Exemplo n.º 1
0
        /// <summary>
        /// Validates the inputs on this page
        /// </summary>
        /// <returns></returns>
        public override bool ValidatePage()
        {
            bool isPageValid = true;

            try
            {
                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.");
                    }
                }
            }
            catch (Exception backEndErrorException)
            {
                SetupLogger.LogException(backEndErrorException);
                SetupHelpers.ShowError(backEndErrorException.Message);

                isPageValid = false;
            }
            return(isPageValid);
        }
 private void passwordBox_LostFocus(object sender, RoutedEventArgs e)
 {
     try
     {
         if (this.checkBoxNewUserId.IsChecked.GetValueOrDefault(false) &&
             !string.IsNullOrEmpty(this.textBoxUserName.Text.Trim()))
         {
             String userName   = SetupInputs.Instance.FindItem(SetupInputTags.SqlDBAdminNameTag);
             String domainName = SetupInputs.Instance.FindItem(SetupInputTags.SqlDBAdminDomainTag);
             if (!UserAccountHelper.ValidateCredentials(userName, domainName, this.passwordBoxPassword.SecurePassword))
             {
                 throw new Exception("Either the domain account or the password you entered are not valid");
             }
         }
     }
     catch (Exception backEndErrorException)
     {
         SetupLogger.LogException(backEndErrorException);
         SetupHelpers.ShowError(backEndErrorException.Message);
     }
 }
        /// <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);
        }