Example #1
0
        internal TTaskInfoBlock GetBlock <TTaskInfoBlock>(InstallationModes mode) where TTaskInfoBlock : TaskInfoBlock, new()
        {
            TaskInfoBlock taskInfoBlock = null;

            this.blocks.TryGetValue(mode, out taskInfoBlock);
            switch (mode)
            {
            case InstallationModes.Install:
            case InstallationModes.Uninstall:
                if (taskInfoBlock == null)
                {
                    taskInfoBlock     = Activator.CreateInstance <TTaskInfoBlock>();
                    this.blocks[mode] = taskInfoBlock;
                }
                break;

            case InstallationModes.BuildToBuildUpgrade:
            case InstallationModes.DisasterRecovery:
                if (taskInfoBlock == null)
                {
                    taskInfoBlock     = Activator.CreateInstance <TTaskInfoBlock>();
                    this.blocks[mode] = taskInfoBlock;
                }
                else if (taskInfoBlock.UseInstallTasks)
                {
                    taskInfoBlock = this.GetBlock <TTaskInfoBlock>(InstallationModes.Install);
                }
                break;
            }
            return((TTaskInfoBlock)((object)taskInfoBlock));
        }
Example #2
0
        public string GetTask(InstallationModes mode, InstallationCircumstances circumstance)
        {
            TaskInfoBlock taskInfoBlock = null;

            if (this.blocks.TryGetValue(mode, out taskInfoBlock) && (mode == InstallationModes.BuildToBuildUpgrade || mode == InstallationModes.DisasterRecovery) && taskInfoBlock.UseInstallTasks)
            {
                this.blocks.TryGetValue(InstallationModes.Install, out taskInfoBlock);
            }
            if (taskInfoBlock != null)
            {
                return(taskInfoBlock.GetTask(circumstance));
            }
            return(string.Empty);
        }
Example #3
0
        public bool IsFatal(InstallationModes mode)
        {
            bool          flag          = true;
            TaskInfoBlock taskInfoBlock = null;

            if (this.blocks.TryGetValue(mode, out taskInfoBlock))
            {
                flag = taskInfoBlock.IsFatal;
                if ((mode == InstallationModes.BuildToBuildUpgrade || mode == InstallationModes.DisasterRecovery) && taskInfoBlock.UseInstallTasks && flag && this.blocks.TryGetValue(InstallationModes.Install, out taskInfoBlock))
                {
                    flag = taskInfoBlock.IsFatal;
                }
            }
            return(flag);
        }
Example #4
0
        public int GetWeight(InstallationModes mode)
        {
            int           num           = 1;
            TaskInfoBlock taskInfoBlock = null;

            if (this.blocks.TryGetValue(mode, out taskInfoBlock))
            {
                num = taskInfoBlock.Weight;
                if ((mode == InstallationModes.BuildToBuildUpgrade || mode == InstallationModes.DisasterRecovery) && taskInfoBlock.UseInstallTasks && num == 1 && this.blocks.TryGetValue(InstallationModes.Install, out taskInfoBlock))
                {
                    num = taskInfoBlock.Weight;
                }
            }
            return(num);
        }
Example #5
0
        public string GetDescription(InstallationModes mode)
        {
            string        text          = string.Empty;
            TaskInfoBlock taskInfoBlock = null;

            if (this.blocks.TryGetValue(mode, out taskInfoBlock))
            {
                text = taskInfoBlock.DescriptionId;
                if ((mode == InstallationModes.BuildToBuildUpgrade || mode == InstallationModes.DisasterRecovery) && taskInfoBlock.UseInstallTasks && string.IsNullOrEmpty(text) && this.blocks.TryGetValue(InstallationModes.Install, out taskInfoBlock))
                {
                    text = taskInfoBlock.DescriptionId;
                }
            }
            return(text ?? string.Empty);
        }
Example #6
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);
                }
            }
        }
Example #7
0
        protected override void CheckInstallationMode()
        {
            InstallationModes installationModes = (InstallationModes)base.Fields["InstallationMode"];

            if (installationModes == InstallationModes.Install && this.role.IsInstalled)
            {
                base.Fields["InstallationMode"] = InstallationModes.BuildToBuildUpgrade;
                TaskLogger.Trace("Updating mode to \"{0}\" because this role is installed", new object[]
                {
                    base.Fields["InstallationMode"]
                });
            }
            if ((installationModes == InstallationModes.Install || installationModes == InstallationModes.BuildToBuildUpgrade) && this.role.IsMissingPostSetup)
            {
                base.Fields["InstallationMode"] = InstallationModes.PostSetupOnly;
                TaskLogger.Trace("Updating mode to \"{0}\" because this role is missing post setup", new object[]
                {
                    base.Fields["InstallationMode"]
                });
            }
        }
 public ConfigurationStatus(string role, InstallationModes action)
 {
     this.Role      = role;
     this.Action    = action;
     this.Watermark = null;
 }
Example #9
0
        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);
        }
Example #10
0
        private int CountStepsToBeExecuted(SetupComponentInfoCollection componentList, InstallationModes installationMode, InstallationCircumstances installationCircumstance)
        {
            int num  = 0;
            int num2 = 0;

            foreach (SetupComponentInfo setupComponentInfo in componentList)
            {
                foreach (TaskInfo taskInfo in setupComponentInfo.Tasks)
                {
                    if (!string.IsNullOrEmpty(taskInfo.GetTask(installationMode, installationCircumstance)) && this.IsTaskIncluded(taskInfo, setupComponentInfo))
                    {
                        num2++;
                        num += taskInfo.GetWeight(installationMode);
                    }
                }
            }
            base.WriteVerbose(Strings.FoundTasksToExecute(num2));
            return(num);
        }
Example #11
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();
                }
            }
        }
Example #12
0
 internal void SetBlock(InstallationModes mode, TaskInfoBlock infoBlock)
 {
     this.blocks[mode] = infoBlock;
 }