protected override void OnInitialize() { this.splash = new frmSplash(); this.splash.Visible = false; if (!NetSqlAzManSnapIn.splashScreenShowed) { this.showSplashScreen(); } base.OnInitialize(); this.RootNode = new StorageScopeNode(); if (this.splash.Visible) { new System.Threading.Thread(new System.Threading.ThreadStart( delegate() { System.Threading.Thread.Sleep(2500); if (!this.loadingCustomData) { this.splash.Close(); this.splash.Dispose(); } Application.DoEvents(); })).Start(); } System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(o => this.Setup())); }
/// <summary> /// Load in any saved data /// </summary> /// <param name="status">asynchronous status for updating the console</param> /// <param name="persistenceData">binary data stored in the console file</param> protected override void OnLoadCustomData(MMC.AsyncStatus status, byte[] persistenceData) { try { this.loadingCustomData = true; /*Application.DoEvents();*/ base.OnLoadCustomData(status, persistenceData); string allSettings = Encoding.Unicode.GetString(persistenceData); string connectionSettingsString = allSettings.Substring(0, allSettings.LastIndexOf('\n') + 1); string savedLanguage = "en"; if (allSettings.Split('\n').Length >= 7) { if (!String.IsNullOrEmpty(allSettings.Split('\n')[6])) { savedLanguage = allSettings.Split('\n')[6]; } } if (!String.IsNullOrEmpty(savedLanguage)) { Globalization.MultilanguageResource.SetCulture(Globalization.MultilanguageResource.cultureName(savedLanguage)); } // saved name? then set snap-in to the name if (string.IsNullOrEmpty(connectionSettingsString) || connectionSettingsString == new String('\n', 6)) { if (this.splash != null && this.splash.Visible) { new System.Threading.Thread(new System.Threading.ThreadStart( delegate() { System.Threading.Thread.Sleep(1500); this.splash.Close(); this.splash.Dispose(); Application.DoEvents(); this.splash = null; })).Start(); } frmStorageConnection frm = new frmStorageConnection(); DialogResult dr = this.Console.ShowDialog(frm); if (dr == DialogResult.OK) { this.dataSource = frm.dataSource; this.initialCatalog = frm.initialCatalog; this.security = frm.security; this.otherSettings = frm.otherSettings; this.userId = frm.userId; this.password = frm.password; this.storage = new SqlAzManStorage(frmStorageConnection.ConstructConnectionString(this.dataSource, this.initialCatalog, !(this.security == "Sql"), this.userId, this.password, this.otherSettings)); this.UpdateRootNode(); } else { this.storage = null; } } else { try { this.dataSource = connectionSettingsString.Split('\n')[0]; this.initialCatalog = connectionSettingsString.Split('\n')[1]; this.security = connectionSettingsString.Split('\n')[2]; this.otherSettings = connectionSettingsString.Split('\n')[3]; this.userId = connectionSettingsString.Split('\n')[4]; this.password = connectionSettingsString.Split('\n')[5]; this.storage = new SqlAzManStorage(frmStorageConnection.ConstructConnectionString(this.dataSource, this.initialCatalog, !(this.security == "Sql"), this.userId, this.password, this.otherSettings)); this.UpdateRootNode(); } catch (SqlException) { frmStorageConnection frm = new frmStorageConnection(); DialogResult dr = this.Console.ShowDialog(frm); if (dr == DialogResult.OK) { this.dataSource = frm.dataSource; this.initialCatalog = frm.initialCatalog; this.security = frm.security; this.otherSettings = frm.otherSettings; this.userId = frm.userId; this.password = frm.password; this.storage = new SqlAzManStorage(frmStorageConnection.ConstructConnectionString(this.dataSource, this.initialCatalog, !(this.security == "Sql"), this.userId, this.password, this.otherSettings)); this.UpdateRootNode(); } else { this.storage = null; } } } } catch (Exception ex) { this.ShowError(String.Format(Globalization.MultilanguageResource.GetString("MMC_Msg30"), ex.Message), Globalization.MultilanguageResource.GetString("MMC_Tit30")); } finally { if (this.splash != null && this.splash.Visible) { new System.Threading.Thread(new System.Threading.ThreadStart( delegate() { System.Threading.Thread.Sleep(2500); this.splash.Close(); this.splash.Dispose(); Application.DoEvents(); })).Start(); } } }