Пример #1
0
        /// <summary>
        /// Downloads all updates and applies them.
        /// </summary>
        private void DownloadAndApplyUpdates()
        {
            try
            {
                var version = this.GetLocalVersion();
                var list    = _patchList.OrderBy(a => a.Version).SkipWhile(a => a.Version <= version);

                foreach (var patchFile in list)
                {
                    var patchFileName = patchFile.FileName;
                    var patchFileUri  = Path.Combine(_conf.PatchUri, patchFileName);

                    this.SetStatus("Downloading {0}...", patchFileName);
                    this.DownloadAndExtractPatch(patchFileUri, patchFileName, TempDirName);

                    this.SetStatus("Checking {0}...", patchFileName);
                    this.AssertPatchApplicable(TempDirName);

                    this.SetStatus("Applying {0}...", patchFileName);
                    this.ApplyPatch(TempDirName);
                    this.RemoveTempFolder(TempDirName);

                    this.UpdateLocalVersion(patchFile.Version);
                }
            }
            catch (FileNotFoundException ex)
            {
                this.RemoveTempFolder(TempDirName);
                this.ShowError(ex.Message);
                return;
            }
            catch (WebException ex)
            {
                this.RemoveTempFolder(TempDirName);
                this.ShowError(ex.Message);
                return;
            }
            catch (Exception ex)
            {
                this.RemoveTempFolder(TempDirName);
                this.ShowError(ex.ToString());
                return;
            }

            this.UpdateComplete();
        }