Esempio n. 1
0
        public void CheckForUpdatesMethod()
        {
            this.Load();
            _error = UpdateManagerError.None;
            _checkForUpdateProcess = true;
            this.OnStartCheckForUpdates(EventArgs.Empty);
            try {
                if (!_isOldVersion)
                {
                    string url  = Configure.CreateScriptGetVersionUrl();
                    string page = WebReader.ReadPage(url);

                    if (page == "")
                    {
                        _error = UpdateManagerError.ConnectionError;
                    }
                    else
                    {
                        string[] sa = page.Split('\n');
                        if (sa.Length != 2 || sa[0] != "ok")
                        {
                            _error = UpdateManagerError.ServerError;
                        }
                        else
                        {
                            _newVersionNumber = Convert.ToInt32(sa[1]);

                            if (_newVersionNumber < 1)
                            {
                                _error = UpdateManagerError.ServerError;
                            }
                            else
                            {
                                if (_newVersionNumber > _currentVersionNumber)
                                {
                                    _isOldVersion = true;
                                }
                            }
                        }
                    }
                }
            } finally {
                _checkForUpdateProcess = false;
                this.OnStopCheckForUpdates(EventArgs.Empty);
            }
        }
Esempio n. 2
0
        private void CreateDetails()
        {
            DirectoryInfo dir = Configure.VersionUserInfoDirectory;

            for (int i = 1; i <= _updateManager.CurrentVersionNumber; i++)
            {
                string   templateVersion = i == _updateManager.CurrentVersionNumber ? TEMPLATE_VERSION_CURRENT : TEMPLATE_VERSION;
                string   userInfoHtml    = "";
                FileInfo userInfoFile    = new FileInfo(Path.Combine(Configure.VersionUserInfoDirectory.FullName, string.Format(Configure.VersionUserInfoFileName, i)));

                if (userInfoFile.Exists)
                {
                    userInfoHtml = File.ReadAllText(userInfoFile.FullName);
                }

                _userInfo.Add(string.Format(templateVersion, i, userInfoHtml));
            }

            WebReader          webReader = _updateManager.WebReader;
            UpdateManagerError error     = this.DownloaFiles();

            if (error != UpdateManagerError.None)
            {
                throw (new WebReaderException(error, ""));
            }

            _newUFI = new UpdateFileInfoManager(_updateFilesFile);
            _moveFiles.Add(new MoveFile(_updateFilesFile, Configure.UpdateDirectory));

            UpdateFileInfo[] ufis = this.GetUpdateFiles();
            int downloadSize      = 0;

            foreach (UpdateFileInfo ufi in ufis)
            {
                if (ufi.Action != UpdateFileInfoAction.Deleted)
                {
                    downloadSize += ufi.CompressSize;
                }
            }

            _userInfo.Add(string.Format(TEMPLATE_INFO_SIZE, ConvertToSize(downloadSize)));
        }
Esempio n. 3
0
 public UpdateDetailsManager(UpdateManager updateManager)
 {
     _updateManager = updateManager;
     _webReader     = updateManager.WebReader;
     this.CreateDetails();
 }