Example #1
0
        public void Load()
        {
            if (_isLoad)
            {
                return;
            }
            _isLoad = true;
            Configure.UpdateDirectory.Create();

            FileInfo file = new FileInfo(Path.Combine(Configure.UpdateDirectory.FullName, Configure.VersionNumberFileName));

            if (!file.Exists)
            {
                return;
            }
            string version = File.ReadAllText(file.FullName);

            _currentVersionNumber = Convert.ToInt32(version);
            _currentUFI           = new UpdateFileInfoManager(new FileInfo(Path.Combine(Configure.UpdateDirectory.FullName, Configure.UpdateFileListName)));

            try {
                if (Configure.DownloadsDirectory.Exists)
                {
                    DateTime dirCreated = Configure.DownloadsDirectory.CreationTime;
                    if (dirCreated.AddHours(1).Ticks < DateTime.Now.Ticks)
                    {
                        try {
                            Configure.DownloadsDirectory.Delete(true);
                        } catch { }
                    }
                }
            } catch { }
            Configure.DownloadsDirectory.Create();
        }
        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)));
        }