protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            UpdatableExchangeHelpSystemException ex = null;

            try
            {
                ex = this.helpUpdater.UpdateHelp();
            }
            catch (Exception ex2)
            {
                if (ex2.GetType() == typeof(UpdatableExchangeHelpSystemException))
                {
                    ex = (UpdatableExchangeHelpSystemException)ex2;
                }
                else
                {
                    ex = new UpdatableExchangeHelpSystemException(UpdatableHelpStrings.UpdateGeneralExceptionErrorID, UpdatableHelpStrings.UpdateGeneralException, ErrorCategory.InvalidOperation, null, ex2);
                }
            }
            if (ex != null)
            {
                this.WriteError(ex, ex.ErrorCategory, ex.TargetObject, false);
            }
            TaskLogger.LogExit();
        }
예제 #2
0
        internal UpdatableExchangeHelpSystemException UpdateHelp()
        {
            double num = 90.0;
            UpdatableExchangeHelpSystemException result = null;

            this.ProgressNumerator = 0.0;
            if (!this.Cmdlet.Force)
            {
                if (!this.DownloadThrottleExpired())
                {
                    this.Cmdlet.WriteVerbose(UpdatableHelpStrings.UpdateUseForceToUpdateHelp(this.ThrottlingPeriodHours));
                    return(result);
                }
            }
            try
            {
                this.UpdateProgress(UpdatePhase.Checking, LocalizedString.Empty, (int)this.ProgressNumerator, 100);
                string path = this.LocalTempBase + "UpdateHelp.$$$\\";
                this.CleanDirectory(path);
                this.EnsureDirectory(path);
                HelpDownloader helpDownloader = new HelpDownloader(this);
                helpDownloader.DownloadManifest();
                if (!this.Cmdlet.Abort)
                {
                    UpdatableHelpVersionRange updatableHelpVersionRange = helpDownloader.SearchManifestForApplicableUpdates(this.CurrentHelpVersion, this.CurrentHelpRevision);
                    if (updatableHelpVersionRange != null)
                    {
                        double num2 = 20.0;
                        this.ProgressNumerator = 10.0;
                        this.UpdateProgress(UpdatePhase.Downloading, LocalizedString.Empty, (int)this.ProgressNumerator, 100);
                        string[] array = this.EnumerateAffectedCultures(updatableHelpVersionRange.CulturesAffected);
                        if (array.Length > 0)
                        {
                            this.Cmdlet.WriteVerbose(UpdatableHelpStrings.UpdateApplyingRevision(updatableHelpVersionRange.HelpRevision, string.Join(", ", array)));
                            helpDownloader.DownloadPackage(updatableHelpVersionRange.CabinetUrl);
                            if (this.Cmdlet.Abort)
                            {
                                return(result);
                            }
                            this.ProgressNumerator += num2;
                            this.UpdateProgress(UpdatePhase.Extracting, LocalizedString.Empty, (int)this.ProgressNumerator, 100);
                            HelpInstaller helpInstaller = new HelpInstaller(this, array, num);
                            helpInstaller.ExtractToTemp();
                            if (this.Cmdlet.Abort)
                            {
                                return(result);
                            }
                            this.ProgressNumerator += num2;
                            this.UpdateProgress(UpdatePhase.Validating, LocalizedString.Empty, (int)this.ProgressNumerator, 100);
                            Dictionary <string, LocalizedString> dictionary = helpInstaller.ValidateFiles();
                            if (this.Cmdlet.Abort)
                            {
                                return(result);
                            }
                            if (dictionary != null && dictionary.Count > 0)
                            {
                                this.Cmdlet.WriteVerbose(UpdatableHelpStrings.UpdateInvalidHelpFiles);
                                foreach (KeyValuePair <string, LocalizedString> keyValuePair in dictionary)
                                {
                                    this.Cmdlet.WriteVerbose(UpdatableHelpStrings.UpdateInvalidFileDescription(keyValuePair.Key, keyValuePair.Value));
                                }
                                throw new UpdatableExchangeHelpSystemException(UpdatableHelpStrings.UpdateContentXmlValidationFailureErrorID, UpdatableHelpStrings.UpdateContentXmlValidationFailure, ErrorCategory.NotInstalled, null, null);
                            }
                            this.ProgressNumerator += num2;
                            this.UpdateProgress(UpdatePhase.Installing, LocalizedString.Empty, (int)this.ProgressNumerator, 100);
                            if (!helpInstaller.AtomicInstallFiles())
                            {
                                throw new UpdatableExchangeHelpSystemException(UpdatableHelpStrings.UpdateInstallFilesExceptionErrorID, UpdatableHelpStrings.UpdateInstallFilesException, ErrorCategory.NotInstalled, null, null);
                            }
                        }
                        else
                        {
                            this.Cmdlet.WriteVerbose(UpdatableHelpStrings.UpdateSkipRevision(updatableHelpVersionRange.HelpRevision));
                        }
                        this.UpdateCurrentVersionInRegistry(updatableHelpVersionRange.HelpRevision);
                        this.Cmdlet.WriteVerbose(UpdatableHelpStrings.UpdateRevisionApplied(updatableHelpVersionRange.HelpRevision));
                        this.ProgressNumerator += num2;
                    }
                    else
                    {
                        this.Cmdlet.WriteVerbose(UpdatableHelpStrings.UpdateNoApplicableUpdates);
                    }
                    this.ProgressNumerator = num;
                    this.UpdateProgress(UpdatePhase.Finalizing, LocalizedString.Empty, (int)this.ProgressNumerator, 100);
                    try
                    {
                        this.CleanDirectory(path);
                        if (Directory.Exists(path))
                        {
                            Directory.Delete(path);
                        }
                    }
                    catch
                    {
                    }
                    this.UpdateLastSuccessfulCheckTimestamp(DateTime.UtcNow);
                }
            }
            catch (Exception ex)
            {
                if (ex.GetType() == typeof(UpdatableExchangeHelpSystemException))
                {
                    result = (UpdatableExchangeHelpSystemException)ex;
                }
                else
                {
                    result = new UpdatableExchangeHelpSystemException(UpdatableHelpStrings.UpdateInstallFilesExceptionErrorID, UpdatableHelpStrings.UpdateInstallFilesException, ErrorCategory.InvalidOperation, null, ex);
                }
            }
            this.ProgressNumerator = 100.0;
            this.UpdateProgress(UpdatePhase.Finalizing, LocalizedString.Empty, (int)this.ProgressNumerator, 100);
            return(result);
        }