BaseSystem.cs 2.5 KB
using System;
using System.ComponentModel;
using System.Data;
using System.Net;

namespace BizFacade
{
    using Comm;


    /// <summary>
    /// BaseSystem ժҪ˵
    /// </summary>
    public class BaseSystem
    {
        protected System.Net.CookieContainer Cookies;
        protected System.Uri webServiceUri;

        public BaseSystem()
        {
        }

        protected void SetCookiesUriHaveCookie(System.Web.Services.Protocols.SoapHttpClientProtocol ws)
        {
            if (Cookies == null)
                Cookies = new System.Net.CookieContainer();
            ws.CookieContainer = Cookies;
            ws.Timeout = -1;
        }

        protected void SetCookiesUri(System.Web.Services.Protocols.SoapHttpClientProtocol ws)
        {
            if (Cookies == null)
                Cookies = new System.Net.CookieContainer();
            ws.CookieContainer = Cookies;
            ws.Timeout = -1;
            // Set the Url on the ws
            if (webServiceUri == null)
                webServiceUri = new Uri(ws.Url);
            else
                ws.Url = webServiceUri.AbsoluteUri;
        }
        protected bool DealRedirect(WebException we, System.Web.Services.Protocols.SoapHttpClientProtocol ws)
        {
            // We need an HttpWebResponse if we expect to 
            // check the HTTP status code.
            if (we.Response.GetType() == typeof(HttpWebResponse))
            {
                HttpWebResponse HttpResponse;
                HttpResponse = (HttpWebResponse)we.Response;
                if (HttpResponse.StatusCode == HttpStatusCode.Found)
                {
                    // This is a "302 Found" response. Prompt the user
                    // to see if it is okay to redirect.
                    string str = HttpResponse.Headers["Location"];
                    webServiceUri = new Uri(webServiceUri, HttpResponse.Headers["Location"]);
                    return true;
                }
            }
            return false;
        }

        public bool TestServiceUrl(string ServiceUrl)
        {
            BaseSvc.BaseSvc ws = new BaseSvc.BaseSvc();
            ws.Url = ServiceUrl;
            return ws.TestServiceUrl();

        }

        public string GetServiceUrl()
        {
            BaseSvc.BaseSvc ws = new BaseSvc.BaseSvc();
            return ws.Url;
        }



        public string GetServiceVersion()
        {
            BaseSvc.BaseSvc ws = new BaseSvc.BaseSvc();
            return ws.GetServiceVersion();
        }

    }
}