Exemple #1
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);
        }
        internal static SetupComponentInfoCollection GetRequiredComponents(string roleName, InstallationModes mode)
        {
            TaskLogger.LogEnter(new object[]
            {
                roleName
            });
            Role           roleByName   = RoleManager.GetRoleByName(roleName);
            RoleCollection currentRoles = RoleManager.GetCurrentRoles();

            currentRoles.Remove(roleByName);
            SetupComponentInfoCollection setupComponentInfoCollection = new SetupComponentInfoCollection();

            foreach (Role role in currentRoles)
            {
                setupComponentInfoCollection.AddRange(role.AllComponents);
            }
            SetupComponentInfoCollection allComponents = roleByName.AllComponents;
            SetupComponentInfoCollection setupComponentInfoCollection2 = new SetupComponentInfoCollection();

            if (mode == InstallationModes.BuildToBuildUpgrade)
            {
                setupComponentInfoCollection2.AddRange(allComponents);
            }
            else
            {
                using (List <SetupComponentInfo> .Enumerator enumerator2 = allComponents.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        SetupComponentInfo candidate = enumerator2.Current;
                        bool flag = false;
                        if (candidate.AlwaysExecute)
                        {
                            TaskLogger.Log(Strings.RunningAlwaysToRunComponent(candidate.Name));
                            flag = true;
                        }
                        else if (setupComponentInfoCollection.Find((SetupComponentInfo sci) => sci.Name == candidate.Name) == null)
                        {
                            TaskLogger.Log(Strings.AddingUniqueComponent(candidate.Name));
                            flag = true;
                        }
                        else
                        {
                            TaskLogger.Log(Strings.AlreadyConfiguredComponent(candidate.Name));
                        }
                        if (flag)
                        {
                            setupComponentInfoCollection2.Add(candidate);
                        }
                    }
                }
            }
            TaskLogger.LogExit();
            return(setupComponentInfoCollection2);
        }
Exemple #3
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();
                }
            }
        }
Exemple #4
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);
        }
Exemple #5
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();
        }
Exemple #6
0
        private SetupComponentInfo Read12_SetupComponentInfo(bool isNullable, bool checkType)
        {
            XmlQualifiedName xmlQualifiedName = checkType ? base.GetXsiType() : null;
            bool             flag             = false;

            if (isNullable)
            {
                flag = base.ReadNull();
            }
            if (checkType && !(xmlQualifiedName == null) && (xmlQualifiedName.Name != this.id1_SetupComponentInfo || xmlQualifiedName.Namespace != this.id2_Item))
            {
                throw base.CreateUnknownTypeException(xmlQualifiedName);
            }
            if (flag)
            {
                return(null);
            }
            SetupComponentInfo setupComponentInfo = new SetupComponentInfo();

            if (setupComponentInfo.ServerTasks == null)
            {
                setupComponentInfo.ServerTasks = new ServerTaskInfoCollection();
            }
            ServerTaskInfoCollection serverTasks = setupComponentInfo.ServerTasks;

            if (setupComponentInfo.OrgTasks == null)
            {
                setupComponentInfo.OrgTasks = new OrgTaskInfoCollection();
            }
            OrgTaskInfoCollection orgTasks = setupComponentInfo.OrgTasks;

            if (setupComponentInfo.ServicePlanOrgTasks == null)
            {
                setupComponentInfo.ServicePlanOrgTasks = new ServicePlanTaskInfoCollection();
            }
            ServicePlanTaskInfoCollection servicePlanOrgTasks = setupComponentInfo.ServicePlanOrgTasks;
            TaskInfoCollection            tasks = setupComponentInfo.Tasks;

            bool[] array = new bool[12];
            while (base.Reader.MoveToNextAttribute())
            {
                if (!array[0] && base.Reader.LocalName == this.id3_Name && base.Reader.NamespaceURI == this.id2_Item)
                {
                    setupComponentInfo.Name = base.Reader.Value;
                    array[0] = true;
                }
                else if (!array[1] && base.Reader.LocalName == this.id4_AlwaysExecute && base.Reader.NamespaceURI == this.id2_Item)
                {
                    setupComponentInfo.AlwaysExecute = XmlConvert.ToBoolean(base.Reader.Value);
                    array[1] = true;
                }
                else if (!array[2] && base.Reader.LocalName == this.id5_IsDatacenterOnly && base.Reader.NamespaceURI == this.id2_Item)
                {
                    setupComponentInfo.IsDatacenterOnly = XmlConvert.ToBoolean(base.Reader.Value);
                    array[2] = true;
                }
                else if (!array[3] && base.Reader.LocalName == this.id6_DescriptionId && base.Reader.NamespaceURI == this.id2_Item)
                {
                    setupComponentInfo.DescriptionId = base.Reader.Value;
                    array[3] = true;
                }
                else if (!array[4] && base.Reader.LocalName == this.id50_IsPartnerHostedOnly && base.Reader.NamespaceURI == this.id2_Item)
                {
                    setupComponentInfo.IsPartnerHostedOnly = XmlConvert.ToBoolean(base.Reader.Value);
                    array[4] = true;
                }
                else if (!array[5] && base.Reader.LocalName == this.id22_DatacenterMode && base.Reader.NamespaceURI == this.id2_Item)
                {
                    setupComponentInfo.DatacenterMode = this.Read14_DatacenterMode(base.Reader.Value);
                    array[5] = true;
                }
                else if (!array[6] && base.Reader.LocalName == this.id55_IsDatacenterDedicatedOnly && base.Reader.NamespaceURI == this.id2_Item)
                {
                    setupComponentInfo.IsDatacenterDedicatedOnly = XmlConvert.ToBoolean(base.Reader.Value);
                    array[6] = true;
                }
                else if (!base.IsXmlnsAttribute(base.Reader.Name))
                {
                    base.UnknownNode(setupComponentInfo, ":Name, :AlwaysExecute, :IsDatacenterOnly, :DescriptionId, :IsPartnerHostedOnly, :IsDatacenterDedicatedOnly");
                }
            }
            base.Reader.MoveToElement();
            if (base.Reader.IsEmptyElement)
            {
                base.Reader.Skip();
                return(setupComponentInfo);
            }
            base.Reader.ReadStartElement();
            base.Reader.MoveToContent();
            int num         = 0;
            int readerCount = base.ReaderCount;

            while (base.Reader.NodeType != XmlNodeType.EndElement && base.Reader.NodeType != XmlNodeType.None)
            {
                if (base.Reader.NodeType == XmlNodeType.Element)
                {
                    if (base.Reader.LocalName == this.id7_ServerTasks && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        if (!base.ReadNull())
                        {
                            if (setupComponentInfo.ServerTasks == null)
                            {
                                setupComponentInfo.ServerTasks = new ServerTaskInfoCollection();
                            }
                            ServerTaskInfoCollection serverTasks2 = setupComponentInfo.ServerTasks;
                            if (base.Reader.IsEmptyElement)
                            {
                                base.Reader.Skip();
                            }
                            else
                            {
                                base.Reader.ReadStartElement();
                                base.Reader.MoveToContent();
                                int num2         = 0;
                                int readerCount2 = base.ReaderCount;
                                while (base.Reader.NodeType != XmlNodeType.EndElement && base.Reader.NodeType != XmlNodeType.None)
                                {
                                    if (base.Reader.NodeType == XmlNodeType.Element)
                                    {
                                        if (base.Reader.LocalName == this.id8_ServerTaskInfo && base.Reader.NamespaceURI == this.id2_Item)
                                        {
                                            if (serverTasks2 == null)
                                            {
                                                base.Reader.Skip();
                                            }
                                            else
                                            {
                                                serverTasks2.Add(this.Read7_ServerTaskInfo(true, true));
                                            }
                                        }
                                        else
                                        {
                                            base.UnknownNode(null, ":ServerTaskInfo");
                                        }
                                    }
                                    else
                                    {
                                        base.UnknownNode(null, ":ServerTaskInfo");
                                    }
                                    base.Reader.MoveToContent();
                                    base.CheckReaderCount(ref num2, ref readerCount2);
                                }
                                base.ReadEndElement();
                            }
                        }
                    }
                    else if (base.Reader.LocalName == this.id9_OrgTasks && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        if (!base.ReadNull())
                        {
                            if (setupComponentInfo.OrgTasks == null)
                            {
                                setupComponentInfo.OrgTasks = new OrgTaskInfoCollection();
                            }
                            OrgTaskInfoCollection orgTasks2 = setupComponentInfo.OrgTasks;
                            if (base.Reader.IsEmptyElement)
                            {
                                base.Reader.Skip();
                            }
                            else
                            {
                                base.Reader.ReadStartElement();
                                base.Reader.MoveToContent();
                                int num3         = 0;
                                int readerCount3 = base.ReaderCount;
                                while (base.Reader.NodeType != XmlNodeType.EndElement && base.Reader.NodeType != XmlNodeType.None)
                                {
                                    if (base.Reader.NodeType == XmlNodeType.Element)
                                    {
                                        if (base.Reader.LocalName == this.id10_OrgTaskInfo && base.Reader.NamespaceURI == this.id2_Item)
                                        {
                                            if (orgTasks2 == null)
                                            {
                                                base.Reader.Skip();
                                            }
                                            else
                                            {
                                                orgTasks2.Add(this.Read10_OrgTaskInfo(true, true));
                                            }
                                        }
                                        else if (base.Reader.LocalName == this.id12_ServicePlanTaskInfo && base.Reader.NamespaceURI == this.id2_Item)
                                        {
                                            if (orgTasks2 == null)
                                            {
                                                base.Reader.Skip();
                                            }
                                            else
                                            {
                                                orgTasks2.Add(this.Read11_ServicePlanTaskInfo(true, true));
                                            }
                                        }
                                        else
                                        {
                                            base.UnknownNode(null, ":OrgTaskInfo");
                                        }
                                    }
                                    else
                                    {
                                        base.UnknownNode(null, ":OrgTaskInfo");
                                    }
                                    base.Reader.MoveToContent();
                                    base.CheckReaderCount(ref num3, ref readerCount3);
                                }
                                base.ReadEndElement();
                            }
                        }
                    }
                    else if (base.Reader.LocalName == this.id11_ServicePlanOrgTasks && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        if (!base.ReadNull())
                        {
                            if (setupComponentInfo.ServicePlanOrgTasks == null)
                            {
                                setupComponentInfo.ServicePlanOrgTasks = new ServicePlanTaskInfoCollection();
                            }
                            ServicePlanTaskInfoCollection servicePlanOrgTasks2 = setupComponentInfo.ServicePlanOrgTasks;
                            if (base.Reader.IsEmptyElement)
                            {
                                base.Reader.Skip();
                            }
                            else
                            {
                                base.Reader.ReadStartElement();
                                base.Reader.MoveToContent();
                                int num4         = 0;
                                int readerCount4 = base.ReaderCount;
                                while (base.Reader.NodeType != XmlNodeType.EndElement && base.Reader.NodeType != XmlNodeType.None)
                                {
                                    if (base.Reader.NodeType == XmlNodeType.Element)
                                    {
                                        if (base.Reader.LocalName == this.id12_ServicePlanTaskInfo && base.Reader.NamespaceURI == this.id2_Item)
                                        {
                                            if (servicePlanOrgTasks2 == null)
                                            {
                                                base.Reader.Skip();
                                            }
                                            else
                                            {
                                                servicePlanOrgTasks2.Add(this.Read11_ServicePlanTaskInfo(true, true));
                                            }
                                        }
                                        else
                                        {
                                            base.UnknownNode(null, ":ServicePlanTaskInfo");
                                        }
                                    }
                                    else
                                    {
                                        base.UnknownNode(null, ":ServicePlanTaskInfo");
                                    }
                                    base.Reader.MoveToContent();
                                    base.CheckReaderCount(ref num4, ref readerCount4);
                                }
                                base.ReadEndElement();
                            }
                        }
                    }
                    else if (base.Reader.LocalName == this.id13_Tasks && base.Reader.NamespaceURI == this.id2_Item)
                    {
                        if (!base.ReadNull())
                        {
                            TaskInfoCollection tasks2 = setupComponentInfo.Tasks;
                            if (tasks2 == null || base.Reader.IsEmptyElement)
                            {
                                base.Reader.Skip();
                            }
                            else
                            {
                                base.Reader.ReadStartElement();
                                base.Reader.MoveToContent();
                                int num5         = 0;
                                int readerCount5 = base.ReaderCount;
                                while (base.Reader.NodeType != XmlNodeType.EndElement && base.Reader.NodeType != XmlNodeType.None)
                                {
                                    if (base.Reader.NodeType == XmlNodeType.Element)
                                    {
                                        if (base.Reader.LocalName == this.id14_TaskInfo && base.Reader.NamespaceURI == this.id2_Item)
                                        {
                                            if (tasks2 == null)
                                            {
                                                base.Reader.Skip();
                                            }
                                            else
                                            {
                                                tasks2.Add(this.Read2_TaskInfo(true, true));
                                            }
                                        }
                                        else
                                        {
                                            base.UnknownNode(null, ":TaskInfo");
                                        }
                                    }
                                    else
                                    {
                                        base.UnknownNode(null, ":TaskInfo");
                                    }
                                    base.Reader.MoveToContent();
                                    base.CheckReaderCount(ref num5, ref readerCount5);
                                }
                                base.ReadEndElement();
                            }
                        }
                    }
                    else
                    {
                        base.UnknownNode(setupComponentInfo, ":ServerTasks, :OrgTasks, :ServicePlanOrgTasks, :Tasks");
                    }
                }
                else
                {
                    base.UnknownNode(setupComponentInfo, ":ServerTasks, :OrgTasks, :ServicePlanOrgTasks, :Tasks");
                }
                base.Reader.MoveToContent();
                base.CheckReaderCount(ref num, ref readerCount);
            }
            base.ReadEndElement();
            return(setupComponentInfo);
        }
Exemple #7
0
 private bool IsTaskIncluded(TaskInfo task, SetupComponentInfo parentComponent)
 {
     return(!this.IsDatacenterDedicated || !parentComponent.IsDatacenterDedicatedOnly || !task.ExcludeInDatacenterDedicated);
 }
Exemple #8
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);
        }
        private void Write12_SetupComponentInfo(string n, string ns, SetupComponentInfo o, bool isNullable, bool needType)
        {
            if (o == null)
            {
                if (isNullable)
                {
                    base.WriteNullTagLiteral(n, ns);
                }
                return;
            }
            if (!needType)
            {
                Type type = o.GetType();
                if (!(type == typeof(SetupComponentInfo)))
                {
                    throw base.CreateUnknownTypeException(o);
                }
            }
            base.WriteStartElement(n, ns, o, false, null);
            if (needType)
            {
                base.WriteXsiType("SetupComponentInfo", "");
            }
            base.WriteAttribute("Name", "", o.Name);
            base.WriteAttribute("AlwaysExecute", "", XmlConvert.ToString(o.AlwaysExecute));
            base.WriteAttribute("IsDatacenterOnly", "", XmlConvert.ToString(o.IsDatacenterOnly));
            base.WriteAttribute("IsDatacenterDedicatedOnly", "", XmlConvert.ToString(o.IsDatacenterDedicatedOnly));
            base.WriteAttribute("IsPartnerHostedOnly", "", XmlConvert.ToString(o.IsPartnerHostedOnly));
            if (o.DatacenterMode != DatacenterMode.Common)
            {
                base.WriteAttribute("DatacenterMode", "", this.Write14_DatacenterMode(o.DatacenterMode));
            }
            base.WriteAttribute("DescriptionId", "", o.DescriptionId);
            ServerTaskInfoCollection serverTasks = o.ServerTasks;

            if (serverTasks != null)
            {
                base.WriteStartElement("ServerTasks", "", null, false);
                for (int i = 0; i < ((ICollection)serverTasks).Count; i++)
                {
                    this.Write7_ServerTaskInfo("ServerTaskInfo", "", serverTasks[i], true, false);
                }
                base.WriteEndElement();
            }
            OrgTaskInfoCollection orgTasks = o.OrgTasks;

            if (orgTasks != null)
            {
                base.WriteStartElement("OrgTasks", "", null, false);
                for (int j = 0; j < ((ICollection)orgTasks).Count; j++)
                {
                    this.Write10_OrgTaskInfo("OrgTaskInfo", "", orgTasks[j], true, false);
                }
                base.WriteEndElement();
            }
            ServicePlanTaskInfoCollection servicePlanOrgTasks = o.ServicePlanOrgTasks;

            if (servicePlanOrgTasks != null)
            {
                base.WriteStartElement("ServicePlanOrgTasks", "", null, false);
                for (int k = 0; k < ((ICollection)servicePlanOrgTasks).Count; k++)
                {
                    this.Write11_ServicePlanTaskInfo("ServicePlanTaskInfo", "", servicePlanOrgTasks[k], true, false);
                }
                base.WriteEndElement();
            }
            TaskInfoCollection tasks = o.Tasks;

            if (tasks != null)
            {
                base.WriteStartElement("Tasks", "", null, false);
                for (int l = 0; l < ((ICollection)tasks).Count; l++)
                {
                    this.Write2_TaskInfo("TaskInfo", "", tasks[l], true, false);
                }
                base.WriteEndElement();
            }
            base.WriteEndElement(o);
        }