コード例 #1
0
        /// <summary>
        /// The upgrade database.
        /// </summary>
        /// <param name="fullText">
        /// The full text.
        /// </param>
        /// <param name="upgradeExtensions">
        /// The upgrade Extensions.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool UpgradeDatabase(bool fullText, bool upgradeExtensions)
        {
            this._messages.Clear();
            {
                var isForumInstalled = this.IsForumInstalled;

                // try
                this.FixAccess(false);

                var isAzureEngine = this.Get <IDbFunction>().GetSQLEngine().Equals("Azure");

                if (!isForumInstalled)
                {
                    this.ExecuteInstallScripts(isAzureEngine);
                }
                else
                {
                    this.ExecuteUpgradeScripts(isAzureEngine);
                }

                this.FixAccess(true);

                var prevVersion = LegacyDb.GetDBVersion();

                LegacyDb.system_updateversion(YafForumInfo.AppVersion, YafForumInfo.AppVersionName);

                // Ederon : 9/7/2007
                // resync all boards - necessary for propr last post bubbling
                this.GetRepository <Board>().Resync();

                this.RaiseEvent.RaiseIssolated(
                    new AfterUpgradeDatabaseEvent(prevVersion, YafForumInfo.AppVersion),
                    null);

                if (isForumInstalled)
                {
                    if (prevVersion < 30 || upgradeExtensions)
                    {
                        this.ImportStatics();
                    }

                    if (prevVersion < 42)
                    {
                        // un-html encode all topic subject names...
                        LegacyDb.unencode_all_topics_subjects(HttpUtility.HtmlDecode);
                    }

                    if (prevVersion < 49)
                    {
                        // Reset The UserBox Template
                        try
                        {
                            this.Get <YafBoardSettings>().UserBox = Constants.UserBox.DisplayTemplateDefault;
                            ((YafLoadBoardSettings)this.Get <YafBoardSettings>()).SaveRegistry();
                        }
                        catch (Exception)
                        {
                            LegacyDb.registry_save("userbox", Constants.UserBox.DisplayTemplateDefault);
                        }
                    }

                    try
                    {
                        // Check if BaskeUrlMask is set and if not automatically write it
                        if (this.Get <YafBoardSettings>().BaseUrlMask.IsNotSet())
                        {
                            this.Get <YafBoardSettings>().BaseUrlMask = BaseUrlBuilder.GetBaseUrlFromVariables();

                            ((YafLoadBoardSettings)this.Get <YafBoardSettings>()).SaveRegistry();
                        }
                    }
                    catch (Exception)
                    {
                        LegacyDb.registry_save("baseurlmask", BaseUrlBuilder.GetBaseUrlFromVariables());
                    }
                }

                // vzrus: uncomment it to not keep install/upgrade objects in DB and for better security
                // DB.system_deleteinstallobjects();
            }

            // attempt to apply fulltext support if desired
            if (fullText && this.DbAccess.Information.FullTextScript.IsSet())
            {
                try
                {
                    this.ExecuteScript(this.DbAccess.Information.FullTextScript, false);
                }
                catch (Exception x)
                {
                    // just a warning...
                    this._messages.Add("Warning: FullText Support wasn't installed: {0}".FormatWith(x.Message));
                }
            }

            // run custom script...
            this.ExecuteScript("custom/custom.sql", true);

            if (Config.IsDotNetNuke)
            {
                // run dnn custom script...
                this.ExecuteScript("custom/dnn.sql", true);
            }

            return(true);
        }
コード例 #2
0
ファイル: default.aspx.cs プロジェクト: Pathfinder-Fr/Website
        /// <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));
            }
        }
コード例 #3
0
ファイル: default.aspx.cs プロジェクト: Pathfinder-Fr/Website
        /// <summary>
        /// Handles the ActiveStepChanged event of the Wizard control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Wizard_ActiveStepChanged([NotNull] object sender, [NotNull] EventArgs e)
        {
            var previousVisible = false;

            switch (this.CurrentWizardStepID)
            {
            case "WizCreatePassword":
                this.lblConfigPasswordAppSettingFile.Text = "app.config";

                if (this.IsConfigPasswordSet)
                {
                    // no need for this setup if IsInstalled...
                    this.InstallWizard.ActiveStepIndex++;

                    if (!this.IsForumInstalled)
                    {
                        // Skip enter the password on a new install when
                        // the app.config password is already set
                        this.CurrentWizardStepID = "WizDatabaseConnection";
                    }
                }

                break;

            case "WizCreateForum":
                if (this.InstallUpgradeService.IsForumInstalled)
                {
                    this.InstallWizard.ActiveStepIndex++;
                }

                break;

            case "WizMigrateUsers":
                if (!this.IsConfigPasswordSet)
                {
                    // no migration because it's a new install...
                    this.CurrentWizardStepID = "WizFinished";
                }
                else
                {
                    var version = (this.Cache["DBVersion"] ?? LegacyDb.GetDBVersion()).ToType <int>();

                    if (version >= 30 || version == -1)
                    {
                        // migration is NOT needed...
                        this.CurrentWizardStepID = "WizFinished";
                    }

                    this.Cache.Remove("DBVersion");
                }

                // get user count
                if (this.CurrentWizardStepID == "WizMigrateUsers")
                {
                    this.lblMigrateUsersCount.Text =
                        LegacyDb.user_list(this.PageBoardID, null, true).Rows.Count.ToString();
                }

                break;

            case "WizDatabaseConnection":
                previousVisible = true;

                // fill with connection strings...
                this.lblConnStringAppSettingName.Text = Config.ConnectionStringName;
                this.FillWithConnectionStrings();
                break;

            case "WizManualDatabaseConnection":
                this.lblAppSettingsFile.Text = "app.config";

                previousVisible = true;
                break;

            case "WizManuallySetPassword":
                this.lblAppSettingsFile2.Text = "app.config";

                break;

            case "WizTestSettings":
                previousVisible = true;
                break;

            case "WizValidatePermission":
                break;

            case "WizMigratingUsers":

                // disable the next button...
                var btnNext =
                    this.InstallWizard.FindControlAs <Button>("StepNavigationTemplateContainerID$StepNextButton");
                if (btnNext != null)
                {
                    btnNext.Enabled = false;
                }

                break;
            }

            var btnPrevious =
                this.InstallWizard.FindControlAs <Button>("StepNavigationTemplateContainerID$StepPreviousButton");

            if (btnPrevious != null)
            {
                btnPrevious.Visible = previousVisible;
            }
        }
コード例 #4
0
ファイル: default.aspx.cs プロジェクト: Pathfinder-Fr/Website
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            var errorMessage = this.InstallWizard.FindControlAs <PlaceHolder>("ErrorMessage");

            if (this._loadMessage.IsNotSet())
            {
                errorMessage.Visible = false;
            }

            if (this.IsPostBack)
            {
                return;
            }

            if (this.Session["InstallWizardFinal"] != null)
            {
                this.CurrentWizardStepID = "WizFinished";
                this.Session.Remove("InstallWizardFinal");
            }
            else
            {
                this.Cache["DBVersion"] = LegacyDb.GetDBVersion();

                this.CurrentWizardStepID = this.IsConfigPasswordSet && this.IsForumInstalled ? "WizEnterPassword" : "WizWelcome";

                // "WizCreatePassword"
                if (!this.IsConfigPasswordSet)
                {
                    // fake the board settings
                    YafContext.Current.BoardSettings = new YafBoardSettings();
                }

                this.FullTextSupport.Visible = this.DbAccess.Information.FullTextScript.IsSet() && this.Get <IDbFunction>().IsFullTextSupported();

                this.TimeZones.DataSource = StaticDataHelper.TimeZones();

                this.Culture.DataSource     = StaticDataHelper.Cultures();
                this.Culture.DataValueField = "CultureTag";
                this.Culture.DataTextField  = "CultureNativeName";

                this.DataBind();

                this.TimeZones.Items.FindByValue(TimeZoneInfo.Local.Id).Selected = true;

                if (this.Culture.Items.Count > 0)
                {
                    this.Culture.Items.FindByValue("en-US").Selected = true;
                }

                this.ForumBaseUrlMask.Text = BaseUrlBuilder.GetBaseUrlFromVariables();

                this.DBUsernamePasswordHolder.Visible = LegacyDb.PasswordPlaceholderVisible;

                // Connection string parameters text boxes
                foreach (var paramNumber in Enumerable.Range(1, 20))
                {
                    var dbParam =
                        this.DbAccess.Information.DbConnectionParameters.FirstOrDefault(p => p.ID == paramNumber);

                    var label = this.FindControlRecursiveAs <Label>("Parameter{0}_Name".FormatWith(paramNumber));
                    if (label != null)
                    {
                        label.Text = dbParam != null ? dbParam.Name : string.Empty;
                    }

                    var control = this.FindControlRecursive("Parameter{0}_Value".FormatWith(paramNumber));
                    if (control is TextBox)
                    {
                        var textBox = control as TextBox;
                        if (dbParam != null)
                        {
                            textBox.Text    = dbParam.Value;
                            textBox.Visible = true;
                        }
                        else
                        {
                            textBox.Text    = string.Empty;
                            textBox.Visible = false;
                        }
                    }
                    else if (control is CheckBox)
                    {
                        var checkBox = control as CheckBox;
                        if (dbParam != null)
                        {
                            checkBox.Checked = dbParam.Value.ToType <bool>();
                            checkBox.Visible = true;
                        }
                        else
                        {
                            checkBox.Checked = false;
                            checkBox.Visible = false;
                        }
                    }
                }

                // Hide New User on DNN
                if (!Config.IsDotNetNuke)
                {
                    return;
                }

                this.UserChoice.SelectedIndex    = 1;
                this.UserChoice.Items[0].Enabled = false;

                this.ExistingUserHolder.Visible    = true;
                this.CreateAdminUserHolder.Visible = false;
            }
        }
コード例 #5
0
ファイル: default.aspx.cs プロジェクト: DaoCalendar/YAFNET
        /// <summary>
        /// The wizard_ active step changed.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Wizard_ActiveStepChanged([NotNull] object sender, [NotNull] EventArgs e)
        {
            bool previousVisible = false;

            switch (this.CurrentWizardStepID)
            {
            case "WizCreatePassword":
                if (this._config.TrustLevel >= AspNetHostingPermissionLevel.High &&
                    this._config.AppSettingsFull != null)
                {
                    this.lblConfigPasswordAppSettingFile.Text = this._config.AppSettingsFull.File;
                }
                else
                {
                    this.lblConfigPasswordAppSettingFile.Text = "(Unknown! YAF default is app.config)";
                }

                if (this.IsInstalled)
                {
                    // no need for this setup if IsInstalled...
                    this.InstallWizard.ActiveStepIndex++;
                }

                break;

            case "WizCreateForum":
                if (this.InstallUpgradeService.IsForumInstalled)
                {
                    this.InstallWizard.ActiveStepIndex++;
                }

                break;

            case "WizMigrateUsers":
                if (!this.IsInstalled)
                {
                    // no migration because it's a new install...
                    this.CurrentWizardStepID = "WizFinished";
                }
                else
                {
                    object version = this.Cache["DBVersion"] ?? LegacyDb.GetDBVersion();

                    if (((int)version) >= 30 || ((int)version) == -1)
                    {
                        // migration is NOT needed...
                        this.CurrentWizardStepID = "WizFinished";
                    }

                    this.Cache.Remove("DBVersion");
                }

                // get user count
                if (this.CurrentWizardStepID == "WizMigrateUsers")
                {
                    this.lblMigrateUsersCount.Text =
                        LegacyDb.user_list(this.PageBoardID, null, true).Rows.Count.ToString();
                }

                break;

            case "WizDatabaseConnection":
                previousVisible = true;

                // fill with connection strings...
                this.lblConnStringAppSettingName.Text = Config.ConnectionStringName;
                this.FillWithConnectionStrings();
                break;

            case "WizManualDatabaseConnection":
                if (this._config.TrustLevel >= AspNetHostingPermissionLevel.High &&
                    this._config.AppSettingsFull != null)
                {
                    this.lblAppSettingsFile.Text = this._config.AppSettingsFull.File;
                }
                else
                {
                    this.lblAppSettingsFile.Text = "(Unknown! YAF default is app.config)";
                }

                previousVisible = true;
                break;

            case "WizManuallySetPassword":
                if (this._config.TrustLevel >= AspNetHostingPermissionLevel.High &&
                    this._config.AppSettingsFull != null)
                {
                    this.lblAppSettingsFile2.Text = this._config.AppSettingsFull.File;
                }
                else
                {
                    this.lblAppSettingsFile2.Text = "(Unknown! YAF default is app.config)";
                }

                break;

            case "WizTestSettings":
                previousVisible = true;
                break;

            case "WizValidatePermission":
                break;

            case "WizMigratingUsers":

                // disable the next button...
                var btnNext =
                    this.InstallWizard.FindControlAs <Button>("StepNavigationTemplateContainerID$StepNextButton");
                if (btnNext != null)
                {
                    btnNext.Enabled = false;
                }

                break;
            }

            var btnPrevious =
                this.InstallWizard.FindControlAs <Button>("StepNavigationTemplateContainerID$StepPreviousButton");

            if (btnPrevious != null)
            {
                btnPrevious.Visible = previousVisible;
            }
        }
コード例 #6
0
        /// <summary>
        /// The upgrade database.
        /// </summary>
        /// <param name="fullText">
        /// The full text.
        /// </param>
        /// <param name="upgradeExtensions">
        /// The upgrade Extensions.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool UpgradeDatabase(bool fullText, bool upgradeExtensions)
        {
            this._messages.Clear();
            {
                // try
                this.FixAccess(false);

                foreach (string script in this.DbAccess.Information.Scripts)
                {
                    this.ExecuteScript(script, true);
                }

                this.FixAccess(true);

                int prevVersion = LegacyDb.GetDBVersion();

                LegacyDb.system_updateversion(YafForumInfo.AppVersion, YafForumInfo.AppVersionName);

                // Ederon : 9/7/2007
                // resync all boards - necessary for propr last post bubbling
                this.GetRepository <Board>().Resync();

                this.RaiseEvent.RaiseIssolated(new AfterUpgradeDatabaseEvent(prevVersion, YafForumInfo.AppVersion), null);

                //// upgrade providers...
                if (this.IsForumInstalled && (prevVersion < 30 || upgradeExtensions))
                {
                    this.ImportStatics();
                }

                if (this.IsForumInstalled && prevVersion < 42)
                {
                    // un-html encode all topic subject names...
                    LegacyDb.unencode_all_topics_subjects(HttpUtility.HtmlDecode);
                }

                if (this.IsForumInstalled && prevVersion < 49)
                {
                    // Reset The UserBox Template
                    this.Get <YafBoardSettings>().UserBox = Constants.UserBox.DisplayTemplateDefault;

                    ((YafLoadBoardSettings)this.Get <YafBoardSettings>()).SaveRegistry();
                }

                // vzrus: uncomment it to not keep install/upgrade objects in DB and for better security
                // DB.system_deleteinstallobjects();
            }

            // attempt to apply fulltext support if desired
            if (fullText && this.DbAccess.Information.FullTextScript.IsSet())
            {
                try
                {
                    this.ExecuteScript(this.DbAccess.Information.FullTextScript, false);
                }
                catch (Exception x)
                {
                    // just a warning...
                    this._messages.Add("Warning: FullText Support wasn't installed: {0}".FormatWith(x.Message));
                }
            }

            // run custom script...
            this.ExecuteScript("custom/custom.sql", true);

            if (Config.IsDotNetNuke)
            {
                // run dnn custom script...
                this.ExecuteScript("custom/dnn.sql", true);
            }

            return(true);
        }