Пример #1
0
		public Configuration( string configuration_path )
		{
			serviceController = new System.ServiceProcess.ServiceController("SMTPSVC");

			XmlTextReader reader = new XmlTextReader( configuration_path );
			XmlDocument doc = new XmlDocument();
			doc.Load( reader );

			// --

			XmlNode settings_node = doc.SelectSingleNode( "/configuration/settings" );
			Settings = new Settings( settings_node );

			// --

			XmlNodeList server_nodes = doc.SelectNodes( "/configuration/servers/server" );
			ArrayList servers = new ArrayList( server_nodes.Count );

			foreach( XmlNode server_node in server_nodes )
			{
				Server server = new Server( this, server_node );
				servers.Add( server );
				ServerNames.Add(server.Address);
				ServerTable.Add(server.Address,server);
			}

			Servers = (Server[])servers.ToArray( typeof(Server) );

			// --

			doc = null;
			reader = null;
		}
Пример #2
0
 public void LoadServerNames()
 {
     ServerNames.Clear();
     foreach (var item in ServerList)
     {
         ServerNames.Add(item.Name);
     }
 }
Пример #3
0
        private void GetDbServers()
        {
            if (!chkScanNetwork.Checked)
            {
                //RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL");
                //string[] array = (string[])registryKey.GetValueNames();
                //if (array.Length > 0)

                RegistryKey baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
                RegistryKey key     = baseKey.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL");

                foreach (string sqlInstance in key.GetValueNames())
                {
                    if (sqlInstance == "MSSQLSERVER")
                    {
                        ServerNames.Add(Environment.MachineName);
                    }
                    else
                    {
                        ServerNames.Add(Environment.MachineName + "\\" + sqlInstance);
                    }
                }
            }
            else
            {
                SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance;
                DataTable dataSources            = instance.GetDataSources();
                DataRow[] array3 = dataSources.Select("");
                DataRow[] array4 = array3;
                for (int j = 0; j < array4.Length; j++)
                {
                    DataRow dataRow = array4[j];
                    if (dataRow["InstanceName"] is string)
                    {
                        ServerNames.Add(dataRow["ServerName"] + "\\" + dataRow["InstanceName"]);
                    }
                    else
                    {
                        ServerNames.Add(dataRow["ServerName"]);
                    }
                }
            }
            ServerNames.Sort();
        }