示例#1
0
        public static Version GetConfiguredVersion(string roleName)
        {
            Version result  = null;
            string  keyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false);
            string  text    = (string)Registry.GetValue(keyName, "ConfiguredVersion", null);

            if (text == null)
            {
                keyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, true);
                text    = (string)Registry.GetValue(keyName, "ConfiguredVersion", null);
            }
            if (text != null)
            {
                result = new Version(text);
            }
            else if (roleName == "AdminToolsRole")
            {
                Version unpackedVersion = RolesUtility.GetUnpackedVersion(roleName);
                if (unpackedVersion != null && unpackedVersion < AdminToolsRole.FirstConfiguredVersion)
                {
                    result = unpackedVersion;
                }
            }
            return(result);
        }
示例#2
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         if (this.ComponentInfoFileNames == null || this.ComponentInfoFileNames.Count == 0)
         {
             throw new NoComponentInfoFilesException();
         }
         this.ComponentInfoList = new SetupComponentInfoCollection();
         try
         {
             foreach (string path in this.ComponentInfoFileNames)
             {
                 string fileName = Path.Combine(Role.SetupComponentInfoFilePath, path);
                 this.ComponentInfoList.Add(RolesUtility.ReadSetupComponentInfoFile(fileName));
             }
         }
         catch (FileNotFoundException exception)
         {
             base.WriteError(exception, ErrorCategory.ObjectNotFound, null);
         }
         catch (XmlDeserializationException exception2)
         {
             base.WriteError(exception2, ErrorCategory.InvalidData, null);
         }
         this.GenerateAndExecuteTaskScript(this.IsTenantOrganization ? InstallationCircumstances.TenantOrganization : InstallationCircumstances.Standalone);
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
示例#3
0
        public static SetupComponentInfo ReadSetupComponentInfoFile(string fileName)
        {
            SetupComponentInfo setupComponentInfo = null;
            XmlReaderSettings  xmlReaderSettings  = new XmlReaderSettings();

            xmlReaderSettings.ConformanceLevel = ConformanceLevel.Document;
            xmlReaderSettings.ValidationType   = ValidationType.Schema;
            Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("component.xsd");

            xmlReaderSettings.Schemas.Add(null, XmlReader.Create(manifestResourceStream));
            string text;

            using (XmlReader xmlReader = RolesUtility.CreateXmlReader(fileName, xmlReaderSettings, out text))
            {
                try
                {
                    setupComponentInfo = (SetupComponentInfo)RolesUtility.GetComponentSerializer().Deserialize(xmlReader);
                    setupComponentInfo.PopulateTasksProperty(Path.GetFileNameWithoutExtension(fileName));
                    setupComponentInfo.ValidateDatacenterAttributes();
                }
                catch (InvalidOperationException ex)
                {
                    throw new XmlDeserializationException(text, ex.Message, (ex.InnerException == null) ? string.Empty : ex.InnerException.Message);
                }
                TaskLogger.Log(Strings.LoadedComponentWithTasks(setupComponentInfo.Name, setupComponentInfo.Tasks.Count, text));
            }
            return(setupComponentInfo);
        }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter(new object[]
     {
         this.RoleName
     });
     RolesUtility.DeleteConfiguredVersion(this.RoleName);
     TaskLogger.LogExit();
 }
示例#5
0
        private void FindStartingTask(ref List <SetupComponentInfo> .Enumerator componentEnumerator, ref List <TaskInfo> .Enumerator taskEnumerator, ref bool nextTaskNonFatal, InstallationModes installationMode, InstallationCircumstances installationCircumstance)
        {
            bool flag = false;

            if (this.ImplementsResume && this.isResuming && installationMode != InstallationModes.BuildToBuildUpgrade)
            {
                ConfigurationStatus configurationStatus = new ConfigurationStatus(this.taskNoun, this.InstallationMode);
                RolesUtility.GetConfiguringStatus(ref configurationStatus);
                base.WriteVerbose(Strings.LookingForTask(configurationStatus.Action.ToString(), configurationStatus.Watermark));
                while (!flag && componentEnumerator.MoveNext())
                {
                    taskEnumerator = componentEnumerator.Current.Tasks.GetEnumerator();
                    while (!flag && taskEnumerator.MoveNext())
                    {
                        if (taskEnumerator.Current.GetID() == configurationStatus.Watermark)
                        {
                            flag = true;
                            if (this.InstallationMode == InstallationModes.Uninstall && configurationStatus.Action == InstallationModes.Install)
                            {
                                nextTaskNonFatal = true;
                            }
                        }
                        else if (!string.IsNullOrEmpty(taskEnumerator.Current.GetTask(installationMode, installationCircumstance)))
                        {
                            this.completedSteps += taskEnumerator.Current.GetWeight(installationMode);
                        }
                    }
                }
                if (!flag)
                {
                    base.WriteVerbose(Strings.CouldNotFindTask);
                    this.completedSteps = 0;
                }
            }
            if (!flag)
            {
                componentEnumerator = this.ComponentInfoList.GetEnumerator();
                while (componentEnumerator.MoveNext())
                {
                    SetupComponentInfo setupComponentInfo = componentEnumerator.Current;
                    taskEnumerator = setupComponentInfo.Tasks.GetEnumerator();
                    if (taskEnumerator.MoveNext())
                    {
                        flag = true;
                        break;
                    }
                    base.WriteVerbose(Strings.ComponentEmpty(componentEnumerator.Current.Name));
                }
                if (!flag)
                {
                    throw new EmptyTaskListException();
                }
            }
        }
示例#6
0
		protected override void InternalProcessRecord()
		{
			TaskLogger.LogEnter(new object[]
			{
				this.RoleName,
				this.ConfiguredVersion
			});
			RolesUtility.SetConfiguredVersion(this.RoleName, this.ConfiguredVersion);
			base.WriteObject(this.ConfiguredVersion);
			TaskLogger.LogExit();
		}
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            Version unpackedVersion = RolesUtility.GetUnpackedVersion("AdminToolsRole");

            if (unpackedVersion != null && unpackedVersion < AdminToolsRole.FirstConfiguredVersion && RolesUtility.GetConfiguredVersion("AdminToolsRole") == null)
            {
                TaskLogger.Log(Strings.UpdatingAdminToolsConfiguredVersion(unpackedVersion.ToString()));
                RolesUtility.SetConfiguredVersion("AdminToolsRole", unpackedVersion);
            }
            TaskLogger.LogExit();
        }
示例#8
0
        protected SetupComponentInfo LoadComponent(SetupComponentInfoReference reference)
        {
            TaskLogger.LogEnter(new object[]
            {
                this.RoleName,
                reference.RelativeFileLocation
            });
            string             fileName = Path.Combine(Role.SetupComponentInfoFilePath, reference.RelativeFileLocation);
            SetupComponentInfo result   = RolesUtility.ReadSetupComponentInfoFile(fileName);

            TaskLogger.LogExit();
            return(result);
        }
示例#9
0
        protected virtual void PopulateContextVariables()
        {
            DateTime dateTime = (DateTime)ExDateTime.Now;

            base.Fields["InvocationID"]    = string.Format("{0}{1:0000}{2}", dateTime.ToString("yyyyMMdd-HHmmss"), dateTime.Millisecond, ComponentInfoBasedTask.random.Next());
            base.Fields["ProductPlatform"] = ((IntPtr.Size == 8) ? "amd64" : "i386");
            if (this.ShouldLoadDatacenterConfigFile && this.InstallationMode != InstallationModes.Uninstall)
            {
                ParameterCollection parameterCollection = RolesUtility.ReadSetupParameters(this.IsDatacenter || this.IsDatacenterDedicated);
                foreach (Parameter parameter in parameterCollection)
                {
                    base.Fields["Datacenter" + parameter.Name] = parameter.EffectiveValue;
                }
            }
        }
示例#10
0
        protected override void PopulateContextVariables()
        {
            base.Fields["PreviousVersion"] = RolesUtility.GetConfiguredVersion(this.RoleName);
            base.Fields["TargetVersion"]   = ConfigurationContext.Setup.GetExecutingVersion();
            base.Fields["NetBIOSName"]     = base.GetNetBIOSName((string)base.Fields["FqdnOrName"]);
            this.PopulateRoles(RoleManager.Roles, "AllRoles");
            RoleCollection installedRoles = RoleManager.GetInstalledRoles();

            foreach (Role role in installedRoles)
            {
                base.Fields[string.Format("Is{0}Installed", role.RoleName)] = role.IsInstalled;
            }
            this.PopulateRoles(installedRoles, "Roles");
            base.PopulateContextVariables();
        }
示例#11
0
 private bool GetIgnoreFilesInUseFlag()
 {
     if (this.IsDatacenter)
     {
         ParameterCollection parameterCollection = RolesUtility.ReadSetupParameters(this.IsDatacenter);
         foreach (Parameter parameter in parameterCollection)
         {
             if (string.Equals(parameter.Name, "IgnoreFilesInUse", StringComparison.InvariantCultureIgnoreCase))
             {
                 return((bool)parameter.EffectiveValue);
             }
         }
         return(false);
     }
     return(false);
 }
示例#12
0
        public static void DeleteConfiguredVersion(string roleName)
        {
            string      name        = "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false);
            RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(name, true);

            registryKey.DeleteValue("ConfiguredVersion", false);
            registryKey.DeleteValue("PostSetupVersion", false);
            registryKey.Close();
            try
            {
                Registry.LocalMachine.DeleteSubKeyTree("SOFTWARE\\Wow6432Node\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false));
            }
            catch (ArgumentException)
            {
            }
        }
示例#13
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            this.CheckInstallationMode();
            ConfigurationStatus configurationStatus = new ConfigurationStatus(this.taskNoun);

            RolesUtility.GetConfiguringStatus(ref configurationStatus);
            if (this.ImplementsResume && configurationStatus.Action != InstallationModes.Unknown && configurationStatus.Watermark != null)
            {
                this.isResuming = true;
                if (configurationStatus.Action != this.InstallationMode && (configurationStatus.Action != InstallationModes.Install || this.InstallationMode != InstallationModes.Uninstall))
                {
                    base.WriteError(new IllegalResumptionException(configurationStatus.Action.ToString(), this.InstallationMode.ToString()), ErrorCategory.InvalidOperation, null);
                }
            }
            base.InternalValidate();
            TaskLogger.LogExit();
        }
示例#14
0
        public static void GetConfiguringStatus(ref ConfigurationStatus status)
        {
            string name = "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(status.Role, false);

            using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(name))
            {
                if (registryKey != null)
                {
                    InstallationModes action = InstallationModes.Unknown;
                    string            text   = (string)registryKey.GetValue("Action", null);
                    if (text != null)
                    {
                        action = (InstallationModes)Enum.Parse(typeof(InstallationModes), text);
                    }
                    status.Action = action;
                    object value = registryKey.GetValue("Watermark", null);
                    status.Watermark = ((value != null) ? value.ToString() : null);
                }
            }
        }
示例#15
0
        public static void SetConfiguredVersion(string roleName, Version configuredVersion)
        {
            string keyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false);
            string text    = (string)Registry.GetValue(keyName, "ConfiguredVersion", "<unset>");

            TaskLogger.Trace("Updating configured version from {0} to {1}", new object[]
            {
                text,
                configuredVersion
            });
            Registry.SetValue(keyName, "ConfiguredVersion", configuredVersion.ToString());
            if (RolesUtility.GetPostSetupVersion(roleName) == null)
            {
                RolesUtility.SetPostSetupVersion(roleName, new Version("0.0.0.0"));
            }
            using (RegistryKey registryKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false)))
            {
                registryKey.SetValue("ConfiguredVersion", configuredVersion.ToString());
            }
        }
示例#16
0
        public static void ClearConfiguringStatus(ConfigurationStatus status)
        {
            string      name        = "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(status.Role, false);
            RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(name, true);

            if (registryKey != null)
            {
                registryKey.DeleteValue("Action", false);
                registryKey.DeleteValue("Watermark", false);
                if (registryKey.SubKeyCount == 0 && registryKey.ValueCount == 0)
                {
                    registryKey.Close();
                    string      name2        = "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\";
                    RegistryKey registryKey2 = Registry.LocalMachine.OpenSubKey(name2, true);
                    registryKey2.DeleteSubKey(RolesUtility.GetRoleKeyByName(status.Role, false), false);
                    registryKey2.Close();
                    return;
                }
                registryKey.Close();
            }
        }
示例#17
0
        protected void LoadComponentList()
        {
            TaskLogger.LogEnter(new object[]
            {
                this.RoleName
            });
            string fileName = Path.Combine(ConfigurationContext.Setup.AssemblyPath, this.RoleName + "Definition.xml");

            this.allComponents = new SetupComponentInfoCollection();
            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();

            xmlReaderSettings.ConformanceLevel = ConformanceLevel.Document;
            xmlReaderSettings.ValidationType   = ValidationType.Schema;
            Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RoleDefinition.xsd");

            xmlReaderSettings.Schemas.Add(null, XmlReader.Create(manifestResourceStream));
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(SetupComponentInfoReferenceCollection));
            string        text;

            using (XmlReader xmlReader = RolesUtility.CreateXmlReader(fileName, xmlReaderSettings, out text))
            {
                TaskLogger.Log(Strings.ReadingComponents(this.RoleName, text));
                SetupComponentInfoReferenceCollection setupComponentInfoReferenceCollection = null;
                try
                {
                    setupComponentInfoReferenceCollection = (SetupComponentInfoReferenceCollection)xmlSerializer.Deserialize(xmlReader);
                }
                catch (InvalidOperationException ex)
                {
                    throw new XmlDeserializationException(text, ex.Message, (ex.InnerException == null) ? string.Empty : ex.InnerException.Message);
                }
                TaskLogger.Log(Strings.FoundComponents(setupComponentInfoReferenceCollection.Count));
                foreach (SetupComponentInfoReference reference in setupComponentInfoReferenceCollection)
                {
                    SetupComponentInfo item = this.LoadComponent(reference);
                    this.allComponents.Add(item);
                }
            }
            TaskLogger.LogExit();
        }
示例#18
0
        public static ParameterCollection ReadSetupParameters(bool isDatacenter)
        {
            string text = null;

            text = (Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeLabs", "ParametersFile", null) as string);
            if (string.IsNullOrEmpty(text))
            {
                if (isDatacenter)
                {
                    throw new RegistryValueMissingOrInvalidException("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeLabs", "ParametersFile");
                }
                text = Path.Combine(Role.SetupComponentInfoFilePath, "bin\\EnterpriseServiceEndpointsConfig.xml");
            }
            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();

            xmlReaderSettings.ConformanceLevel = ConformanceLevel.Document;
            xmlReaderSettings.ValidationType   = ValidationType.Schema;
            Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("parameter.xsd");

            xmlReaderSettings.Schemas.Add(null, XmlReader.Create(manifestResourceStream));
            ParameterCollection parameterCollection = null;

            using (XmlReader xmlReader = XmlReader.Create(text, xmlReaderSettings))
            {
                try
                {
                    parameterCollection = (ParameterCollection)RolesUtility.GetParameterSerializer().Deserialize(xmlReader);
                }
                catch (InvalidOperationException ex)
                {
                    throw new XmlDeserializationException(text, ex.Message, (ex.InnerException == null) ? string.Empty : ex.InnerException.Message, ex);
                }
            }
            TaskLogger.Log(Strings.LoadedParameters(text, parameterCollection.Count));
            return(parameterCollection);
        }
示例#19
0
        public static void SetConfiguringStatus(ConfigurationStatus status)
        {
            string keyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(status.Role, false);

            Registry.SetValue(keyName, "Action", status.Action);
            Registry.SetValue(keyName, "Watermark", status.Watermark);
        }
示例#20
0
        public static Version GetUnpackedDatacenterVersion(string roleName)
        {
            Version result  = null;
            string  keyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false);
            string  text    = (string)Registry.GetValue(keyName, "UnpackedDatacenterVersion", null);

            if (text != null)
            {
                result = new Version(text);
            }
            return(result);
        }
示例#21
0
        public static void SetPostSetupVersion(string roleName, Version version)
        {
            string keyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false);
            string text    = (string)Registry.GetValue(keyName, "PostSetupVersion", "<unset>");

            TaskLogger.Trace("Updating postsetup version from {0} to {1}", new object[]
            {
                text,
                version
            });
            Registry.SetValue(keyName, "PostSetupVersion", (version == null) ? "" : version.ToString());
        }
示例#22
0
        internal bool GenerateAndExecuteTaskScript(InstallationCircumstances installationCircumstance)
        {
            this.completedSteps = 0;
            bool flag = false;
            ConfigurationStatus configurationStatus = new ConfigurationStatus(this.taskNoun, this.InstallationMode);
            string text = string.Format("{0}-{1}", this.taskVerb, this.taskNoun);

            TaskLogger.LogEnter();
            bool          flag2         = this.ShouldExecuteComponentTasks();
            StringBuilder stringBuilder = new StringBuilder();

            List <TaskInfo> .Enumerator enumerator = default(List <TaskInfo> .Enumerator);
            this.PopulateContextVariables();
            try
            {
                string path  = string.Format("{0}-{1}.ps1", text, base.Fields["InvocationID"]);
                string text2 = Path.Combine(ConfigurationContext.Setup.SetupLoggingPath, path);
                base.WriteVerbose(Strings.WritingInformationScript(text2));
                if (this.shouldWriteLogFile)
                {
                    this.logFileStream           = new StreamWriter(text2);
                    this.logFileStream.AutoFlush = true;
                }
                this.WriteLogFile(Strings.SetupLogHeader(this.taskNoun, this.taskVerb, (DateTime)ExDateTime.Now));
                this.WriteLogFile(Strings.VariablesSection);
                if (base.ServerSettings != null)
                {
                    this.monadConnection.RunspaceProxy.SetVariable(ExchangePropertyContainer.ADServerSettingsVarName, base.ServerSettings);
                }
                this.SetRunspaceVariables();
                SortedList <string, object> sortedList = new SortedList <string, object>();
                foreach (object obj in base.Fields)
                {
                    DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
                    sortedList.Add((string)dictionaryEntry.Key, dictionaryEntry.Value);
                }
                foreach (KeyValuePair <string, object> keyValuePair in sortedList)
                {
                    string text3 = this.GenerateScriptVarCommand(keyValuePair.Key, keyValuePair.Value);
                    this.WriteLogFile(text3);
                    if (flag2)
                    {
                        this.ExecuteScript(text3, false, 0, LocalizedString.Empty);
                    }
                }
                this.FilterComponents();
                if (this.InstallationMode == InstallationModes.Uninstall)
                {
                    base.WriteVerbose(Strings.ReversingTaskList);
                    this.ComponentInfoList.Reverse();
                    foreach (SetupComponentInfo setupComponentInfo in this.ComponentInfoList)
                    {
                        setupComponentInfo.Tasks.Reverse();
                    }
                }
                List <SetupComponentInfo> .Enumerator enumerator5 = this.ComponentInfoList.GetEnumerator();
                bool flag3 = false;
                this.FindStartingTask(ref enumerator5, ref enumerator, ref flag3, this.InstallationMode, installationCircumstance);
                using (enumerator5)
                {
                    bool flag4 = true;
                    bool flag5 = true;
                    this.WriteLogFile(Strings.ComponentTaskSection);
                    this.totalSteps = this.CountStepsToBeExecuted(this.ComponentInfoList, this.InstallationMode, installationCircumstance);
                    while (flag4)
                    {
                        SetupComponentInfo setupComponentInfo2 = enumerator5.Current;
                        string             name = setupComponentInfo2.Name;
                        LocalizedString    localizedString;
                        if (string.IsNullOrEmpty(setupComponentInfo2.DescriptionId))
                        {
                            localizedString = Strings.SetupProgressGenericComponent;
                        }
                        else
                        {
                            try
                            {
                                Strings.IDs key = (Strings.IDs)Enum.Parse(typeof(Strings.IDs), setupComponentInfo2.DescriptionId, false);
                                localizedString = Strings.GetLocalizedString(key);
                            }
                            catch (ArgumentException)
                            {
                                localizedString = Strings.SetupProgressGenericComponent;
                            }
                        }
                        base.WriteVerbose(Strings.ProcessingComponent(name, localizedString));
                        this.WriteLogFile(Strings.ComponentSection(name));
                        while (flag5)
                        {
                            TaskInfo taskInfo = enumerator.Current;
                            string   task     = taskInfo.GetTask(this.InstallationMode, installationCircumstance);
                            if (string.IsNullOrEmpty(task))
                            {
                                flag5 = enumerator.MoveNext();
                            }
                            else if (!this.IsTaskIncluded(taskInfo, enumerator5.Current))
                            {
                                flag5 = enumerator.MoveNext();
                            }
                            else
                            {
                                string text4  = task;
                                string id     = taskInfo.GetID();
                                int    weight = taskInfo.GetWeight(this.InstallationMode);
                                bool   flag6  = !flag3 && taskInfo.IsFatal(this.InstallationMode);
                                flag3 = false;
                                string          description = taskInfo.GetDescription(this.InstallationMode);
                                LocalizedString localizedString2;
                                if (string.IsNullOrEmpty(description))
                                {
                                    localizedString2 = localizedString;
                                }
                                else
                                {
                                    try
                                    {
                                        Strings.IDs key2 = (Strings.IDs)Enum.Parse(typeof(Strings.IDs), description, false);
                                        localizedString2 = Strings.GetLocalizedString(key2);
                                    }
                                    catch (ArgumentException)
                                    {
                                        localizedString2 = localizedString;
                                    }
                                }
                                this.WriteLogFile(string.Format("# [ID = {0:x}, Wt = {1}, isFatal = {2}] \"{3}\"", new object[]
                                {
                                    taskInfo.GetID(),
                                    weight,
                                    flag6,
                                    localizedString2
                                }));
                                this.WriteLogFile(ExDateTime.Now + ":" + text4);
                                if (flag2)
                                {
                                    configurationStatus.Watermark = id;
                                    if (this.ImplementsResume)
                                    {
                                        RolesUtility.SetConfiguringStatus(configurationStatus);
                                    }
                                    if (!text4.Contains("\n"))
                                    {
                                        text4 = "\n\t" + text4 + "\n\n";
                                    }
                                    ExDateTime now      = ExDateTime.Now;
                                    bool       flag7    = this.ExecuteScript(text4, !flag6, weight, localizedString2);
                                    TimeSpan   timeSpan = ExDateTime.Now - now;
                                    if (ComponentInfoBasedTask.monitoredCmdlets.Contains(text.ToLowerInvariant()) && timeSpan.CompareTo(this.executionTimeThreshold) > 0)
                                    {
                                        if (taskInfo is ServicePlanTaskInfo)
                                        {
                                            ServicePlanTaskInfo servicePlanTaskInfo = (ServicePlanTaskInfo)taskInfo;
                                            stringBuilder.AppendLine(string.Format("Task {0}__{1} had execution time: {2}.", servicePlanTaskInfo.FileId, servicePlanTaskInfo.FeatureName, timeSpan.ToString()));
                                        }
                                        else
                                        {
                                            stringBuilder.AppendLine(string.Format("Task {0} had execution time: {1}.", taskInfo.GetID(), timeSpan.ToString()));
                                        }
                                    }
                                    flag = (!flag7 && flag6);
                                    if (flag)
                                    {
                                        base.WriteVerbose(new LocalizedString(string.Format("[ERROR-REFERENCE] Id={0} Component={1}", taskInfo.GetID(), taskInfo.Component)));
                                        base.WriteVerbose(Strings.HaltingExecution);
                                        break;
                                    }
                                }
                                flag5 = enumerator.MoveNext();
                            }
                        }
                        if (flag)
                        {
                            break;
                        }
                        flag4 = enumerator5.MoveNext();
                        if (flag4)
                        {
                            enumerator.Dispose();
                            enumerator = enumerator5.Current.Tasks.GetEnumerator();
                            flag5      = enumerator.MoveNext();
                        }
                    }
                    base.WriteVerbose(Strings.FinishedComponentTasks);
                }
            }
            catch (Exception ex)
            {
                base.WriteVerbose(Strings.ExceptionOccured(ex.ToString()));
                flag = true;
                this.OnHalt(ex);
                throw;
            }
            finally
            {
                if (!string.IsNullOrEmpty(stringBuilder.ToString()) && ComponentInfoBasedTask.monitoredCmdlets.Contains(text.ToLowerInvariant()))
                {
                    if (base.Fields["TenantName"] != null)
                    {
                        ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_ExecuteTaskScriptOptic, new string[]
                        {
                            text,
                            base.Fields["TenantName"].ToString(),
                            stringBuilder.ToString()
                        });
                    }
                    else if (base.Fields["OrganizationHierarchicalPath"] != null)
                    {
                        ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_ExecuteTaskScriptOptic, new string[]
                        {
                            text,
                            base.Fields["OrganizationHierarchicalPath"].ToString(),
                            stringBuilder.ToString()
                        });
                    }
                    else
                    {
                        ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_ExecuteTaskScriptOptic, new string[]
                        {
                            text,
                            string.Empty,
                            stringBuilder.ToString()
                        });
                    }
                }
                if (flag)
                {
                    if (this.IsCmdletLogEntriesEnabled)
                    {
                        ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_ComponentTaskFailed, this.GetComponentEventParameters(this.GetVerboseInformation(this.GetCmdletLogEntries())));
                    }
                    base.WriteProgress(this.Description, Strings.ProgressStatusFailed, 100);
                }
                else
                {
                    if (this.IsCmdletLogEntriesEnabled)
                    {
                        ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_ComponentTaskExecutedSuccessfully, this.GetComponentEventParameters(this.GetVerboseInformation(this.GetCmdletLogEntries())));
                    }
                    base.WriteProgress(this.Description, Strings.ProgressStatusCompleted, 100);
                    if (flag2)
                    {
                        RolesUtility.ClearConfiguringStatus(configurationStatus);
                        if (text == "Start-PostSetup")
                        {
                            foreach (string roleName in base.Fields["Roles"].ToString().Split(new char[]
                            {
                                ','
                            }))
                            {
                                RolesUtility.SetPostSetupVersion(roleName, (Version)base.Fields["TargetVersion"]);
                            }
                            RolesUtility.SetPostSetupVersion("AdminTools", (Version)base.Fields["TargetVersion"]);
                        }
                    }
                }
                if (this.logFileStream != null)
                {
                    this.logFileStream.Close();
                    this.logFileStream = null;
                }
                enumerator.Dispose();
                TaskLogger.LogExit();
            }
            return(!flag);
        }