private void UpdateRootNode()
 {
     StorageScopeNode ssn = ((StorageScopeNode)this.RootNode);
     do
     {
         try
         {
             ssn.storage = this.storage;
             ssn.dataSource = this.dataSource;
             ssn.initialCatalog = this.initialCatalog;
             ssn.security = this.security;
             ssn.otherSettings = this.otherSettings;
             ssn.userId = this.userId;
             ssn.password = this.password;
             ssn.internalRender();
         }
         catch (SqlException)
         {
             this.storage = null;
             ssn.storage = null;
         }
         if (ssn.storage == null)
         {
             if (this.splash != null && this.splash.Visible)
             {
                 System.Threading.Thread.Sleep(1000);
                 this.splash.Close();
                 this.splash.Dispose();
                 Application.DoEvents();
             }
             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));
             }
             else
             {
                 return;
             }
         }
     } while (ssn.storage == null);
 }
 protected internal void sqlStoreConnectionStringAction_Triggered(object sender, MMC.SyncActionEventArgs e)
 {
     frmStorageConnection frm = new frmStorageConnection();
     frm.dataSource = this.dataSource;
     frm.initialCatalog = this.initialCatalog;
     frm.security = this.security;
     frm.otherSettings = this.otherSettings;
     frm.userId = this.userId;
     frm.password = this.password;
     DialogResult dr = this.SnapIn.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.Render();
         ((NetSqlAzManSnapIn)this.SnapIn).dataSource = this.dataSource;
         ((NetSqlAzManSnapIn)this.SnapIn).initialCatalog = this.initialCatalog;
         ((NetSqlAzManSnapIn)this.SnapIn).security = this.security;
         ((NetSqlAzManSnapIn)this.SnapIn).otherSettings = this.otherSettings;
         ((NetSqlAzManSnapIn)this.SnapIn).userId = this.userId;
         ((NetSqlAzManSnapIn)this.SnapIn).password = this.password;
         this.SnapIn.IsModified = true;
     }
 }
 /// <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();
         }
     }
 }