private void Write11_ServicePlanTaskInfo(string n, string ns, ServicePlanTaskInfo o, bool isNullable, bool needType) { if (o == null) { if (isNullable) { base.WriteNullTagLiteral(n, ns); } return; } if (!needType) { Type type = o.GetType(); if (!(type == typeof(ServicePlanTaskInfo))) { throw base.CreateUnknownTypeException(o); } } base.WriteStartElement(n, ns, o, false, null); if (needType) { base.WriteXsiType("ServicePlanTaskInfo", ""); } base.WriteAttribute("FeatureName", "", o.FeatureName); this.Write9_OrgTaskInfoBlock("Install", "", o.Install, false, false); this.Write9_OrgTaskInfoBlock("BuildToBuildUpgrade", "", o.BuildToBuildUpgrade, false, false); this.Write9_OrgTaskInfoBlock("Uninstall", "", o.Uninstall, false, false); base.WriteEndElement(o); }
private ServicePlanTaskInfo Read11_ServicePlanTaskInfo(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.id12_ServicePlanTaskInfo || xmlQualifiedName.Namespace != this.id2_Item)) { throw base.CreateUnknownTypeException(xmlQualifiedName); } if (flag) { return(null); } ServicePlanTaskInfo servicePlanTaskInfo = new ServicePlanTaskInfo(); bool[] array = new bool[4]; while (base.Reader.MoveToNextAttribute()) { if (!array[3] && base.Reader.LocalName == this.id26_FeatureName && base.Reader.NamespaceURI == this.id2_Item) { servicePlanTaskInfo.FeatureName = base.Reader.Value; array[3] = true; } else if (!base.IsXmlnsAttribute(base.Reader.Name)) { base.UnknownNode(servicePlanTaskInfo, ":FeatureName"); } } base.Reader.MoveToElement(); if (base.Reader.IsEmptyElement) { base.Reader.Skip(); return(servicePlanTaskInfo); } 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 (!array[0] && base.Reader.LocalName == this.id15_Install && base.Reader.NamespaceURI == this.id2_Item) { servicePlanTaskInfo.Install = this.Read9_OrgTaskInfoBlock(false, true); array[0] = true; } else if (!array[1] && base.Reader.LocalName == this.id16_BuildToBuildUpgrade && base.Reader.NamespaceURI == this.id2_Item) { servicePlanTaskInfo.BuildToBuildUpgrade = this.Read9_OrgTaskInfoBlock(false, true); array[1] = true; } else if (!array[2] && base.Reader.LocalName == this.id18_Uninstall && base.Reader.NamespaceURI == this.id2_Item) { servicePlanTaskInfo.Uninstall = this.Read9_OrgTaskInfoBlock(false, true); array[2] = true; } else { base.UnknownNode(servicePlanTaskInfo, ":Install, :BuildToBuildUpgrade, :Uninstall"); } } else { base.UnknownNode(servicePlanTaskInfo, ":Install, :BuildToBuildUpgrade, :Uninstall"); } base.Reader.MoveToContent(); base.CheckReaderCount(ref num, ref readerCount); } base.ReadEndElement(); return(servicePlanTaskInfo); }
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); }
protected override void FilterComponents() { base.FilterComponents(); if (this.deltaServicePlanSettings != null) { bool recreateCannedRBACRoles = ManageServicePlanMigrationBase.CannedRolesChanged(this.deltaServicePlanSettings); bool rolesToRoleGroupAssignmentsChange = ManageServicePlanMigrationBase.RoleToRoleGroupsAssignmentsChanged(this.deltaServicePlanSettings); bool shareableConfigurationEnabledChange = ManageServicePlanMigrationBase.RBACConfigPresenceChanged(this.deltaServicePlanSettings); bool createNewMailboxPlanObject = (this.conservative || ManageServicePlanMigrationBase.MailboxPlanConfigurationChanged(this.deltaServicePlanSettings)) && !this.IsCrossSKUMigration && !base.InternalPilotEnabled; foreach (SetupComponentInfo setupComponentInfo in base.ComponentInfoList) { setupComponentInfo.Tasks.RemoveAll(delegate(TaskInfo taskInfo) { ServicePlanTaskInfo servicePlanTaskInfo = taskInfo as ServicePlanTaskInfo; if (servicePlanTaskInfo == null) { return(true); } string featureName; switch (featureName = servicePlanTaskInfo.FeatureName) { case "LoadSetupSnapin": case "ServicePlanUpgradeStart": case "PerMBXPlanRoleAssignmentPolicyEnabled": case "PerMBXPlanRetentionPolicyEnabled": case "PerMBXPlanOWAPolicyEnabled": case "MailboxPlans": return(false); case "RecreateCannedRBACRoleGroups": return(!rolesToRoleGroupAssignmentsChange); case "RecreateCannedRBACRoles": return(!recreateCannedRBACRoles && !shareableConfigurationEnabledChange && !rolesToRoleGroupAssignmentsChange); case "RecreateCannedRBACRoleAssignments": return(!rolesToRoleGroupAssignmentsChange && !shareableConfigurationEnabledChange); case "CreateNewMailboxPlanObject": return(!createNewMailboxPlanObject); case "UpdateMailboxes": { bool flag = this.UpgradePhase >= UpgradePhase.UpdateMailboxes; bool flag2 = createNewMailboxPlanObject || this.IsCrossSKUMigration; return(!flag || !flag2 || !this.includeUserUpdatePhase); } case "CleanupOldMailboxPlan": { bool flag = this.UpgradePhase == UpgradePhase.Cleanup; bool flag2 = createNewMailboxPlanObject || this.IsCrossSKUMigration; return(!flag || !flag2); } case "ServicePlanUpgradeEnd": return(this.configOnly); } return(!this.featuresToApply.Contains(servicePlanTaskInfo.FeatureName)); }); } } }