Esempio n. 1
0
        public void NotifyOccured(NotifyType notifyType, Socket socket, BaseInfo baseInfo)
        {
            switch (notifyType)
            {
            case NotifyType.Notify_Socket:
            {
                QQMessageBox.Show(_ProgressForm, "服务器连接失败", "消息", QQMessageBoxIcon.Warning, QQMessageBoxButtons.OK);
                Environment.Exit(0);
            }
            break;

            case NotifyType.Reply_Server:
            {
                _ServerInfo   = (ServerInfo)baseInfo;
                _DownloadPath = _UpdateIni.GetIniValue("DownloadServer", "URL") + "/" + _ServerInfo.DownloadAddress;

                if (_DownloadPath[_DownloadPath.Length - 1] != '/')
                {
                    _DownloadPath += '/';
                }

                string localRoot = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "\\..\\");
                WebDownloader.localRoot = localRoot;

                WebDownloader.progressForm = _ProgressForm;
                WebDownloader.GetInstance().DownloadFile("server.version", DownloadVersionCompleted, _DownloadPath);
            }
            break;
            }
        }
Esempio n. 2
0
        public void DownloadFileCompleted(string filePath)
        {
            DownloadFileInfo foundInfo = null;

            foreach (DownloadFileInfo localInfo in _LocalVersions)
            {
                if (localInfo.FilePath == _ServerVersions[0].FilePath)
                {
                    foundInfo = localInfo;
                    break;
                }
            }

            if (foundInfo == null)
            {
                foundInfo          = new DownloadFileInfo();
                foundInfo.FilePath = _ServerVersions[0].FilePath;

                _LocalVersions.Add(foundInfo);
            }

            foundInfo.FileVersion = _ServerVersions[0].FileVersion;

            _ServerVersions.RemoveAt(0);

            if (NeedDownload())
            {
                WebDownloader.GetInstance().DownloadFile(_ServerVersions[0].FilePath, DownloadFileCompleted, _DownloadPath);
            }
        }
Esempio n. 3
0
        static public WebDownloader GetInstance()
        {
            if (_instance == null)
            {
                _instance = new WebDownloader();
            }

            return(_instance);
        }
Esempio n. 4
0
        public void DownloadVersionCompleted(string filePath)
        {
            _LoginEngine.DetachHandler(NotifyOccured);
            _LoginEngine.Disconnect();

            _ServerVersions = VersionInfo.ReadInfoFile(WebDownloader.localRoot, false);
            _LocalVersions  = VersionInfo.ReadInfoFile(WebDownloader.localRoot, true);


            if (NeedDownload())
            {
                WebDownloader.GetInstance().DownloadFile(_ServerVersions[0].FilePath, DownloadFileCompleted, _DownloadPath);
            }
        }