Beispiel #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //var IP = "169.254.72.217";
            //var Port = "12345";
            //var IP = "95.84.228.121";
            //var Port = "12345";

            var IP = string.Format("{0}.{1}.{2}.{3}", TB_ip_1.Text, TB_ip_2.Text, TB_ip_3.Text, TB_ip_4.Text);
            var Port = TB_port.Text;

            NetTcpBinding b = new NetTcpBinding();
            b.Security.Mode = SecurityMode.Transport;
            b.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
            EndpointAddress ea = new EndpointAddress(new Uri("net.tcp://" + IP + ":" + Port + "/HddInfo"));

            var client = new ServiceReference1.HddInfoClient(b, ea);
            client.Endpoint.Address = new EndpointAddress(new Uri("net.tcp://" + IP + ":" + Port + "/HddInfo"));

            client.ClientCredentials.Windows.ClientCredential.UserName = TB_UserName.Text;
            client.ClientCredentials.Windows.ClientCredential.Password = TB_Password.Text;

            try
            {
                var res3 = client.GetHddInfo();
                foreach (var item in res3)
                {
                    LB_result.Items.Add("===================================");
                    LB_result.Items.Add(item.Caption);
                    LB_result.Items.Add(item.DeviceID);
                    LB_result.Items.Add(item.Status);
                    LB_result.Items.Add(item.Size);
                    foreach (var ld in item.LogicalDrives)
                    {
                        LB_result.Items.Add(ld);
                    }
                    LB_result.Items.Add("===================================");
                }
            }
            catch (Exception ex)
            {
                LB_result.Items.Add(ex.Message);
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var IP = "169.254.72.217";
            var Port = "12345";
            //var client = new ServiceReference1.HddInfoClient("NetTcpBinding_IHddInfo");
            //client.Endpoint.Address = new EndpointAddress(new Uri("net.tcp://" + IP + ":" + Port + "/HddInfo"));

            NetTcpBinding b = new NetTcpBinding();
            b.Security.Mode = SecurityMode.Transport;
            b.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
            EndpointAddress ea = new EndpointAddress(new Uri("net.tcp://" + IP + ":" + Port + "/HddInfo"));

            var client = new ServiceReference1.HddInfoClient(b, ea);
            client.ClientCredentials.Windows.ClientCredential.UserName = "******";
            client.ClientCredentials.Windows.ClientCredential.Password = "******";

            try
            {
                var res3 = client.GetHddInfo();
                foreach(var item in res3)
                {
                    listBox1.Items.Add("===================================");
                    listBox1.Items.Add(item.Caption);
                    listBox1.Items.Add(item.DeviceID);
                    listBox1.Items.Add(item.Status);
                    listBox1.Items.Add(item.Size);
                    foreach (var ld in item.LogicalDrives)
                    {
                        listBox1.Items.Add(ld);
                    }
                    listBox1.Items.Add("===================================");
                }
            }
            catch (Exception ex)
            {
                listBox1.Items.Add(ex.Message);
            }
        }