Exemple #1
0
        private void ux_buttonTestServer_Click(object sender, EventArgs e)
        {
            System.Web.Services.Discovery.DiscoveryClientProtocol dcp = new System.Web.Services.Discovery.DiscoveryClientProtocol();
            dcp.Timeout           = 1000;
            dcp.AllowAutoRedirect = true;

            // Test the address for the GRIN-Global web services...
            try
            {
                string serverAddress = "http://" + ux_textboxServerName.Text.Trim() + "/GRINGlobal/GUI.asmx";
                dcp.Discover(serverAddress);
                MessageBox.Show("Successfully connected!");
                dcp.Dispose();
            }
            catch
            {
                MessageBox.Show("Connection attempt failed");
                dcp.Dispose();
            }
        }
Exemple #2
0
        private void SearchNetworkForWebServers(Dictionary<string, string> WebServiceURLs)
        {
            Cursor.Current = Cursors.WaitCursor;
            string origMessage = ux_textboxLoginMessage.Text;
            ux_textboxLoginMessage.Text = "Scanning...";
            ux_progressbarScanning.Step = 1;
            ux_progressbarScanning.Minimum = 0;
            ux_progressbarScanning.Maximum = 255;
            ux_progressbarScanning.Value = 1;
            ux_progressbarScanning.Show();

            System.Web.Services.Discovery.DiscoveryClientProtocol dcp = new System.Web.Services.Discovery.DiscoveryClientProtocol();
            dcp.Timeout = 1000;

            // Search for active servers hosting the GRIN-Global web services...
            // Try the localhost first...
            try
            {
                ux_textboxLoginMessage.Text = "Scanning localhost...";
                ux_textboxLoginMessage.Update();
                dcp.Discover("http://localhost/GRINGlobal/GUI.asmx");
                WebServiceURLs.Add("localhost", "http://localhost/GRINGlobal/GUI.asmx");
            }
            catch
            {
                // Silently fail...
            }

            // Now scan the class D subnet for all available ethernet adapters...
            System.Net.NetworkInformation.NetworkInterface[] adapters = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();

            foreach (System.Net.NetworkInformation.NetworkInterface adapter in adapters)
            {
                if (adapter.NetworkInterfaceType == System.Net.NetworkInformation.NetworkInterfaceType.Ethernet &&
                    adapter.OperationalStatus == System.Net.NetworkInformation.OperationalStatus.Up)
                {
                    System.Net.NetworkInformation.IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
                    System.Net.NetworkInformation.UnicastIPAddressInformationCollection adapterAddresses = adapterProperties.UnicastAddresses;
                    foreach (System.Net.NetworkInformation.IPAddressInformation addressInfo in adapterAddresses)
                    {
                        DateTime dtStart = DateTime.Now;
                        string addrPrefix = addressInfo.Address.ToString().Substring(0, addressInfo.Address.ToString().LastIndexOf('.'));
                        string ipAddress = addrPrefix + ".1";
                        string webServiceURL = "http://" + ipAddress + "/GRINGlobal/GUI.asmx";
                        string serverName = System.Net.Dns.GetHostEntry(ipAddress).HostName;
                        System.Web.Services.Discovery.DiscoveryDocument dd = new System.Web.Services.Discovery.DiscoveryDocument();

                        for (int addrSuffix = 1; addrSuffix < 254; addrSuffix++)
                        {
                            try
                            {
                                // Now see if we can find a GG server...
                                ipAddress = addrPrefix + "." + addrSuffix;
                                // Display what IP address is being scanned...
                                ux_textboxLoginMessage.Text = "Scanning " + ipAddress + "...";
                                ux_textboxLoginMessage.Update();
                                // Attempt to discover the GG specific web services using the IP address...
                                dd = dcp.Discover("http://" + ipAddress + "/GRINGlobal/GUI.asmx");
                                // If we made it here, we found a webservice so now attempt to resolve the ipAddress to a friendlier host name
                                // Why do this now?  Because DNS lookup can be expensive so only do it when really neccessary
                                // (BTW... unresolved DNS lookups will return the ipAddress)...
                                serverName = System.Net.Dns.GetHostEntry(ipAddress).HostName;
                                webServiceURL = "http://" + serverName + "/GRINGlobal/GUI.asmx";
                                // Attempt to discover the GG specific web services (again - this time with a DNS resolved computer name)
                                // Why do this?  Because there is a slight possiblity the DNS lookup returned bogus data...
                                dd = dcp.Discover(webServiceURL);
                                for (int i = 0; i < dd.References.Count; i++)
                                {
                                    // There are many different references in a discovery document - we only want the SOAP Bindings...
                                    if (dd.References[i].GetType() == typeof(System.Web.Services.Discovery.SoapBinding))
                                    {
                                        System.Web.Services.Discovery.SoapBinding wsb = (System.Web.Services.Discovery.SoapBinding)dd.References[i];
                                        // The bad news is that the references have duplicates bindings (one for each protocol), but the good
                                        // news is that since the WebServiceURLs object is a dictionary... it will create and execption if the same Key entry is
                                        // attempted to be added twice (net result is that it will silently fail in the catch block)...
                                        WebServiceURLs.Add(serverName, wsb.Address);
                                    }
                                }
                            }
                            catch
                            {
                                // Silently fail...
                            }
                            ux_progressbarScanning.PerformStep();
                            ux_progressbarScanning.Update();
                            // Check to see if we should bail out (at user request)...
                            Application.DoEvents();
                        }
                    }
                }
            }
            ux_progressbarScanning.Hide();
            ux_textboxLoginMessage.Text = origMessage;
        }
Exemple #3
0
        private void SearchNetworkForWebServers(Dictionary <string, string> WebServiceURLs)
        {
            Cursor.Current = Cursors.WaitCursor;
            string origMessage = ux_textboxLoginMessage.Text;

            ux_textboxLoginMessage.Text    = "Scanning...";
            ux_progressbarScanning.Step    = 1;
            ux_progressbarScanning.Minimum = 0;
            ux_progressbarScanning.Maximum = 255;
            ux_progressbarScanning.Value   = 1;
            ux_progressbarScanning.Show();

            System.Web.Services.Discovery.DiscoveryClientProtocol dcp = new System.Web.Services.Discovery.DiscoveryClientProtocol();
            dcp.Timeout = 1000;

            // Search for active servers hosting the GRIN-Global web services...
            // Try the localhost first...
            try
            {
                ux_textboxLoginMessage.Text = "Scanning localhost...";
                ux_textboxLoginMessage.Update();
                dcp.Discover("http://localhost/GRINGlobal/GUI.asmx");
                WebServiceURLs.Add("localhost", "http://localhost/GRINGlobal/GUI.asmx");
            }
            catch
            {
                // Silently fail...
            }


            // Now scan the class D subnet for all available ethernet adapters...
            System.Net.NetworkInformation.NetworkInterface[] adapters = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();

            foreach (System.Net.NetworkInformation.NetworkInterface adapter in adapters)
            {
                if (adapter.NetworkInterfaceType == System.Net.NetworkInformation.NetworkInterfaceType.Ethernet &&
                    adapter.OperationalStatus == System.Net.NetworkInformation.OperationalStatus.Up)
                {
                    System.Net.NetworkInformation.IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
                    System.Net.NetworkInformation.UnicastIPAddressInformationCollection adapterAddresses = adapterProperties.UnicastAddresses;
                    foreach (System.Net.NetworkInformation.IPAddressInformation addressInfo in adapterAddresses)
                    {
                        DateTime dtStart       = DateTime.Now;
                        string   addrPrefix    = addressInfo.Address.ToString().Substring(0, addressInfo.Address.ToString().LastIndexOf('.'));
                        string   ipAddress     = addrPrefix + ".1";
                        string   webServiceURL = "http://" + ipAddress + "/GRINGlobal/GUI.asmx";
                        string   serverName    = System.Net.Dns.GetHostEntry(ipAddress).HostName;
                        System.Web.Services.Discovery.DiscoveryDocument dd = new System.Web.Services.Discovery.DiscoveryDocument();

                        for (int addrSuffix = 1; addrSuffix < 254; addrSuffix++)
                        {
                            try
                            {
                                // Now see if we can find a GG server...
                                ipAddress = addrPrefix + "." + addrSuffix;
                                // Display what IP address is being scanned...
                                ux_textboxLoginMessage.Text = "Scanning " + ipAddress + "...";
                                ux_textboxLoginMessage.Update();
                                // Attempt to discover the GG specific web services using the IP address...
                                dd = dcp.Discover("http://" + ipAddress + "/GRINGlobal/GUI.asmx");
                                // If we made it here, we found a webservice so now attempt to resolve the ipAddress to a friendlier host name
                                // Why do this now?  Because DNS lookup can be expensive so only do it when really neccessary
                                // (BTW... unresolved DNS lookups will return the ipAddress)...
                                serverName    = System.Net.Dns.GetHostEntry(ipAddress).HostName;
                                webServiceURL = "http://" + serverName + "/GRINGlobal/GUI.asmx";
                                // Attempt to discover the GG specific web services (again - this time with a DNS resolved computer name)
                                // Why do this?  Because there is a slight possiblity the DNS lookup returned bogus data...
                                dd = dcp.Discover(webServiceURL);
                                for (int i = 0; i < dd.References.Count; i++)
                                {
                                    // There are many different references in a discovery document - we only want the SOAP Bindings...
                                    if (dd.References[i].GetType() == typeof(System.Web.Services.Discovery.SoapBinding))
                                    {
                                        System.Web.Services.Discovery.SoapBinding wsb = (System.Web.Services.Discovery.SoapBinding)dd.References[i];
                                        // The bad news is that the references have duplicates bindings (one for each protocol), but the good
                                        // news is that since the WebServiceURLs object is a dictionary... it will create and execption if the same Key entry is
                                        // attempted to be added twice (net result is that it will silently fail in the catch block)...
                                        WebServiceURLs.Add(serverName, wsb.Address);
                                    }
                                }
                            }
                            catch
                            {
                                // Silently fail...
                            }
                            ux_progressbarScanning.PerformStep();
                            ux_progressbarScanning.Update();
                            // Check to see if we should bail out (at user request)...
                            Application.DoEvents();
                        }
                    }
                }
            }
            ux_progressbarScanning.Hide();
            ux_textboxLoginMessage.Text = origMessage;
        }
Exemple #4
0
        private void ux_buttonTestServer_Click(object sender, EventArgs e)
        {
            System.Web.Services.Discovery.DiscoveryClientProtocol dcp = new System.Web.Services.Discovery.DiscoveryClientProtocol();
            dcp.Timeout = 1000;
            dcp.AllowAutoRedirect = true;

            // Test the address for the GRIN-Global web services...
            try
            {
                string serverAddress = "http://" + ux_textboxServerName.Text.Trim() + "/GRINGlobal/GUI.asmx";
                dcp.Discover(serverAddress);
                MessageBox.Show("Successfully connected!");
                dcp.Dispose();
            }
            catch
            {
                MessageBox.Show("Connection attempt failed");
                dcp.Dispose();
            }
        }