Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// EnterPage
        /// </summary>
        public override void EnterPage()
        {
            // Ok... now we need to hook the action up to the progress bar
            base.EnterPage();
            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
            {
                this.installationProgressHeader.Text = WpfResources.WPFResourceDictionary.UninstallationProgressText;

                PrepareInstallData.PrepareInstallDataItems();

                SetupFileValidation.ResetInstallItemFileLocations(
                    PropertyBagDictionary.Instance.GetProperty <string>(PropertyBagConstants.LocationOfSetupFiles),
                    PropertyBagDictionary.Instance.GetProperty <string>(PropertyBagConstants.LocationOfSetupFiles));

                // Look for missing files
                if (SetupFileValidation.HaveAllNeededInstallItemFiles())
                {
                    SetupHelpers.LogPropertyBag();
                    // return true;
                }
            }
            else
            {
                this.installationProgressHeader.Text = WpfResources.WPFResourceDictionary.InstallationProgressText;
            }

            this.LayoutInstallItems();

            this.Page.Host.SetNextButtonState(true, false, null);

            this.backgroundWorkerProcessInstalls.RunWorkerAsync();
        }
Exemplo n.º 3
0
        public static bool FindAgreementFile(ref String path, CMP.Setup.AgreementType agreementType)
        {
            bool returnValue = true;

            agreementType = AgreementType.Notice;
            String setupExePath = PropertyBagDictionary.Instance.GetProperty <string>(PropertyBagDictionary.SetupExePath);

            path        = Path.Combine(setupExePath, "Notice.rtf");
            returnValue = SetupFileValidation.ValidateFileExists(path);

            return(returnValue);
        }
Exemplo n.º 4
0
        private void printButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FlowDocument flowDocumentCopy  = new FlowDocument();
                TextRange    copyDocumentRange = new TextRange(flowDocumentCopy.ContentStart, flowDocumentCopy.ContentEnd);
                String       filePath          = String.Empty;
                SetupFileValidation.FindAgreementFile(ref filePath, this.currentAgreementType);
                using (FileStream eulaStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    copyDocumentRange.Load(eulaStream, System.Windows.DataFormats.Rtf);
                    eulaStream.Close();
                }

                // Create a XpsDocumentWriter object, open a Windows common print dialog.
                // This methods returns a ref parameter that represents information about the dimensions of the printer media.
                PrintDocumentImageableArea ia        = null;
                XpsDocumentWriter          docWriter = PrintQueue.CreateXpsDocumentWriter(ref ia);
                if (docWriter != null && ia != null)
                {
                    DocumentPaginator paginator = ((IDocumentPaginatorSource)flowDocumentCopy).DocumentPaginator;

                    // Change the PageSize and PagePadding for the document to match the CanvasSize for the printer device.
                    paginator.PageSize = new Size(ia.MediaSizeWidth, ia.MediaSizeHeight);
                    Thickness pagePadding = flowDocumentCopy.PagePadding;
                    flowDocumentCopy.PagePadding = new Thickness(
                        Math.Max(ia.OriginWidth, pagePadding.Left),
                        Math.Max(ia.OriginHeight, pagePadding.Top),
                        Math.Max(ia.MediaSizeWidth - (ia.OriginWidth + ia.ExtentWidth), pagePadding.Right),
                        Math.Max(ia.MediaSizeHeight - (ia.OriginHeight + ia.ExtentHeight), pagePadding.Bottom));
                    flowDocumentCopy.ColumnWidth = double.PositiveInfinity;

                    // Send DocumentPaginator to the printer.
                    docWriter.Write(paginator);
                }
            }
            catch (Exception ex)
            {
                SetupHelpers.ShowError(ex.Message);
            }
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Checks for existing data base files.
        /// </summary>
        /// <param name="serverName">Name of the server.</param>
        /// <param name="databaseFolder">The database folder.</param>
        /// <returns>true if successful, false otherwise</returns>
        public static bool CheckForExistingDataBaseFiles(string serverName, string databaseFolder)
        {
            Collection <string> existingFilesList = null;
            string conflictingFiles = string.Empty;

            if (!string.IsNullOrEmpty(serverName) &&
                !string.IsNullOrEmpty(databaseFolder))
            {
                existingFilesList = SetupFileValidation.ListOfFilesOnRemoteComputer(serverName, databaseFolder);
            }
            else
            {
                // could not do the check
                return(false);
            }

            if (existingFilesList == null)
            {
                // There was an error.
                return(false);
            }

            if (existingFilesList.Count < 1)
            {
                // Folder was empty... this is ok.
                PropertyBagDictionary.Instance.SafeRemove(PropertyBagConstants.ExistingSqlFilesMessage);
                PropertyBagDictionary.Instance.SafeRemove(PropertyBagConstants.ExistingSqlFiles);
                return(true);
            }
            else
            {
                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Server))
                {
                    String dbName = SetupInputs.Instance.FindItem(SetupInputTags.SqlDatabaseNameTag);
                    if (existingFilesList.Contains(dbName.ToLowerInvariant()))
                    {
                        conflictingFiles = conflictingFiles + dbName + "\r\n";
                    }
                }

                if (string.IsNullOrEmpty(conflictingFiles))
                {
                    PropertyBagDictionary.Instance.SafeRemove(PropertyBagConstants.ExistingSqlFilesMessage);
                    PropertyBagDictionary.Instance.SafeRemove(PropertyBagConstants.ExistingSqlFiles);
                }
                else
                {
                    PropertyBagDictionary.Instance.SafeAdd(
                        PropertyBagConstants.ExistingSqlFiles,
                        conflictingFiles);
                    string message =
                        string.Format(
                            WpfResources.WPFResourceDictionary.ExistingSqlFilesMessage,
                            conflictingFiles,
                            "\r\n");
                    PropertyBagDictionary.Instance.SafeAdd(
                        PropertyBagConstants.ExistingSqlFilesMessage,
                        message);
                }
            }

            // Life was good
            return(true);
        }