Esempio n. 1
0
 private void FrmMain_Load(object sender, EventArgs e)
 {
     instanceContext       = new InstanceContext(this);
     hospitalServiceClient = new HospitalServiceClient(instanceContext);
     hospitalServiceClient.ClientCredentials.ClientCertificate = System.Net.CredentialCache.DefaultCredentials;
     try
     {
         hospitalServiceClient.Subscribe(clientId);
         txtID.Text = clientId;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         Environment.Exit(0);
     }
     System.Timers.Timer timer = new System.Timers.Timer(3000);
     timer.Elapsed +=
         (
             (object o, ElapsedEventArgs args) =>
     {
         try
         {
             if (hospitalServiceClient.State == CommunicationState.Faulted)
             {
                 hospitalServiceClient.Abort();
                 hospitalServiceClient = new HospitalServiceClient(instanceContext);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
         );
 }
Esempio n. 2
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            string message = txtMessage.Text;

            if (!string.IsNullOrEmpty(message))
            {
                try
                {
                    if (hospitalServiceClient.State == CommunicationState.Faulted)
                    {
                        hospitalServiceClient.Abort();
                        hospitalServiceClient = new HospitalServiceClient(instanceContext);
                    }
                    hospitalServiceClient.SendMessage(clientId, message, txtReciever.Text);
                    txtMessage.Text = string.Empty;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }