Пример #1
0
        public void End(Exception ex = null)
        {
            try
            {
                if (ex == null)
                {
                    return;
                }

                var pipeProxy = _pipeFactory.CreateChannel();
                if (pipeProxy == null || _pipeFactory.State != CommunicationState.Opened)
                {
                    Logger.Warn("Could not publish exception message - connection closed.");
                    return;
                }

                var json = JsonConvert.SerializeObject(_currentMessage);

                var contract = new MessageExceptionContract
                {
                    Endpoint    = Configure.EndpointName,
                    MessageJson = json,
                    MessageType = _currentMessage.GetType().FullName,
                    Exception   = ex.ToString()
                };
                Logger.Info("Published exception message.");

                pipeProxy.MessageException(contract);
            }
            catch (EndpointNotFoundException e)
            {
                Logger.Error("Unable to publish exception message.", e);
            }
            catch (CommunicationObjectFaultedException e)
            {
                Logger.Error("Unable to publish exception message.", e);
            }
            finally
            {
                _currentMessage = null;
            }
        }
Пример #2
0
 public void MessageException(MessageExceptionContract message)
 {
     MessageExceptionEvent(this, message);
 }
        public void End(Exception ex = null)
        {
            try
            {
                if (ex == null)
                    return;

                var pipeProxy = _pipeFactory.CreateChannel();
                if (pipeProxy == null || _pipeFactory.State != CommunicationState.Opened)
                {
                    Logger.Warn("Could not publish exception message - connection closed.");
                    return;
                }

                var json = JsonConvert.SerializeObject(_currentMessage);

                var contract = new MessageExceptionContract
                {
                    Endpoint = Configure.EndpointName,
                    MessageJson = json,
                    MessageType = _currentMessage.GetType().FullName,
                    Exception = ex.ToString()
                };
                Logger.Info("Published exception message.");

                pipeProxy.MessageException(contract);
            }
            catch (EndpointNotFoundException e)
            {
                Logger.Error("Unable to publish exception message.", e);
            }
            catch (CommunicationObjectFaultedException e)
            {
                Logger.Error("Unable to publish exception message.", e);
            }
            finally
            {
                _currentMessage = null;
            }
        }
 public void MessageException(MessageExceptionContract message)
 {
     MessageExceptionEvent(this, message);
 }