private void PopulateDatabaseNameItemsWorker(object sender, DoWorkEventArgs e) { BackgroundWorker backgroundWorker = sender as BackgroundWorker; if (backgroundWorker == null) { return; } String[] databaseArray = null; try { if (!String.IsNullOrEmpty(this.serverName)) { using (ImpersonationHelper impersonationHelper = new ImpersonationHelper()) { databaseArray = SetupDatabaseHelper.GetSqlDBNames( !SetupDatabaseHelper.SqlServerIsOnLocalComputer(this.serverName), this.serverName, IsDefaultInstance(this.selectedInstance) ? String.Empty : this.selectedInstance, this.port, true); } } } catch (Exception) { } finally { e.Result = databaseArray; } }
/// <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); }
private void comboBoxExistingDatabaseName_DropDownOpened(object sender, EventArgs e) { this.DisableInputMode(); this.resetServerName(); this.resetInstanceName(); String[] databaseArray = null; try { if (!String.IsNullOrEmpty(this.serverName)) { using (ImpersonationHelper impersonationHelper = new ImpersonationHelper()) { databaseArray = SetupDatabaseHelper.GetSqlDBNames( !SetupDatabaseHelper.SqlServerIsOnLocalComputer(this.serverName), this.serverName, IsDefaultInstance(this.selectedInstance) ? String.Empty : this.selectedInstance, this.port, true); } } } catch (Exception) { } finally { this.EnableInputMode(); this.comboBoxExistingDatabaseName.Text = String.Empty; this.comboBoxExistingDatabaseName.Items.Clear(); if (databaseArray != null && databaseArray.Length > 0) { foreach (String databaseName in databaseArray) { 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(this.selectedDatabase)) { this.comboBoxExistingDatabaseName.Text = selectedDatabase; } else { this.selectedDatabase = databaseArray[0]; this.comboBoxExistingDatabaseName.Text = this.selectedDatabase; } } } }
/// <summary> /// Validates the inputs on this page /// </summary> /// <returns></returns> public override bool ValidatePage() { bool isPageValid = true; try { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; SetupInputs.Instance.EditItem(SetupInputTags.WapSqlMachineNameTag, this.textBoxServer.Text); SetupInputs.Instance.EditItem(SetupInputTags.WapSqlInstanceNameTag, IsDefaultInstance(this.comboBoxInstance.Text) ? String.Empty : this.comboBoxInstance.Text); this.port = String.IsNullOrEmpty(this.textBoxPort.Text) ? InputDefaults.WapSqlServerPort : Convert.ToInt32(this.textBoxPort.Text); SetupInputs.Instance.EditItem(SetupInputTags.WapSqlServerPortTag, this.port); bool isNewDB = this.radioNewDatabase.IsChecked.GetValueOrDefault(false); SetupInputs.Instance.EditItem(SetupInputTags.WapCreateNewSqlDatabaseTag, isNewDB); if (isNewDB) { SetupInputs.Instance.EditItem(SetupInputTags.WapSqlDatabaseNameTag, this.textBoxNewDatabaseName.Text); } else { SetupInputs.Instance.EditItem(SetupInputTags.WapSqlDatabaseNameTag, this.comboBoxExistingDatabaseName.Text); } if (this.checkBoxNewUserId.IsChecked.GetValueOrDefault(false)) { String userName = SetupInputs.Instance.FindItem(SetupInputTags.WapSqlDBAdminNameTag); String domainName = SetupInputs.Instance.FindItem(SetupInputTags.WapSqlDBAdminDomainTag); if (!UserAccountHelper.ValidateCredentials(userName, domainName, this.passwordBoxPassword.SecurePassword)) { throw new Exception("Either the domain account or the password you entered are not valid."); } } String fullInstanceName = SetupDatabaseHelper.ConstructFullInstanceName( !SetupDatabaseHelper.SqlServerIsOnLocalComputer(this.serverName), (String)SetupInputs.Instance.FindItem(SetupInputTags.WapSqlMachineNameTag), (String)SetupInputs.Instance.FindItem(SetupInputTags.WapSqlInstanceNameTag), (int)SetupInputs.Instance.FindItem(SetupInputTags.WapSqlServerPortTag)); SetupDatabaseHelper.CheckDatabase( fullInstanceName, (String)SetupInputs.Instance.FindItem(SetupInputTags.WapSqlDatabaseNameTag), true); } catch (SqlException) { Exception exception = new Exception("Setup cannot connect to the specified SQL Server instance."); SetupLogger.LogException(exception); SetupHelpers.ShowError(exception.Message); isPageValid = false; } catch (Exception exception) { SetupLogger.LogException(exception); SetupHelpers.ShowError(exception.Message); isPageValid = false; } finally { Mouse.OverrideCursor = null; } return(isPageValid); }