public static bool SimplePreinstallProcessor(String controlTitle, bool wipeCmdArg) { bool returnValue = true; try { // Find the current installdata item in the array InstallItemsInstallDataItem simpleInstallItem = null; foreach (InstallItemsInstallDataItem itemToInstall in PropertyBagDictionary.Instance.GetProperty <ArrayList>(PropertyBagConstants.ItemsToInstall)) { if (string.Equals(itemToInstall.ControlTitle, controlTitle, StringComparison.OrdinalIgnoreCase)) { simpleInstallItem = itemToInstall; break; } } if (simpleInstallItem == null) { // Item not found - throw an exception SetupLogger.LogError(String.Format("SimplePreinstallProcessor:{0} Install Data item not found.", controlTitle)); throw new ArgumentException(String.Format("{0} Item To Install not found", controlTitle)); } else { PropertyBagDictionary.Instance.SafeAdd("CurrentWorkingInstallItem", simpleInstallItem); } // Set the Install/Uninstall state if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall)) { simpleInstallItem.ItemWeAreInstallingEnumValue = simpleInstallItem.ItemWeAreInstallingEnumValue | InstallItemsInstallDataItem.InstallDataInputs.Installing; } else { simpleInstallItem.ItemWeAreInstallingEnumValue = simpleInstallItem.ItemWeAreInstallingEnumValue | InstallItemsInstallDataItem.InstallDataInputs.Uninstalling; } // Set the location of the log file simpleInstallItem.LogFile = SetupHelpers.SetLogFilePath(simpleInstallItem.LogFile); // If this is an uninstall then wipe the current commandline arguments. if (wipeCmdArg && PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall)) { simpleInstallItem.Arguments = "REMOVE=ALL"; } } catch (ArgumentException exception) { if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.FailureReason)) { PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.FailureReason, exception); } returnValue = false; } return(returnValue); }
public static bool AdminWAPExtensionPreinstallProcessor() { bool returnValue = true; // used to store the return value for this function try { InstallItemsInstallDataItem adminWapExtensionInstallItem = null; // Find the Client installdata item in the array foreach (InstallItemsInstallDataItem itemToInstall in PropertyBagDictionary.Instance.GetProperty <ArrayList>(PropertyBagConstants.ItemsToInstall)) { if (string.Equals(itemToInstall.ControlTitle, PropertyBagConstants.AdminWAPExtension, StringComparison.OrdinalIgnoreCase)) { adminWapExtensionInstallItem = itemToInstall; break; } } if (adminWapExtensionInstallItem == null) { // Item not found - throw an exception SetupLogger.LogError("PageCustomDelegates: AdminWAPExtensionPreinstallProcessor: Install Data item not found."); throw new ArgumentException(WpfResources.WPFResourceDictionary.InvalidArgument); } // Set the Install/Uninstall state adminWapExtensionInstallItem.ItemWeAreInstallingEnumValue = adminWapExtensionInstallItem.ItemWeAreInstallingEnumValue | (PropertyBagDictionary.Instance.PropertyExists("uninstall") ? InstallItemsInstallDataItem.InstallDataInputs.Uninstalling : InstallItemsInstallDataItem.InstallDataInputs.Installing); // If this is not an uninstall, remove the product code. if (0 == (adminWapExtensionInstallItem.ItemWeAreInstallingEnumValue & InstallItemsInstallDataItem.InstallDataInputs.Uninstalling)) { adminWapExtensionInstallItem.ProductCode = string.Empty; } // Set the location of the log file adminWapExtensionInstallItem.LogFile = SetupHelpers.SetLogFilePath(adminWapExtensionInstallItem.LogFile); SetupHelpers.CreateEventSources(); // Adjust the command line arguments adminWapExtensionInstallItem.Arguments += ConfigureBasicCommandLineArguments() + ConfigureAdminWAPCommandlineArguments(); } catch (ArgumentException exception) { if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.FailureReason)) { PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.FailureReason, exception); } returnValue = false; } // Do any other tasks that are needed. return(returnValue); }
/// <summary> /// Addes a Install data item to the install data item register /// </summary> /// <param name="pageToRegister">Page to add to the register</param> public void RegisterDataItem(InstallItemsInstallDataItem installDataItemToRegister) { this.installDataItems.Add(installDataItemToRegister.ControlTitle, installDataItemToRegister); if (installDataItemToRegister.InstallTypeEnumValue == InstallItemsInstallDataItem.InstallDataInputs.CustomAction) { InstallDataItemDelegateRegistry.Instance.RegisterCustomAction( installDataItemToRegister.ControlTitle, GetDelegate( installDataItemToRegister.CustomAction.DelegateId, installDataItemToRegister.CustomAction.Value)); } if (!String.IsNullOrEmpty(installDataItemToRegister.PreProcessing.Value)) { InstallDataItemDelegateRegistry.Instance.RegisterPreprocessDelegate( installDataItemToRegister.ControlTitle, GetDelegate( installDataItemToRegister.PreProcessing.DelegateId, installDataItemToRegister.PreProcessing.Value)); } if (!String.IsNullOrEmpty(installDataItemToRegister.PostProcessing.Value)) { InstallDataItemDelegateRegistry.Instance.RegisterPostProcessDelegate( installDataItemToRegister.ControlTitle, GetDelegate( installDataItemToRegister.PostProcessing.DelegateId, installDataItemToRegister.PostProcessing.Value)); } if (!String.IsNullOrEmpty(installDataItemToRegister.Prereq.Value)) { InstallDataItemDelegateRegistry.Instance.RegisterPrerequisiteDelegate( installDataItemToRegister.ControlTitle, GetDelegate( installDataItemToRegister.Prereq.DelegateId, installDataItemToRegister.Prereq.Value)); } }
public static bool CMPServerPreinstallProcessor() { bool returnValue = true; try { InstallItemsInstallDataItem virtualMachineManagerInstallItem = null; // Find the installdata item in the array foreach (InstallItemsInstallDataItem itemToInstall in PropertyBagDictionary.Instance.GetProperty <ArrayList>(PropertyBagConstants.ItemsToInstall)) { if (string.Equals(itemToInstall.ControlTitle, PropertyBagConstants.CMPServer, StringComparison.OrdinalIgnoreCase)) { virtualMachineManagerInstallItem = itemToInstall; break; } } if (virtualMachineManagerInstallItem == null) { // Item not found - throw an exception SetupLogger.LogError("PageCustomDelegates: VMMPreinstallProcessor: Install Data item not found."); throw new ArgumentException(WpfResources.WPFResourceDictionary.InvalidArgument); } // Set the Install/Uninstall state virtualMachineManagerInstallItem.ItemWeAreInstallingEnumValue = virtualMachineManagerInstallItem.ItemWeAreInstallingEnumValue | (PropertyBagDictionary.Instance.PropertyExists("uninstall") ? InstallItemsInstallDataItem.InstallDataInputs.Uninstalling : InstallItemsInstallDataItem.InstallDataInputs.Installing); // If this is not an uninstall, remove the product code. if (0 == (virtualMachineManagerInstallItem.ItemWeAreInstallingEnumValue & InstallItemsInstallDataItem.InstallDataInputs.Uninstalling)) { virtualMachineManagerInstallItem.ProductCode = string.Empty; } // Set the location of the log file virtualMachineManagerInstallItem.LogFile = SetupHelpers.SetLogFilePath(virtualMachineManagerInstallItem.LogFile); SetupHelpers.CreateEventSources(); // Adjust the command line arguments virtualMachineManagerInstallItem.Arguments += InstallItemCustomDelegates.ConfigureBasicCommandLineArguments() + InstallItemCustomDelegates.ConfigureServerCommandLineArguments(); bool isRollback = PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.RollbacksToProcess); if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall)) { String currentSetupUser = String.Format(SetupConstants.UserAccountTemplate, Environment.UserDomainName, Environment.UserName); SetupInputs.Instance.EditItem(SetupInputTags.SetupUserAccountTag, currentSetupUser); if (SetupInputs.Instance.FindItem(SetupInputTags.RemoteDatabaseImpersonationTag)) { SetupDatabaseHelper.GrantSetupUserDBAccess(false, false); SetupInputs.Instance.EditItem(SetupInputTags.RemoteDatabaseImpersonationTag, false); PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.AfterGrantSetupUserDBAccess, true); } ServiceConfigurationHandler.RemoveService(SetupConstants.EngineServiceName); // Stopping the service sometimes does not end the processes and this keeps a lock on the process binaries InstallItemCustomDelegates.EndCmpWorkerServiceProcess(); bool retainDB = SetupInputs.Instance.FindItem(SetupInputTags.RetainSqlDatabaseTag) || !SetupInputs.Instance.FindItem(SetupInputTags.CreateNewSqlDatabaseTag); if (!retainDB) { SetupDatabaseHelper.RemoveDB(false); } } } catch (ArgumentException exception) { if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.FailureReason)) { PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.FailureReason, exception); } SetupLogger.LogException(exception); returnValue = false; } return(returnValue); }
public static bool WAPExtensionCommonPreinstallProcessor() { bool returnValue = true; // used to store the return value for this function try { InstallItemsInstallDataItem wapExtensionCommonInstallItem = null; // Find the installdata item in the array foreach (InstallItemsInstallDataItem itemToInstall in PropertyBagDictionary.Instance.GetProperty <ArrayList>(PropertyBagConstants.ItemsToInstall)) { if (string.Equals(itemToInstall.ControlTitle, PropertyBagConstants.WAPExtensionCommon, StringComparison.OrdinalIgnoreCase)) { wapExtensionCommonInstallItem = itemToInstall; break; } } if (wapExtensionCommonInstallItem == null) { // Item not found - throw an exception SetupLogger.LogError("PageCustomDelegates: WAPExtensionCommonPreinstallProcessor: Install Data item not found."); throw new ArgumentException(WpfResources.WPFResourceDictionary.InvalidArgument); } // Set the Install/Uninstall state wapExtensionCommonInstallItem.ItemWeAreInstallingEnumValue = wapExtensionCommonInstallItem.ItemWeAreInstallingEnumValue | (PropertyBagDictionary.Instance.PropertyExists("uninstall") ? InstallItemsInstallDataItem.InstallDataInputs.Uninstalling : InstallItemsInstallDataItem.InstallDataInputs.Installing); // If this is not an uninstall, remove the product code. if (0 == (wapExtensionCommonInstallItem.ItemWeAreInstallingEnumValue & InstallItemsInstallDataItem.InstallDataInputs.Uninstalling)) { wapExtensionCommonInstallItem.ProductCode = string.Empty; } // Set the location of the log file wapExtensionCommonInstallItem.LogFile = SetupHelpers.SetLogFilePath(wapExtensionCommonInstallItem.LogFile); // Adjust the command line arguments wapExtensionCommonInstallItem.Arguments += ConfigureBasicCommandLineArguments() + ConfigureWAPExtensionCommonCommandLineArguments(); if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall)) { if (SetupInputs.Instance.FindItem(SetupInputTags.WapRemoteDatabaseImpersonationTag)) { SetupDatabaseHelper.GrantSetupUserDBAccess(false, false); SetupInputs.Instance.EditItem(SetupInputTags.WapRemoteDatabaseImpersonationTag, false); PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.WapAfterGrantSetupUserDBAccess, true); } bool retainDB = SetupInputs.Instance.FindItem(SetupInputTags.WapRetainSqlDatabaseTag) || (!SetupInputs.Instance.FindItem(SetupInputTags.WapCreateNewSqlDatabaseTag) && PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.RollbacksToProcess)); if (!retainDB) { SetupDatabaseHelper.RemoveDB(true); } } } catch (ArgumentException exception) { if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.FailureReason)) { PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.FailureReason, exception); } returnValue = false; } // Do any other tasks that are needed. return(returnValue); }