Update.cs 2.0 KB
//----------------------------------------------------------------
// Copyright (C) 2000-2003 Shangxin Corporation
// All rights reserved.
using System;
using System.Data;
using LiveUpdate.UpdateSvc;

namespace LiveUpdate
{
    /// <summary>
    /// UpdateSystem 的摘要说明。
    /// </summary>
    public class UpdateSystem
    {
        protected System.Net.CookieContainer Cookies;
        private string WebServiceUrl = "";
        public UpdateSystem()
        {
        }

        public UpdateSystem(string Url)
        {
            WebServiceUrl = Url;
        }

        private UpdateSvc.UpdateSvc m_wsUpdateSvc;

        private UpdateSvc.UpdateSvc NewUpdateSvc()
        {
            if (m_wsUpdateSvc == null)
            {
                m_wsUpdateSvc = new UpdateSvc.UpdateSvc();
                if (WebServiceUrl != "")
                {
                    m_wsUpdateSvc.Url = WebServiceUrl;
                }
                SetCookiesUriHaveCookie(m_wsUpdateSvc);
            }
            return m_wsUpdateSvc;
        }


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

        /// <summary>
        /// 获得最新客户端的版本信息
        /// </summary>
        /// <returns></returns>
        public string GetClientVersion()
        {
            return NewUpdateSvc().GetClientVersion();
        }

        public DataSet GetClientFileList()
        {
            return NewUpdateSvc().GetClientFileList();
        }

        public byte[] GetClientFile(string FileName)
        {
            return NewUpdateSvc().GetClientFile(FileName);
        }

        public string GetUpdateUrl()
        {
            UpdateSvc.UpdateSvc usws = new UpdateSvc.UpdateSvc();
            if (this.WebServiceUrl != null || this.WebServiceUrl != "")
            {
                usws.Url = this.WebServiceUrl;
            }
            return usws.Url;
        }
    }
}