Пример #1
0
        /// <summary>
        /// Validates EULA file exists on the media.
        /// </summary>
        /// <returns>true if successful</returns>
        public static bool ExistEULAFile()
        {
            bool returnValue = true;

            // Print a pretty header for the log...
            SetupLogger.LogInfo(string.Empty);
            SetupLogger.LogInfo("**************************************************");

            // Make the entry in the property bad if it is not there
            if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.MissingFilesList))
            {
                StringBuilder missingFiles = new StringBuilder();
                PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.MissingFilesList, missingFiles);
            }

            // Print a pretty footer for the log.
            SetupLogger.LogInfo("**************************************************");

            if (!returnValue)
            {
                StringBuilder missingFiles = PropertyBagDictionary.Instance.GetProperty <StringBuilder>(PropertyBagConstants.MissingFilesList);
                SetupLogger.LogInfo(string.Format(CultureInfo.CurrentCulture, WpfResources.WPFResourceDictionary.MissingFileFormatString, missingFiles.ToString()));
                SetupHelpers.ShowError(string.Format(CultureInfo.CurrentCulture, WpfResources.WPFResourceDictionary.MissingFileFormatString, missingFiles.ToString()));
            }
            else
            {
                SetupLogger.LogInfo("All vital setup files found.");
            }

            // Cleanup the property bag
            PropertyBagDictionary.Instance.Remove(PropertyBagConstants.MissingFilesList);
            return(returnValue);
        }
Пример #2
0
        /// <summary>
        /// Validates the file exists.
        /// </summary>
        /// <param name="fileToLookFor">The file to look for.</param>
        /// <returns>true if the file is found, false otherwise.</returns>
        public static bool ValidateFileExists(string fileToLookFor)
        {
            bool returnValue = false;

            SetupLogger.LogInfo("Looking for file: {0}.", fileToLookFor);
            if (!File.Exists(fileToLookFor))
            {
                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.MissingFilesList))
                {
                    // We are making a list to show the user.
                    StringBuilder missingFiles = PropertyBagDictionary.Instance.GetProperty <StringBuilder>(PropertyBagConstants.MissingFilesList);
                    missingFiles.AppendLine(fileToLookFor); // Name of the missing file
                    missingFiles.AppendLine(string.Empty);  // Extra space to make the dialog more readable
                    PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.MissingFilesList, missingFiles);
                }

                returnValue = false;
                SetupLogger.LogInfo("Missing {0}.", fileToLookFor);
            }
            else
            {
                SetupLogger.LogInfo("Found {0}.", fileToLookFor);
                returnValue = true;
            }

            return(returnValue);
        }
Пример #3
0
        /// <summary>
        /// Prepares the install data items.
        /// </summary>
        public static void PrepareInstallDataItems()
        {
            ArrayList itemsToInstall = new ArrayList();

            foreach (KeyValuePair <string, InstallItemsInstallDataItem> valuePair in InstallDataItemRegistry.Instance.InstallDataItems)
            {
                //If there is a property in the property bag that matches the name of this InstallDataItem
                //then we should add it to the list to install.
                if (PropertyBagDictionary.Instance.PropertyExists(valuePair.Key))
                {
                    itemsToInstall.Add(valuePair.Value);
                }
                else
                {
                    SetupLogger.LogInfo("No match for {0} found.", valuePair.Key);
                }
            }

            // if this is an uninstall, we should reverse the order of everything except the postinstall guy... that must stay in the same place.
            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
            {
                itemsToInstall.Reverse(0, itemsToInstall.Count - 1);
            }

            PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.ItemsToInstall, itemsToInstall);

            SetupLogger.LogInfo("PrepareInstallDataItems: Install Item list:");
            SetupLogger.LogInfo("***************************");
            foreach (InstallItemsInstallDataItem dataItem in itemsToInstall)
            {
                SetupLogger.LogInfo(dataItem.DisplayTitle);
            }
            SetupLogger.LogInfo("***************************");
        }
Пример #4
0
        /// <summary>
        /// Iterates through the given path and returns the existing valid parent folder
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static String GetExistingAncestor(String path)
        {
            AppAssert.AssertNotNull(path, "path");

            // Check if the path exists
            if (Directory.Exists(path))
            {
                SetupLogger.LogInfo("InstallLocationPage.SetPathInBrowserDialog : The path {0} exists, returning", path);
                return(path);
            }

            String ancestor = null;
            int    index    = path.LastIndexOf(Path.DirectorySeparatorChar);

            while (index >= 0)
            {
                ancestor = path.Substring(0, index);
                SetupLogger.LogInfo("InstallLocationPage.SetPathInBrowserDialog : Check if the ancestor {0} exists", ancestor);
                if (Directory.Exists(ancestor))
                {
                    SetupLogger.LogInfo("InstallLocationPage.SetPathInBrowserDialog : The ancestor {0} exists, returning", ancestor);
                    return(ancestor + Path.DirectorySeparatorChar);
                }

                index = ancestor.LastIndexOf(Path.DirectorySeparatorChar);
            }
            return(null);
        }
Пример #5
0
        /// <summary>
        /// Launch Setup in Silent Mode
        /// </summary>
        /// <returns>a SetupReturnValues reflecting success or possible failure causes</returns>
        private static SetupReturnValues SilentRun()
        {
            // Setup the data for the items to install
            PrepareInstallData.PrepareInstallDataItems();

            // Check to see that we have all the install files we need.
            // Make sure the file locations are set for the install files.
            SetupFileValidation.ResetInstallItemFileLocations(
                PropertyBagDictionary.Instance.GetProperty <string>(PropertyBagConstants.LocationOfSetupFiles),
                PropertyBagDictionary.Instance.GetProperty <string>(PropertyBagConstants.LocationOfSetupFiles));

            if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
            {
                if (!SetupFileValidation.HaveAllNeededInstallItemFiles())
                {
                    return(SetupReturnValues.InvalidInstallImage);
                }

                SetupHelpers.SetFeatureSwitches();
                // If we are not uninstalling, Do the prereq check
                if (2 == SetupHelpers.DoAllPrerequisiteChecks())
                {
                    // We failed prereq tests so we will fail the install
                    SetupLogger.LogError("We failed the prerequisite checks.");
                    return(SetupReturnValues.FailedPrerequisiteChecks);
                }

                // If this is a server installation,
                // - check if there is an existing database,
                // and if so, check if upgrade is supported from that version
                // - make sure client is also installed with server.
                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Server))
                {
                    // Error conditions
                    // An unsupported database found
                    // A supported database is found, but user didnt explicitly specify upgrade

                    // CheckDatabase will throw an exception if DB version is
                    // incompatible
                    string sqlMachineName = (String)SetupInputs.Instance.FindItem(SetupInputTags.SqlMachineNameTag);

                    String fullInstanceName = SetupDatabaseHelper.ConstructFullInstanceName(
                        !SetupDatabaseHelper.SqlServerIsOnLocalComputer(sqlMachineName),
                        sqlMachineName,
                        (String)SetupInputs.Instance.FindItem(SetupInputTags.SqlInstanceNameTag),
                        (int)SetupInputs.Instance.FindItem(SetupInputTags.SqlServerPortTag));
                }
            }

            // Do the install using the passed information
            InstallActionProcessor installs = new InstallActionProcessor();

            SetupLogger.LogInfo("Silent ProcessInstalls Starting");

            SetupReturnValues rturn = installs.ProcessInstalls();

            SetupLogger.LogInfo("Silent ProcessInstalls Done");

            return(rturn);
        }
Пример #6
0
        /// <summary>
        /// Loads and initializes all UI pages.
        /// </summary>
        /// <returns>the newly created IPageHost interface object</returns>
        private static IPageHost LoadUiPages()
        {
            // Creates a page factory, a host page and set up page navigation
            Factory   factory = new WpfFactory();
            IPageHost host    = factory.CreateHost();

            PageNavigation.Instance.Host = host;

            // Add wait screen here if needed.
            XmlSerializer serializer = new XmlSerializer(typeof(Pages));

            using (MemoryStream stream = new MemoryStream())
            {
                using (StreamWriter writer = new StreamWriter(stream))
                {
                    writer.Write(Properties.Resources.Pages);
                    writer.Flush();
                    stream.Position = 0;
                    Pages inputPages = (Pages)serializer.Deserialize(stream);

                    foreach (PagesPage page in inputPages.Page)
                    {
                        SetupLogger.LogInfo("Adding Page {0}", page.Id);
                        Page workingPage = new Page(factory, host, page);

                        // Add this page to our pages
                        PageRegistry.Instance.RegisterPage(workingPage);
                    }
                }
            }

            PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.ScreensLoaded, "1");
            return(host);
        }
Пример #7
0
        /// <summary>
        /// Forwards to page based on property value handler.
        /// Ok so this fuction takes a string that looks like this
        /// [nameofproperty],[screenfor0],[screeenfor1],[screenfor2],...,[screenforN]
        /// it parses and looks for the property in the property bag.
        /// if it finds it, it returns the screen from the input that matches the value
        /// of the property bag entry.
        /// </summary>
        /// <param name="currentPage">The current page.</param>
        /// <returns>Page to move to</returns>
        public static Page ForwardToPageBasedOnPropertyValueHandler(Page currentPage)
        {
            string nextPageChoices = currentPage.NextPageArgument;
            int    pageToMoveTo    = 0;

            string[] pageChoices = nextPageChoices.Split(new char[] { ',' });

            // Check to see if the length is correct
            if (pageChoices.Length < 2)
            {
                SetupLogger.LogError("ForwardToPageBasedOnPropertyValueHandler: Invalid XML description for Page");
                throw new ArgumentException(currentPage.ToString());
            }

            if (!PropertyBagDictionary.Instance.PropertyExists(pageChoices[0]))
            {
                // Page not specified
                SetupLogger.LogError("ForwardToPageBasedOnPropertyValueHandler: Missing property bag entry for {0}.  This entry is vital to select the next page.", pageChoices[0]);
                throw new ArgumentException(currentPage.ToString());
            }
            else
            {
                pageToMoveTo = 1 + PropertyBagDictionary.Instance.GetProperty <int>(pageChoices[0]);
                SetupLogger.LogInfo("ForwardToPageBasedOnPropertyValueHandler: Property bag entry for {0} is {1}.  This means that we will move to a next page id {2}.", pageChoices[0], pageToMoveTo.ToString(), pageChoices[pageToMoveTo]);
            }

            // We will go to the page specifed in the pageChoice
            return(PageRegistry.Instance.GetPage(pageChoices[pageToMoveTo]));
        }
Пример #8
0
        /// <summary>
        /// Moves backward from RemoveWAPDatabasePage page.
        /// It can go to:
        /// 0 - AddRemoveComponentsPage
        /// 1 - RemoveDatabasePage, if we are on the uninstall path and we are uninstalling server
        /// </summary>
        /// <param name="currentPage">The current page.</param>
        /// <returns>Page to move to</returns>
        public static Page BackwardFromRemoveWAPDatabasePageHandler(Page currentPage)
        {
            string nextPageChoices = currentPage.PreviousPageArgument;

            string[] pageChoices = nextPageChoices.Split(new char[] { ',' });

            // Check to see if the length is correct
            if (pageChoices.Length != 2)
            {
                SetupLogger.LogError("ForwardFromAddRemoveComponentsPageHandler: Invalid XML description for Page");
                SetupLogger.LogError("XML Was {0}:", nextPageChoices);
                SetupLogger.LogError("XML should have been like: FirstPage,SecondPage");
                throw new ArgumentException(currentPage.ToString());
            }
            String AddRemoveComponentsPage = pageChoices[0];
            String RemoveDatabasePage      = pageChoices[1];

            // default to go to the ReadyToInstallPage
            Page pageToReturn = PageRegistry.Instance.GetPage(AddRemoveComponentsPage);

            // Check if we are on the uninstall path
            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall) &&
                PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Server))
            {
                SetupLogger.LogInfo("ForwardFromAddRemoveComponentsPageHandler: Move to Remove WAP Database Page");
                pageToReturn = PageRegistry.Instance.GetPage(RemoveDatabasePage);
            }

            return(pageToReturn);
        }
Пример #9
0
        /// <summary>
        /// Resets the install item file locations.
        /// </summary>
        /// <param name="oldLocation">The old location.</param>
        /// <param name="newLocation">The new location.</param>
        public static void ResetInstallItemFileLocations(string oldLocation, string newLocation)
        {
            SetupLogger.LogInfo("*****ResetInstallItemFileLocations********************************************");
            foreach (InstallItemsInstallDataItem itemToInstall in PropertyBagDictionary.Instance.GetProperty <ArrayList>(PropertyBagConstants.ItemsToInstall))
            {
                if (!string.IsNullOrEmpty(itemToInstall.FullPathToLaunch))
                {
                    // if the old path is set, replace... otherwise, add
                    if (itemToInstall.FullPathToLaunch.Contains(oldLocation))
                    {
                        if (oldLocation.EndsWith(Path.DirectorySeparatorChar.ToString()) &&
                            !newLocation.EndsWith(Path.DirectorySeparatorChar.ToString()))
                        {
                            // We need to add a \ to the new location
                            newLocation = newLocation + Path.DirectorySeparatorChar;
                        }

                        itemToInstall.FullPathToLaunch = itemToInstall.FullPathToLaunch.Replace(oldLocation, newLocation);
                    }
                    else
                    {
                        // get rid of the parent ".." symble in path
                        String path = newLocation;
                        if (newLocation.EndsWith(Path.DirectorySeparatorChar.ToString()))
                        {
                            path = newLocation.Substring(0, newLocation.LastIndexOf(Path.DirectorySeparatorChar));
                        }
                        while (itemToInstall.FullPathToLaunch.IndexOf("..") == 0)
                        {
                            itemToInstall.FullPathToLaunch = itemToInstall.FullPathToLaunch.Substring(3);
                            path = path.Substring(0, path.LastIndexOf(Path.DirectorySeparatorChar));
                        }

                        itemToInstall.FullPathToLaunch = Path.Combine(path, itemToInstall.FullPathToLaunch);
                    }

                    // get locale
                    if (itemToInstall.FullPathToLaunch.Contains(SetupConstants.UnknownLCID))
                    {
                        String fileFullPath = itemToInstall.FullPathToLaunch.Replace(SetupConstants.UnknownLCID, CultureInfo.CurrentUICulture.LCID.ToString());
                        if (File.Exists(fileFullPath))
                        {
                            itemToInstall.FullPathToLaunch = fileFullPath;
                        }
                        else
                        {
                            // the locale file does not exist, use the English one as default
                            itemToInstall.FullPathToLaunch = itemToInstall.FullPathToLaunch.Replace(SetupConstants.UnknownLCID, SetupConstants.BaseLanguageID);
                        }
                    }

                    SetupLogger.LogInfo("Item:        {0}", itemToInstall.DisplayTitle);
                    SetupLogger.LogInfo("path set to: {0}", itemToInstall.FullPathToLaunch);
                    SetupLogger.LogInfo("------------------------------------------------------------------------------");
                }
            }

            SetupLogger.LogInfo("******************************************************************************");
        }
Пример #10
0
        /// <summary>
        /// Moves back from ReadyToInstall page.
        /// </summary>
        /// <param name="currentPage">The current page.</param>
        /// <returns>Page to move to</returns>
        public static Page BackwardFromReadyToInstallPage(Page currentPage)
        {
            string previousPageChoices = currentPage.PreviousPageArgument;

            string[] pageChoices = previousPageChoices.Split(new char[] { ',' });

            String AccountConfigurationPage   = pageChoices[0];
            String ARPAddRemoveComponentsPage = pageChoices[1];
            String ARPRemoveDatabasePage      = pageChoices[2];
            String ARPRemoveWAPDatabasePage   = pageChoices[3];
            String EulaPage = pageChoices[4];

            // Set default next page to PortConfigurationPage
            Page pageToReturn = PageRegistry.Instance.GetPage(AccountConfigurationPage);

            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
            {
                // If we are at the uninstall path
                // then we need to check whether we are uninstalling a standalone server
                // or the last node of HA VMM server
                // if that's the case, then we need to move back to Retain DB option page
                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Server))
                {
                    SetupLogger.LogInfo("BackwardFromReadyToInstallPage: Move to Remove Database Page");
                    pageToReturn = PageRegistry.Instance.GetPage(ARPRemoveDatabasePage);
                }
                else
                {
                    SetupLogger.LogInfo("BackwardFromReadyToInstallPage: Move to Add/Remove Components Page");
                    pageToReturn = PageRegistry.Instance.GetPage(ARPAddRemoveComponentsPage);
                }

                // Override the server database options when the extension is getting removed
                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.ExtensionCommon))
                {
                    SetupLogger.LogInfo("BackwardFromReadyToInstallPage: Move to Remove WAP Database Page");
                    pageToReturn = PageRegistry.Instance.GetPage(ARPRemoveWAPDatabasePage);
                }
            }
            else
            {
                if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Server))
                {
                    if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.ExtensionCommon))
                    {
                        pageToReturn = PageRegistry.Instance.GetPage(AccountConfigurationPage);
                    }
                    else
                    {
                        // No customization if the installation doesn't involve the WAP common components
                        pageToReturn = PageRegistry.Instance.GetPage(EulaPage);
                    }
                }
            }

            return(pageToReturn);
        }
Пример #11
0
        public static bool AdminWAPExtensionPostIstallProcessor()
        {
            SetupLogger.LogInfo("WAPExtensionPostIstallProcessor: Entered.");
            bool returnValue = true;

            // TODO: Run post-installation required tasks

            return(returnValue);
        }
Пример #12
0
        /// <summary>
        /// Forward from switch page to start page handler.
        /// 0 - ARPStartPageSwitch (Add/Remove)
        /// 1 - InitialInstallStartPageSwitch (Initial install)
        /// 2 - ConfigInitialInstallStartPageSwitch (VHD Configuration - Setup/Config scenario)
        /// 3 - UpgradeStartPageSwitch (Upgrade)
        /// </summary>
        /// <param name="currentPage">The current page.</param>
        /// <returns>Page to move to</returns>
        public static Page ForwardFromSwitchPageHandler(Page currentPage)
        {
            string nextPageChoices = currentPage.NextPageArgument;

            string[] pageChoices = nextPageChoices.Split(new char[] { ',' });

            // default to the upgrade page.
            Page pageToReturn = PageRegistry.Instance.GetPage(pageChoices[0]);

            SetupLogger.LogInfo("ForwardFromSwitchPageHandler: Moving to page {0}", pageToReturn.Id);
            return(pageToReturn);
        }
Пример #13
0
        /// <summary>
        /// Logs all inputs to the log file
        /// </summary>
        public void LogInputs()
        {
            InputParameter inputParameter = null;

            foreach (String parameter in parameterList)
            {
                inputParameter = this.FindItem(parameter);
                if (inputParameter.Valid && inputParameter.CanLogToFile)
                {
                    SetupLogger.LogInfo(parameter);
                    SetupLogger.LogInfo(inputParameter.InputValue.ToString());
                }
            }
        }
        private void PopulateDatabaseNameItemsWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.comboBoxExistingDatabaseName.Text = String.Empty;
            this.comboBoxExistingDatabaseName.Items.Clear();

            // First, handle the case where an exception was thrown.
            if (e.Error != null)
            {
                SetupLogger.LogError("Database population failed");
                SetupHelpers.ShowError(e.Error.Message);
            }
            else if (e.Cancelled)
            {
                SetupLogger.LogInfo("Database population has been cancelled.");
            }
            else
            {
                // Handle the case where the operation succeeded.
                String[] databaseNames = e.Result as String[];
                if (databaseNames != null && databaseNames.Length > 0)
                {
                    foreach (String databaseName in databaseNames)
                    {
                        this.comboBoxExistingDatabaseName.Items.Add(databaseName);
                    }

                    // First satisfy the below scenario:
                    // - User clicked on existing db radio button and selected a db
                    // - then clicked new db radio button
                    // - and then clicked existing radio db again w/o changin server, instance, or port info
                    // Basically, check if the selected instance already exists in the list
                    // if yes, then choose it
                    // otherwise, this is a new population, select the first item
                    if (this.comboBoxExistingDatabaseName.Items.Contains(selectedDatabase))
                    {
                        this.comboBoxExistingDatabaseName.Text = selectedDatabase;
                        this.radioExistingDatabase.IsChecked   = true;
                    }
                    else
                    {
                        this.selectedDatabase = databaseNames[0];
                        this.comboBoxExistingDatabaseName.Text = this.selectedDatabase;
                        this.radioNewDatabase.IsChecked        = true;
                    }
                }
            }

            this.EnableInputMode();
        }
Пример #15
0
        /// <summary>
        /// Parses the command line.
        /// In case of errors, shows the error dialog and then rethrows the exception.
        /// </summary>
        /// <param name="arguments"></param>
        public void ParseCommandline(String[] arguments)
        {
            int index = 1, iterator = 0;

            try
            {
                // Parse command line arguments
                while (index < arguments.Length)
                {
                    SetupLogger.LogInfo("Main : Parse argument {0}", arguments[index]);

                    if (IsArgument(arguments[index]))
                    {
                        for (iterator = 0; iterator < CommandlineParameterTable.Length; iterator++)
                        {
                            SetupLogger.LogInfo("Main : Calling parse function for {0}", CommandlineParameterTable[iterator].ParameterId);

                            if (CommandlineParameterTable[iterator].ParseArgumentDelegate(CommandlineParameterTable[iterator], arguments, ref index))
                            {
                                SetupLogger.LogInfo("Main : The argument was parsed, move to next one.");
                                break;
                            }
                        }
                        if (iterator >= CommandlineParameterTable.Length)
                        {
                            throw new Exception(String.Format("The parameter {0} is not valid", arguments[index]));
                        }
                    }
                    else
                    {
                        throw new Exception(String.Format("The parameter {0} is not valid", arguments[index]));
                    }
                }
            }
            catch (Exception backEndErrorException)
            {
                SetupLogger.LogInfo("SpawnSetup : {0}", backEndErrorException.ToString());

                if ((bool)this.GetParameterValue(CommandlineParameterId.QuietMode) == false)
                {
                    SetupHelpers.ShowError(backEndErrorException.Message);
                }
                else
                {
                    SetupLogger.LogError("Quite mode error: {0}", backEndErrorException.Message);
                }
                throw;
            }
        }
Пример #16
0
        /// <summary>
        /// Handles the request navigate.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void HandleRequestNavigate(object sender, RoutedEventArgs e)
        {
            string navigateUri = ((Hyperlink)sender).NavigateUri.ToString();

            try
            {
                navigateUri = SetupHelpers.GetLatestNavigationUri(navigateUri);

                Uri              newNavigateUri = new Uri(navigateUri);
                string           filePath       = newNavigateUri.AbsolutePath;
                string           fileExtension  = Path.GetExtension(filePath);
                ProcessStartInfo startInfo      = null;

                if (SetupHelpers.IsSupportedFileExtension(fileExtension))
                {
                    startInfo = new ProcessStartInfo(navigateUri);
                }
                else
                {
                    startInfo           = new ProcessStartInfo();
                    startInfo.FileName  = Environment.SystemDirectory + Path.DirectorySeparatorChar + "notepad.exe";
                    startInfo.Arguments = filePath;
                }

                Process.Start(startInfo);
            }
            catch (UriFormatException exception)
            {
                SetupLogger.LogInfo("Unable to launch {0}.  Exception {1}", navigateUri, exception.Message);
            }
            catch (InvalidOperationException exception)
            {
                SetupLogger.LogInfo("Unable to launch {0}.  Exception {1}", navigateUri, exception.Message);
            }
            catch (ArgumentException exception)
            {
                SetupLogger.LogInfo("Unable to launch {0}.  Exception {1}", navigateUri, exception.Message);
            }
            catch (Win32Exception exception)
            {
                SetupLogger.LogInfo("Unable to launch {0}.  Exception {1}", navigateUri, exception.Message);
            }

            e.Handled = true;
        }
Пример #17
0
        /// <summary>
        /// Backwards from Eula page.
        /// It can go to:
        /// 0 - Components page
        /// 1 - Upgrade Components Page, if we are in upgrade path
        /// 2 - ARPAddRemoveComponentsPage, if we are in add/remove
        /// 3 - RegistrationPage, if server feature is selected.
        /// </summary>
        /// <param name="currentPage">The current page.</param>
        /// <returns>Page to move to</returns>
        public static Page BackwardFromEulaPageHandler(Page currentPage)
        {
            string previousPageChoices = currentPage.PreviousPageArgument;

            string[] pageChoices = previousPageChoices.Split(new char[] { ',' });

            // default to the Components Page
            Page pageToReturn = PageRegistry.Instance.GetPage(pageChoices[0]);

            // If we are in the add/remove path
            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.AddRemoveMode))
            {
                SetupLogger.LogInfo("BackwardFromEulaPageHandler: Move back to addremove components page");
                pageToReturn = PageRegistry.Instance.GetPage(pageChoices[1]);
            }

            return(pageToReturn);
        }
Пример #18
0
        private static bool ParseSetupLocationArgument(CommandlineArgument commandlineArgument, String[] arguments, ref int index)
        {
            if (ConsumeArgument(commandlineArgument, arguments[index], "SetupLocation"))
            {
                if (FetchValue(commandlineArgument, arguments, index))
                {
                    index++;
                    commandlineArgument.Parameter = ValidateDirectoryPath((String)commandlineArgument.Parameter);

                    arguments[index] = (String)commandlineArgument.Parameter;

                    SetupLogger.LogInfo("file path {0}", commandlineArgument.Parameter);
                    index++;
                    return(true);
                }
            }
            return(false);
        }
Пример #19
0
        /// <summary>
        /// Enters the page
        /// </summary>
        public override void EnterPage()
        {
            SetupLogger.LogInfo("Enter Account configuration page.");

            base.EnterPage();

            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.VMMSupportedVersionInstalled))
            {
                string serviceAccount = SetupConstants.VmmServiceAccount;
                if (String.Equals(serviceAccount, SetupConstants.LocalSystem, StringComparison.OrdinalIgnoreCase))
                {
                    this.radioLocalSystemAccount.IsChecked = true;
                }
                else
                {
                    this.radioDomainAccount.IsChecked = true;
                    this.textBoxUserName.Text         = serviceAccount;

                    // If VMM service was already running under domain account
                    // don't let it be changed. We need the password though
                    this.radioLocalSystemAccount.IsEnabled = false;
                    this.textBoxUserName.IsEnabled         = false;
                }
            }
            else
            {
                //if (!this.radioLocalSystemAccount.IsChecked.GetValueOrDefault(false))
                //{
                //    this.radioDomainAccount.IsChecked = true;
                //}
                this.radioLocalSystemAccount.IsChecked = true;
            }

            if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Server))
            {
                this.serviceAccountGrid.Height = 0;
            }
            else
            {
                this.serviceAccountGrid.Height = Double.NaN;
            }

            this.SetNextButtonState();
        }
Пример #20
0
        /// <summary>
        /// Enters the page.
        /// </summary>
        public virtual void EnterPage()
        {
            SetupLogger.LogInfo(String.Format("Enter {0}", this.ToString()));
            //CMP.Setup.SetupLogger.LogInfo(String.Format("Enter {0}", this.ToString()));

            // Need to get to the host page so we can access it's public functions
            IPageHost host = this.page.Host;

            // Set the previous page button to false if there is no previous button
            host.SetPreviousButtonState(true, this.page.PreviousPageArgument != null);
            // Set the next page button to "Finish" if there is no next page
            host.SetNextButtonState(true, true,
                                    this.page.NextPageArgument == null ?
                                    WPFResourceDictionary.FinishButtonText :
                                    // Set to 'Next' when there are other pages to move to.
                                    WPFResourceDictionary.NextButtonText);
            // Reset the cancel button to enabled
            host.SetCancelButtonState(true, true);
        }
Пример #21
0
        /// <summary>
        /// OnProcessInstallRunWorkerCompleted
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">RunWorkerCompletedEventArgs</param>
        private void OnProcessInstallRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (this.Dispatcher.Thread == Thread.CurrentThread)
            {
                if (e.Error != null)
                {
                    SetupLogger.LogInfo("OnProcessInstallRunWorkerCompleted()", e.Error);
                }

                PageNavigation.Instance.MoveToNextPage();
            }
            else
            {
                this.Dispatcher.BeginInvoke(
                    DispatcherPriority.Normal,
                    new SendOrPostCallback(delegate { this.OnProcessInstallRunWorkerCompleted(sender, e); }),
                    null);
            }
        }
Пример #22
0
        private static ParseArgumentDelegate CreateCredentialArgumentParser(CommandlineParameterId id)
        {
            return(delegate(CommandlineArgument commandlineArgument, String[] arguments, ref int index)
            {
                string parmeterName = Enum.GetName(typeof(CommandlineParameterId), id);
                if (ConsumeArgument(commandlineArgument, arguments[index], parmeterName))
                {
                    if (FetchValue(commandlineArgument, arguments, index))
                    {
                        index++;
                        arguments[index] = (String)commandlineArgument.Parameter;

                        SetupLogger.LogInfo("{0} received", parmeterName);
                        index++;
                        return true;
                    }
                }
                return false;
            });
        }
Пример #23
0
        private static bool ParseOptionsArgument(CommandlineArgument commandlineArgument, String[] arguments, ref int index)
        {
            const string optionsParameter = @"options";

            if (ConsumeArgument(commandlineArgument, arguments[index], optionsParameter))
            {
                if (FetchValue(commandlineArgument, arguments, index))
                {
                    index++;
                    commandlineArgument.Parameter = ValidateFilePath((String)commandlineArgument.Parameter);

                    arguments[index] = (String)commandlineArgument.Parameter;

                    SetupLogger.LogInfo("MST file path {0}", commandlineArgument.Parameter);
                    index++;
                    return(true);
                }
            }

            return(false);
        }
Пример #24
0
        public static bool WAPExtensionCommonPostIstallProcessor()
        {
            SetupLogger.LogInfo("WAPExtensionPostIstallProcessor: Entered.");
            bool returnValue = true;

            try
            {
                if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
                {
                    String currentSetupUser = String.Format(SetupConstants.UserAccountTemplate, Environment.UserDomainName, Environment.UserName);
                    SetupInputs.Instance.EditItem(SetupInputTags.SetupUserAccountTag, currentSetupUser);

                    SetupDatabaseHelper.CheckDatabase(
                        InstallItemCustomDelegates.GetSQLServerInstanceNameStr(true),
                        SetupInputs.Instance.FindItem(SetupInputTags.WapSqlDatabaseNameTag),
                        true);

                    SetupDatabaseHelper.CreateDB(true);

                    if (SetupInputs.Instance.FindItem(SetupInputTags.WapRemoteDatabaseImpersonationTag))
                    {
                        SetupDatabaseHelper.GrantSetupUserDBAccess(true, true);
                        SetupInputs.Instance.EditItem(SetupInputTags.WapRemoteDatabaseImpersonationTag, false);
                        PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.WapAfterGrantSetupUserDBAccess, true);
                    }

                    SetupDatabaseHelper.DeployWAPDacpac();
                }
            }
            catch (ArgumentException exception)
            {
                if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.FailureReason))
                {
                    PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.FailureReason, exception);
                }
                returnValue = false;
            }

            return(returnValue);
        }
Пример #25
0
        public UInt64 GetFreeDiskSpace(String folderPath)
        {
            if (folderPath == null)
            {
                throw new ArgumentNullException("folderPath");
            }
            SetupLogger.LogInfo("GetFreeDiskSpace");

            SetupLogger.LogData("Folder Path: ", folderPath);
            UInt64 freeBytes      = 0;
            UInt64 totalBytes     = 0;
            UInt64 totalfreeBytes = 0;

            String validFolderPath = PathHelper.GetExistingAncestor(folderPath);

            InstallLocationValidation.GetDiskFreeSpace(validFolderPath, ref freeBytes, ref totalBytes, ref totalfreeBytes);

            // Convert the bytes in Megabytes
            freeBytes = freeBytes / (UInt64)Math.Pow(2, 20);

            SetupLogger.LogData("FreeSpace: ", freeBytes.ToString());
            return(freeBytes);
        }
Пример #26
0
        /// <summary>
        /// Handles the request navigate.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void HandleRequestNavigate(object sender, RoutedEventArgs e)
        {
            string navigateUri = ((Hyperlink)sender).NavigateUri.ToString();

            try
            {
                Process.Start(new ProcessStartInfo(navigateUri));
            }
            catch (InvalidOperationException exception)
            {
                SetupLogger.LogInfo("Unable to launch {0}.  Exception {1}", navigateUri, exception.Message);
            }
            catch (ArgumentNullException exception)
            {
                SetupLogger.LogInfo("Unable to launch {0}.  Exception {1}", navigateUri, exception.Message);
            }
            catch (Win32Exception exception)
            {
                SetupLogger.LogInfo("Unable to launch {0}.  Exception {1}", navigateUri, exception.Message);
            }

            e.Handled = true;
        }
Пример #27
0
        public static int Main()
        {
            SetupReturnValues returnValue = SetupReturnValues.Failed;

            // This is needed to load the WPF stuff so
            // that we can get at the resources.
            Application apptry = Application.Current;

            Application.Equals(apptry, null);

            SetDefaultPropertyValues();

            SetupLogger.Initialize(PropertyBagDictionary.Instance.GetProperty <string>(PropertyBagConstants.DefaultLogName));
            SetupLogger.LogInfo("Application Started");
            bool  createdNew;
            Mutex mSetupwizard = new Mutex(true, @"Global\Phoenix Setup", out createdNew);

            if (!createdNew)
            {
                SetupLogger.LogInfo("There is already another setup wizard running on this computer.");
                SetupLogger.LogInfo("Please wait until that program is finished.");
                returnValue = SetupReturnValues.AnotherSetupRunningOnThisMachine;
                MessageBox.Show(WPFResourceDictionary.AnotherSetupRunningOnThisMachineMessage, WPFResourceDictionary.SetupMessageBoxTitle, MessageBoxButton.OK);
                goto AllDone;
            }

            try
            {
                // Set CurrentDirectory
                Environment.CurrentDirectory = PropertyBagDictionary.Instance.GetProperty <string>(PropertyBagDictionary.SetupExePath);

                try
                {
                    SetupLogger.Initialize(SetupHelpers.SetLogFilePath("SetupWizardAdditional.log"), LogLevel.Verbose, true);
                }
                catch (Exception exception)
                {
                    // Since the exception is thrown before the logger is initialized,
                    // just display the message in a message box
                    MessageBox.Show(exception.Message, WPFResourceDictionary.SetupMessageBoxTitle, MessageBoxButton.OK);
                    goto AllDone;
                }

                if (!ParseCommandLine())
                {
                    // Could not parse the command line
                    returnValue = SetupReturnValues.InvalidCommandLine;
                    goto AllDone;
                }

                // Get the state of the components on; this machine
                SystemStateDetection.CheckInstalledComponents();

                // If not silent, show splash screen here
                if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagDictionary.Silent))
                {
                    Program.splashPage = new SplashPage();
                    Program.splashPage.Show();
                }
                else
                {
                    // Silent setup
                    // Check command line against the existing components
                    if (!CheckCommandLine())
                    {
                        returnValue = SetupReturnValues.InvalidCommandLine;
                        goto AllDone;
                    }
                }

                // If we don't have a location for the setup files, assume current location.
                if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.LocationOfSetupFiles))
                {
                    PropertyBagDictionary.Instance.SafeAdd(
                        PropertyBagConstants.LocationOfSetupFiles,
                        PropertyBagDictionary.Instance.GetProperty <string>(PropertyBagDictionary.SetupExePath));
                }

                // Check to see if the path is valid for our install
                if (!SetupValidationHelpers.IsValidPathForInstall(SetupInputs.Instance.FindItem(SetupInputTags.BinaryInstallLocationTag)))
                {
                    SetupLogger.LogInfo("Invalid path passed to the setup. {0}", SetupInputs.Instance.FindItem(SetupInputTags.BinaryInstallLocationTag));
                    returnValue = SetupReturnValues.InvalidCommandLine;
                    if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagDictionary.Silent))
                    {
                        goto AllDone;
                    }
                }

                // What we have selected is valid given the machine state, etc...
                if (!SetupHelpers.RationalizeComponents())
                {
                    SetupLogger.LogInfo("We could not rationalize the component choices.  We must fail.");
                    returnValue = SetupReturnValues.InvalidCommandLine;

                    goto AllDone;
                }

                // Need to load the install data items
                XmlSerializer dataItemSerializer = new XmlSerializer(typeof(InstallItems));
                using (MemoryStream stream = new MemoryStream())
                {
                    StreamWriter writer = new StreamWriter(stream);
                    writer.Write(Properties.Resources.InstallItems);
                    writer.Flush();
                    stream.Position = 0;
                    InstallItems inputInstallItems = (InstallItems)dataItemSerializer.Deserialize(stream);
                    SetupLogger.LogInfo("Start adding DataItems");
                    foreach (InstallItemsInstallDataItem installDataItem in inputInstallItems.InstallDataItem)
                    {
                        SetupLogger.LogInfo(installDataItem.DisplayTitle);

                        // localize the display title
                        installDataItem.DisplayTitle = InstallItemDisplayTitleEnumHelper.GetName((InstallItem)Enum.Parse(typeof(InstallItem), installDataItem.DisplayTitle));
                        // Add this Item to our data items
                        InstallDataItemRegistry.Instance.RegisterDataItem(installDataItem);
                    }
                    SetupLogger.LogInfo("Done adding DataItems");
                }

                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagDictionary.Silent))
                {
                    returnValue = Program.SilentRun();
                }
                else
                {
                    Program.UiRun();
                    // Set the application return value: Always success in UI mode
                    returnValue = SetupReturnValues.Successful;
                }
            }
            catch (Exception exception)
            {
                SetupLogger.LogInfo("Uncaught Exception", exception);
            }
            finally
            {
            }


            // All done with the install.
AllDone:
            // Reboot if we have to
            RebootIfNeeded();

            //release the setup wizard mutex
            mSetupwizard.ReleaseMutex();

            return((int)returnValue);
        }
Пример #28
0
        /// <summary>
        /// Validates the file exists on server.
        /// </summary>
        /// <param name="remoteComputer">The remote computer.</param>
        /// <param name="pathToCheck">The path to check.</param>
        /// <returns>
        /// true if there are files in the folder, false otherwise
        /// </returns>
        public static Collection <string> ListOfFilesOnRemoteComputer(string remoteComputer, string pathToCheck)
        {
            Collection <string> filesInFolder = null;

            if (string.IsNullOrEmpty(remoteComputer) || string.IsNullOrEmpty(pathToCheck))
            {
                SetupLogger.LogInfo("ValidateFileExistsOnServer: Either the computer name or the path to check was null.  We will return -1;");
                return(null);
            }

            try
            {
                pathToCheck = pathToCheck.Replace("\\", "\\\\");
                string remoteFolder = "ASSOCIATORS OF " +
                                      "{Win32_Directory=\"" + pathToCheck.TrimEnd(Path.DirectorySeparatorChar) + "\"} " +
                                      "WHERE AssocClass=CIM_DirectoryContainsFile " +
                                      "ResultClass=CIM_DataFile " +
                                      "ResultRole=PartComponent " +
                                      "Role=GroupComponent";

                ManagementObjectSearcher query = new ManagementObjectSearcher(remoteFolder);

                // Connect to the computer
                ConnectionOptions co = new ConnectionOptions();
                co.Impersonation = ImpersonationLevel.Impersonate;
                co.Timeout       = new TimeSpan(0, 0, 30);

                ManagementScope ms = new ManagementScope(
                    "\\\\" + remoteComputer + "\\root\\cimv2",
                    co);

                query.Scope = ms;
                ManagementObjectCollection queryCollection = query.Get();

                filesInFolder = new Collection <string>();

                foreach (ManagementObject mo in queryCollection)
                {
                    string fileExtension = (mo["Extension"].ToString());
                    if (fileExtension.Equals("mdf", StringComparison.OrdinalIgnoreCase) ||
                        fileExtension.Equals("ldf", StringComparison.OrdinalIgnoreCase))
                    {
                        filesInFolder.Add(mo["FileName"].ToString().ToLowerInvariant());
                    }
                }
            }
            catch (ArgumentException e)
            {
                SetupLogger.LogException(e);
            }
            catch (COMException e)
            {
                SetupLogger.LogException(e);
            }
            catch (UnauthorizedAccessException e)
            {
                SetupLogger.LogException(e);
            }
            catch (ManagementException e)
            {
                SetupLogger.LogException(e);
            }

            return(filesInFolder);
        }
Пример #29
0
        /// <summary>
        /// Checks to see if we have all needed install item files.
        /// </summary>
        /// <returns>true if they are all there, if not false (and asks for new path if not silent)</returns>
        public static bool HaveAllNeededInstallItemFiles()
        {
            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
            {
                // we are doing an uninstall so we don't need anything from the CD
                return(true);
            }
            else
            {
                bool haveAllNeededFiles = true;

                foreach (InstallItemsInstallDataItem itemToInstall in PropertyBagDictionary.Instance.GetProperty <ArrayList>(PropertyBagConstants.ItemsToInstall))
                {
                    if (!string.IsNullOrEmpty(itemToInstall.FullPathToLaunch))
                    {
                        haveAllNeededFiles = haveAllNeededFiles & SetupFileValidation.ValidateFileExists(itemToInstall.FullPathToLaunch);
                    }
                }

                if (haveAllNeededFiles)
                {
                    return(true);
                }

                // When we get here in the logic, we must return false...
                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagDictionary.Silent))
                {
                    // We don't have all the files and we are silent.... we must fail.
                    SetupLogger.LogError(
                        "HaveAllNeededInstallItemFiles:  We are missing some of the install files needed by the installitems.  Please check the path {0} to make sure it pointing to the root of our files.",
                        PropertyBagDictionary.Instance.GetProperty <string>(PropertyBagConstants.LocationOfSetupFiles));
                }
                else
                {
                    // Open a browser on at my MyComputer and save the browsed location to the propertybag
                    string diskLocation = string.Empty;
                    SetupHelpers.BrowseFromLocation(
                        Environment.GetFolderPath(Environment.SpecialFolder.MyComputer),
                        WpfResources.WPFResourceDictionary.PromptForSetupFiles,
                        out diskLocation);

                    if (string.IsNullOrEmpty(diskLocation) == false)
                    {
                        diskLocation = Path.Combine(diskLocation, SetupConstants.SetupFolder);
                        if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.ArchitectureIs64Check))
                        {
                            diskLocation = Path.Combine(diskLocation, "amd64");
                        }
                        else
                        {
                            diskLocation = Path.Combine(diskLocation, "i386");
                        }

                        if (Directory.Exists(diskLocation))
                        {
                            ResetInstallItemFileLocations(
                                PropertyBagDictionary.Instance.GetProperty <string>(PropertyBagConstants.LocationOfSetupFiles),
                                diskLocation);
                            PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.LocationOfSetupFiles, diskLocation);
                        }
                        else
                        {
                            SetupLogger.LogInfo("Path {0} does not exist.", diskLocation);
                        }
                    }
                }
            }

            // We did not have all the files we needed.
            return(false);
        }
Пример #30
0
 /// <summary>
 /// Exits the page.
 /// The default implementation writes the property bag.
 /// </summary>
 public virtual void ExitPage()
 {
     WritePropertyBag(PropertyBagDictionary.Instance);
     SetupLogger.LogInfo(String.Format("Exit {0}", this.ToString()));
 }