示例#1
0
 private void CreateNewProxy()
 {
     try
     {
         if (TelegramNotify != null)
         {
             if (TelegramNotify.State == CommunicationState.Faulted)
             {
                 TelegramNotify.Abort();
             }
             else
             {
                 TelegramNotify.Close();
             }
             TelegramNotify = null;
         }
         var ic = new InstanceContext(this);
         TelegramNotify = new TelegramNotifyClient(ic);
         TelegramNotify.RegisterCommunicator(Name);
         Log?.AddLog(Log.Severity.EVENT, Name, String.Format("ServiceCommunicator.CreateNewProxy ({0})", Name), "");
     }
     catch (Exception ex)
     {
         Log?.AddLog(Log.Severity.EXCEPTION, Name, "ServiceCommunicator.CreateNewProxy Exception", ex.Message);
         throw new ServiceCommunicatorException(String.Format("{0} ServiceCommunicator.NotifyRcv failed. Reason:{1}", Name, ex.Message));
     }
 }
示例#2
0
 public override void NotifySend(Telegram tel)
 {
     try
     {
         if (!(tel is TelegramLife))
         {
             TelegramNotify.TelegramNotifySend(tel, Name);
         }
         Log?.AddLog(Log.Severity.EVENT, Name, "ServiceCommunicator.NotifySend", tel.ToString());
     }
     catch (CommunicationObjectAbortedException ex)
     {
         CreateNewProxy();
         Log?.AddLog(Log.Severity.EXCEPTION, Name, "ServiceCommunicator.NotifySend CommunicationObjectAbortException", ex.Message);
         throw new ServiceCommunicatorException(String.Format("{0} ServiceCommunicator.NotifySend failed. Reason:{1}", Name, ex.Message));
     }
     catch (CommunicationObjectFaultedException ex)
     {
         CreateNewProxy();
         Log?.AddLog(Log.Severity.EXCEPTION, Name, "ServiceCommunicator.NotifySend CommunicationObjectFaultException", ex.Message);
         throw new ServiceCommunicatorException(String.Format("{0} ServiceCommunicator.NotifySend failed. Reason:{1}", Name, ex.Message));
     }
     catch (Exception ex)
     {
         CreateNewProxy();
         Log?.AddLog(Log.Severity.EXCEPTION, Name, "ServiceCommunicator.NotifySend", ex.Message);
         throw new ServiceCommunicatorException(String.Format("{0} ServiceCommunicator.NotifySend failed. Reason:{1}", Name, ex.Message));
     }
 }
示例#3
0
 public override void Dispose()
 {
     try
     {
         base.Dispose();
         TelegramNotify?.Close();
     }
     catch {}
 }