using System; using CMS.DataEngine; using CMS.DatabaseHelper; using CMS.ExtendedControls; using CMS.GlobalHelper; using CMS.SettingsProvider; using CMS.UIControls; public partial class CMSInstall_Controls_WizardSteps_SeparationFinished : CMSUserControl { #region "Variables" private const string COLLATION_CASE_INSENSITIVE = "SQL_Latin1_General_CP1_CI_AS"; #endregion #region "Public properties" /// /// Error label. /// public LocalizedLabel ErrorLabel { get { return lblError; } } /// /// Error label for azure. /// public LocalizedLabel AzureErrorLabel { get { return lblAzureError; } } /// /// Info label. /// public LocalizedLabel InfoLabel { get { return lblCompleted; } } /// /// Connection string. /// public string ConnectionString { get; set; } /// /// Database. /// public string Database { get; set; } /// /// Indicates if old database should be deleted completely. /// public bool DeleteOldDB { get { return chkDeleteOldDB.Checked; } } /// /// Indicates if current process is separation. /// public bool IsSeparation { get; set; } #endregion #region "Page events" protected override void OnLoad(EventArgs e) { base.OnLoad(e); plcDeleteOldDB.Visible = !IsSeparation && !AzureHelper.IsRunningOnAzure; imgHelp.ImageUrl = GetImageUrl("/CMSModules/CMS_Settings/help.png"); imgHelp.ToolTip = GetString("separationDB.deleteolddbhelp"); } protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (!String.IsNullOrEmpty(lblAzureError.Text)) { plcAzureError.Visible = true; plcContent.Visible = false; } } #endregion #region "Methods and event" /// /// Change collation clicked. /// protected void btnChangeCollation_Click(object sender, EventArgs e) { ConnectionHelper.ChangeDatabaseCollation(ConnectionString, Database, COLLATION_CASE_INSENSITIVE); lblCompleted.ResourceString = "separationDB.OK"; btnChangeCollation.Visible = false; } /// /// Display collation dialog. /// public void DisplayCollationDialog() { string collation = ConnectionHelper.GetDatabaseCollation(ConnectionString); if (CMSString.Compare(collation, COLLATION_CASE_INSENSITIVE, true) != 0) { lblChangeCollation.ResourceString = string.Format(ResHelper.GetFileString("separationDB.collation"), collation); btnChangeCollation.ResourceString = string.Format(ResHelper.GetFileString("install.changecollation"), COLLATION_CASE_INSENSITIVE); plcChangeCollation.Visible = true; } } /// /// Validates control. /// public bool ValidateForSeparationFinish() { if (AzureHelper.IsRunningOnAzure) { return !String.IsNullOrEmpty(AzureHelper.GetConnectionString(DBSeparationHelper.ConnStringSeparateName)); } else { return !String.IsNullOrEmpty(DBSeparationHelper.ConnStringSeparate); } } #endregion }