Ejemplo n.º 1
0
    /// <summary>
    /// Finish button click.
    /// </summary>
    protected void FinishNextButton_Click(object sender, EventArgs e)
    {
        if (!separationFinished.ValidateForSeparationFinish())
        {
            string error = String.Empty;
            if (!AzureHelper.IsRunningOnAzure)
            {
                var separationHelper = new DBSeparationHelper();

                separationHelper.InstallScriptsFolder           = CMSDatabaseHelper.GetSQLInstallPathToObjects();
                separationHelper.ScriptsFolder                  = Server.MapPath("~/App_Data/DBSeparation");
                separationHelper.InstallationConnStringSeparate = hdnConnString.Value;
                error = separationHelper.DeleteSourceTables(separationFinished.DeleteOldDB, false);
            }

            if (!String.IsNullOrEmpty(error))
            {
                separationFinished.ErrorLabel.Visible = true;
                separationFinished.ErrorLabel.Text    = error;
                new EventLogProvider().LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Contact management database join", "DELETEOLDDATA", URLHelper.CurrentURL, error);
            }
            else
            {
                EnableTasks();
                TakeSitesOnline();
                WebSyncHelperClass.CreateTask(WebFarmTaskTypeEnum.RestartApplication, "RestartApplication", "", null);
                ScriptHelper.RegisterStartupScript(this, typeof(string), "Close dialog", ScriptHelper.GetScript("RefreshParent(); CloseDialog();"));
            }
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Joins databases.
    /// </summary>
    private void JoinDB()
    {
        var separation = new DBSeparationHelper();

        separation.InstallScriptsFolder = CMSDatabaseHelper.GetSQLInstallPathToObjects();
        separation.ScriptsFolder        = Server.MapPath("~/App_Data/DBSeparation");
        separation.LogMessage           = progress.LogMessage;
        separation.JoinDatabase();

        progress.LogMessage(ResHelper.GetString("separationDB.joinOK"), CMSDatabaseHelper.MessageType.Finished, false);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Separates database.
    /// </summary>
    private void SeparateDB()
    {
        separation = new DBSeparationHelper();

        separation.InstallationConnStringSeparate = databaseDialog.ConnectionString;
        separation.InstallScriptsFolder           = CMSDatabaseHelper.GetSQLInstallPathToObjects();
        separation.ScriptsFolder = Server.MapPath("~/App_Data/DBSeparation");
        separation.LogMessage    = progress.LogMessage;

        separation.SeparateDatabase();

        progress.LogMessage(ResHelper.GetString("SeparationDB.OK"), CMSDatabaseHelper.MessageType.Finished, false);
    }
    /// <summary>
    /// Separates database.
    /// </summary>
    private void SeparateDB()
    {
        separation = new DBSeparationHelper();

        separation.InstallationConnStringSeparate = databaseDialog.ConnectionString;
        separation.InstallScriptsFolder = CMSDatabaseHelper.GetSQLInstallPathToObjects();
        separation.ScriptsFolder = Server.MapPath("~/App_Data/DBSeparation");
        separation.LogMessage = progress.LogMessage;

        separation.SeparateDatabase();

        progress.LogMessage(ResHelper.GetString("SeparationDB.OK"), CMSDatabaseHelper.MessageType.Finished, false);
    }
    /// <summary>
    /// Finish button click.
    /// </summary>
    protected void FinishNextButton_Click(object sender, EventArgs e)
    {
        if (separationFinished.ValidateForSeparationFinish())
        {
            string error = String.Empty;
            if (!AzureHelper.IsRunningOnAzure)
            {
                var separationHelper = new DBSeparationHelper();

                separationHelper.InstallationConnStringSeparate = DBSeparationHelper.ConnStringSeparate;
                separationHelper.InstallScriptsFolder = CMSDatabaseHelper.GetSQLInstallPathToObjects();
                separationHelper.ScriptsFolder = Server.MapPath("~/App_Data/DBSeparation");
                error = separationHelper.DeleteSourceTables(false, true);
            }

            if (!String.IsNullOrEmpty(error))
            {
                separationFinished.ErrorLabel.Visible = true;
                separationFinished.ErrorLabel.Text = error;
                new EventLogProvider().LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Contact management database separation", "DELETEOLDDATA", URLHelper.CurrentURL, error);
            }
            else
            {
                EnableTasks();
                TakeSitesOnline();
                WebSyncHelperClass.CreateTask(WebFarmTaskTypeEnum.RestartApplication, "RestartApplication", "", null);
                ScriptHelper.RegisterStartupScript(this, typeof(string), "Close dialog", ScriptHelper.GetScript("RefreshParent(); CloseDialog();"));
            }
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Validates control.
    /// </summary>
    public bool ValidateForSeparation()
    {
        // Get database name
        if (radCreateNew.Checked && !AzureHelper.IsRunningOnAzure)
        {
            Database = txtNewDatabaseName.Text;
        }
        else
        {
            Database = txtExistingDatabaseName.Text;
        }
        Database = TextHelper.LimitLength(Database, 100, String.Empty);

        if (String.IsNullOrEmpty(Database))
        {
            DisplaySeparationError(GetString("Install.ErrorDBNameEmpty"));
            return(false);
        }

        // Set up the connection string
        ConnectionString = ConnectionHelper.GetConnectionString(AuthenticationType, ServerName, Database, Username, Password, 240, false);

        // Test existing DB
        if (radUseExisting.Checked || AzureHelper.IsRunningOnAzure)
        {
            if (!String.IsNullOrEmpty(ConnectionHelper.TestConnection(AuthenticationType, ServerName, Database, Username, Password)))
            {
                DisplaySeparationError(String.Format(ResHelper.GetFileString("Install.ErrorDatabseDoesntExist"), Database));
                return(false);
            }

            if (DBSeparationHelper.CheckCMDatabase(ConnectionString))
            {
                DisplaySeparationError(GetString("separationDB.errorCMexists"));
                return(false);
            }
            if (!AzureHelper.IsRunningOnAzure)
            {
                if (!ConnectionHelper.CheckDBPermission(DatabasePermission.ModifyDatabase, AuthenticationType, ServerName, Username, Password))
                {
                    DisplaySeparationError(GetString("separationDB.permissionmodify"));
                    return(false);
                }
            }
        }
        // Test new DB
        else
        {
            if (ConnectionHelper.DatabaseExists(ConnectionString))
            {
                DisplaySeparationError(GetString("separationDB.ErrorDBExists"));
                return(false);
            }
            if (!AzureHelper.IsRunningOnAzure)
            {
                if (!ConnectionHelper.CheckDBPermission(DatabasePermission.ModifyDatabase, AuthenticationType, ServerName, Username, Password))
                {
                    DisplaySeparationError(GetString("separationDB.permissionmodify"));
                    return(false);
                }
                if (!ConnectionHelper.CheckDBPermission(DatabasePermission.CreateDatabase, AuthenticationType, ServerName, Username, Password))
                {
                    DisplaySeparationError(GetString("separationDB.permissioncreate"));
                    return(false);
                }
            }
        }

        // Test if tasks are stopped
        if (EnabledTasks())
        {
            DisplaySeparationError(GetString("separationDB.stoptaskserror"));
            return(false);
        }
        imgHelp.Visible = btnStopTasks.Visible = true;

        // Test if separation process is not already started.
        if (SystemHelper.DBSeparationInProgress)
        {
            DisplaySeparationError(GetString("separationDB.processalreadystarted"));
            return(false);
        }

        return(true);
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Joins databases.
    /// </summary>
    private void JoinDB()
    {
        var separation = new DBSeparationHelper();

        separation.InstallScriptsFolder = CMSDatabaseHelper.GetSQLInstallPathToObjects();
        separation.ScriptsFolder = Server.MapPath("~/App_Data/DBSeparation");
        separation.LogMessage = progress.LogMessage;
        separation.JoinDatabase();

        progress.LogMessage(ResHelper.GetString("separationDB.joinOK"), CMSDatabaseHelper.MessageType.Finished, false);
    }