示例#1
0
        /// <summary>
        /// The wizard_ next button click.
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="System.Web.UI.WebControls.WizardNavigationEventArgs"/> instance containing the event data.
        /// </param>
        protected void Wizard_NextButtonClick([NotNull] object sender, [NotNull] WizardNavigationEventArgs e)
        {
            e.Cancel = true;

            switch (this.CurrentWizardStepID)
            {
            case "WizValidatePermission":
                e.Cancel = false;
                break;

            case "WizDatabaseConnection":

                // save the database settings...
                UpdateDBFailureType type = this.UpdateDatabaseConnection();
                e.Cancel = false;

                switch (type)
                {
                case UpdateDBFailureType.None:
                    this.CurrentWizardStepID = "WizTestSettings";
                    break;

                case UpdateDBFailureType.AppSettingsWrite:
                    this.NoWriteAppSettingsHolder.Visible = true;
                    break;

                case UpdateDBFailureType.ConnectionStringWrite:
                    this.NoWriteDBSettingsHolder.Visible = true;
                    this.lblDBConnStringName.Text        = Config.ConnectionStringName;
                    this.lblDBConnStringValue.Text       = this.CurrentConnString;
                    break;
                }

                break;

            case "WizManualDatabaseConnection":
                e.Cancel = false;
                break;

            case "WizCreatePassword":
                if (this.txtCreatePassword1.Text.Trim() == string.Empty)
                {
                    this.ShowErrorMessage("Please enter a configuration password.");
                    break;
                }

                if (this.txtCreatePassword2.Text != this.txtCreatePassword1.Text)
                {
                    this.ShowErrorMessage("Verification is not the same as your password.");
                    break;
                }

                e.Cancel = false;

                this.CurrentWizardStepID =
                    this._config.WriteAppSetting(_AppPasswordKey, this.txtCreatePassword1.Text)
                            ? "WizDatabaseConnection"
                            : "WizManuallySetPassword";

                break;

            case "WizManuallySetPassword":
                if (this.IsConfigPasswordSet)
                {
                    e.Cancel = false;
                }
                else
                {
                    this.ShowErrorMessage(
                        "You must update your appSettings with the YAF.ConfigPassword Key to continue. NOTE: The key name is case sensitive.");
                }

                break;

            case "WizTestSettings":
                e.Cancel = false;
                break;

            case "WizEnterPassword":
                if (this._config.GetConfigValueAsString(_AppPasswordKey)
                    == FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtEnteredPassword.Text, "md5") ||
                    this._config.GetConfigValueAsString(_AppPasswordKey) == this.txtEnteredPassword.Text.Trim())
                {
                    e.Cancel = false;

                    // move to upgrade..
                    this.CurrentWizardStepID = this.IsForumInstalled ? "WizWelcomeUpgrade" : "WizDatabaseConnection";

                    var dbVersionName = LegacyDb.GetDBVersionName();
                    var dbVersion     = LegacyDb.GetDBVersion();

                    this.CurrentVersionName.Text = dbVersion < 0
                                                           ? "New"
                                                           : "{0} ({1})".FormatWith(dbVersionName, dbVersion);
                    this.UpgradeVersionName.Text = "{0} ({1})".FormatWith(YafForumInfo.AppVersionName, YafForumInfo.AppVersion);
                }
                else
                {
                    this.ShowErrorMessage("You entered the <strong>wrong password</strong>!");
                }

                break;

            case "WizCreateForum":
                if (this.CreateForum())
                {
                    e.Cancel = false;
                }

                break;

            case "WizInitDatabase":
                if (this.InstallUpgradeService.UpgradeDatabase(
                        this.FullTextSupport.Checked,
                        this.UpgradeExtensions.Checked))
                {
                    e.Cancel = false;
                }

                var messages = this.InstallUpgradeService.Messages;

                if (messages.Any())
                {
                    this._loadMessage += messages.ToDelimitedString("\r\n");
                }

                this.ShowErrorMessage(this._loadMessage);

                break;

            case "WizMigrateUsers":

                // migrate users/roles only if user does not want to skip
                if (!this.skipMigration.Checked)
                {
                    RoleMembershipHelper.SyncRoles(this.PageBoardID);

                    // start the background migration task...
                    this.Get <ITaskModuleManager>().Start <MigrateUsersTask>(this.PageBoardID);
                }

                e.Cancel = false;
                break;

            case "WizWelcomeUpgrade":

                e.Cancel = false;

                // move to upgrade..
                this.CurrentWizardStepID = "WizInitDatabase";
                break;

            case "WizWelcome":

                e.Cancel = false;

                // move to upgrade..
                this.CurrentWizardStepID = "WizValidatePermission";
                break;

            case "WizFinished":
                break;

            default:
                throw new ApplicationException(
                          "Installation Wizard step not handled: {0}".FormatWith(
                              this.InstallWizard.WizardSteps[e.CurrentStepIndex].ID));
            }
        }
示例#2
0
        /// <summary>
        /// The wizard_ next button click.
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="System.Web.UI.WebControls.WizardNavigationEventArgs"/> instance containing the event data.
        /// </param>
        protected void Wizard_NextButtonClick([NotNull] object sender, [NotNull] WizardNavigationEventArgs e)
        {
            e.Cancel = true;

            switch (this.CurrentWizardStepID)
            {
            case "WizValidatePermission":
                e.Cancel = false;
                break;

            case "WizDatabaseConnection":

                // save the database settings...
                UpdateDBFailureType type = this.UpdateDatabaseConnection();
                e.Cancel = false;

                switch (type)
                {
                case UpdateDBFailureType.None:
                    this.CurrentWizardStepID = "WizTestSettings";
                    break;

                case UpdateDBFailureType.AppSettingsWrite:
                    this.NoWriteAppSettingsHolder.Visible = true;
                    break;

                case UpdateDBFailureType.ConnectionStringWrite:
                    this.NoWriteDBSettingsHolder.Visible = true;
                    this.lblDBConnStringName.Text        = Config.ConnectionStringName;
                    this.lblDBConnStringValue.Text       = this.CurrentConnString;
                    break;
                }

                break;

            case "WizManualDatabaseConnection":
                e.Cancel = false;
                break;

            case "WizCreatePassword":
                if (this.txtCreatePassword1.Text.Trim() == string.Empty)
                {
                    this.AddLoadMessage("Please enter a configuration password.");
                    break;
                }

                if (this.txtCreatePassword2.Text != this.txtCreatePassword1.Text)
                {
                    this.AddLoadMessage("Verification is not the same as your password.");
                    break;
                }

                e.Cancel = false;

                if (this._config.TrustLevel >= AspNetHostingPermissionLevel.High &&
                    this._config.WriteAppSetting(_AppPasswordKey, this.txtCreatePassword1.Text))
                {
                    // advance to the testing section since the password is now set...
                    this.CurrentWizardStepID = "WizDatabaseConnection";
                }
                else
                {
                    this.CurrentWizardStepID = "WizManuallySetPassword";
                }

                break;

            case "WizManuallySetPassword":
                if (this.IsInstalled)
                {
                    e.Cancel = false;
                }
                else
                {
                    this.AddLoadMessage(
                        "You must update your appSettings with the YAF.ConfigPassword Key to continue. NOTE: The key name is case sensitive.");
                }

                break;

            case "WizTestSettings":
                e.Cancel = false;
                break;

            case "WizEnterPassword":
                if (this._config.GetConfigValueAsString(_AppPasswordKey)
                    == FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtEnteredPassword.Text, "md5") ||
                    this._config.GetConfigValueAsString(_AppPasswordKey) == this.txtEnteredPassword.Text.Trim())
                {
                    e.Cancel = false;

                    // move to test settings...
                    this.CurrentWizardStepID = "WizTestSettings";
                }
                else
                {
                    this.AddLoadMessage("Wrong password!");
                }

                break;

            case "WizCreateForum":
                if (this.CreateForum())
                {
                    e.Cancel = false;
                }

                break;

            case "WizInitDatabase":
                if (this.InstallUpgradeService.UpgradeDatabase(this.FullTextSupport.Checked, this.UpgradeExtensions.Checked))
                {
                    e.Cancel = false;
                }

                // Check if BaskeUrlMask is set and if not automatically write it
                if (this._config.GetConfigValueAsString(_AppBaseUrlMaskKey).IsNotSet() && this._config.TrustLevel >= AspNetHostingPermissionLevel.High)
                {
#if DEBUG
                    var urlKey =
                        "http://{0}{1}/".FormatWith(
                            HttpContext.Current.Request.ServerVariables["SERVER_NAME"],
                            HttpContext.Current.Request.ServerVariables["SERVER_PORT"].Equals("80")
                                    ? string.Empty
                                    : ":{0}".FormatWith(HttpContext.Current.Request.ServerVariables["SERVER_PORT"]));
#else
                    var urlKey =
                        "http://{0}/".FormatWith(
                            HttpContext.Current.Request.ServerVariables["SERVER_NAME"]);
#endif

                    this._config.WriteAppSetting(_AppBaseUrlMaskKey, urlKey);
                }

                var messages = this.InstallUpgradeService.Messages;

                if (messages.Any())
                {
                    this._loadMessage += messages.ToDelimitedString("\r\n");
                }

                break;

            case "WizMigrateUsers":

                // migrate users/roles only if user does not want to skip
                if (!this.skipMigration.Checked)
                {
                    RoleMembershipHelper.SyncRoles(this.PageBoardID);

                    // start the background migration task...
                    this.Get <ITaskModuleManager>().Start <MigrateUsersTask>(this.PageBoardID);
                }

                e.Cancel = false;
                break;

            case "WizFinished":
                break;

            default:
                throw new ApplicationException(
                          "Installation Wizard step not handled: {0}".FormatWith(
                              this.InstallWizard.WizardSteps[e.CurrentStepIndex].ID));
            }
        }