예제 #1
0
 private void bt_Start_Click(object sender, EventArgs e)
 {
     try
     {
         if (ds_KetNoi.SelectedIndex == 0)
         {
             address = new EndpointAddress(new Uri("http://localhost:8000/BasicHttpBinding"));
             factory = new ChannelFactory<IService>(new BasicHttpBinding(), address);
             patientSvc = factory.CreateChannel();
             for (int i = 0; i < patientSvc.GetAuthors().Count(); i++)
                 lv_ThanhVien.Items.Add(patientSvc.GetAuthors()[i]);
             tb_DeTai.Text = patientSvc.DeTai();
         }
         else if (ds_KetNoi.SelectedIndex == 1)
         {
             address = new EndpointAddress(new Uri("http://localhost:8000/WSHttpBinding"));
             factory = new ChannelFactory<IService>(new WSHttpBinding(), address);
             patientSvc = factory.CreateChannel();
             for (int i = 0; i < patientSvc.GetAuthors().Count(); i++)
                 lv_ThanhVien.Items.Add(patientSvc.GetAuthors()[i]);
             tb_DeTai.Text = patientSvc.DeTai();
         }
         else if (ds_KetNoi.SelectedIndex == 2)
         {
             address = new EndpointAddress(new Uri("net.tcp://localhost:8000/NetTcpBinding"));
             factory = new ChannelFactory<IService>(new NetTcpBinding(), address);
             patientSvc = factory.CreateChannel();
             for (int i = 0; i < patientSvc.GetAuthors().Count(); i++)
                 lv_ThanhVien.Items.Add(patientSvc.GetAuthors()[i]);
             tb_DeTai.Text = patientSvc.DeTai();
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show("Không kết nối được !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         tb_DeTai.Text = "";
         lv_ThanhVien.Items.Clear();
     }
 }
예제 #2
0
        private void btn_Author_BasHttp_Click(object sender, EventArgs e)
        {
            // try
               // {
                address = new EndpointAddress("http://localhost:" + txtLLocaBasHttp.Text + "/GetMark_Service");
                BasicHttpBinding binding = new BasicHttpBinding();
                proxy = ChannelFactory<IService>.CreateChannel(binding, address);

                lstMem = proxy.GetAuthors();
                grid_basHttp.DataSource = lstMem;
              //  }
              //  catch
              //  {
              //      MessageBox.Show("Service not responding!", "Warning", MessageBoxButtons.OK);
              //  }
        }
예제 #3
0
        private void btn_Author_WsHttp_Click(object sender, EventArgs e)
        {
            try
            {
                address = new EndpointAddress("http://localhost:" + txtLLocaWsHttp.Text + "/GetMark_Service");
                WSHttpBinding binding = new WSHttpBinding();

                proxy = ChannelFactory<IService>.CreateChannel(binding, address);
                lstMem = proxy.GetAuthors();
                grid_WsHttp.DataSource = lstMem;
            }
            catch (CommunicationException commProblem) //lỗi giao tiếp với server
            {
                MessageBox.Show("There was a communication problem. " + commProblem.Message + commProblem.StackTrace);
            }
        }
예제 #4
0
        private void btn_Author_netNamePipe_Click(object sender, EventArgs e)
        {
            try
            {
                address = new EndpointAddress("net.pipe://localhost/GetMark_Service");

                NetNamedPipeBinding binding = new NetNamedPipeBinding();

                proxy = ChannelFactory<IService>.CreateChannel(binding, address);
                lstMem = proxy.GetAuthors();
                grid_netNPipe.DataSource = lstMem;
            }
            catch
            {
                MessageBox.Show("Service not responding!", "Warning", MessageBoxButtons.OK);
            }
        }