示例#1
0
        public async Task ProcessEventAsync(IApiContext apiContext, Event eventPayLoad)
        {
            try
            {
                Trace.CorrelationManager.ActivityId = !String.IsNullOrEmpty(apiContext.CorrelationId)
                    ? Guid.Parse(apiContext.CorrelationId)
                    : Guid.NewGuid();

                _logger.Info(String.Format("Got Event {0} for tenant {1}", eventPayLoad.Topic, apiContext.TenantId));


                var eventType = eventPayLoad.Topic.Split('.');
                var topic     = eventType[0];

                if (String.IsNullOrEmpty(topic))
                {
                    throw new ArgumentException("Topic cannot be null or empty");
                }

                var eventCategory  = (EventCategory)(Enum.Parse(typeof(EventCategory), topic, true));
                var eventProcessor = _container.ResolveKeyed <IEventProcessor>(eventCategory);
                await eventProcessor.ProcessAsync(_container, apiContext, eventPayLoad);
            }
            catch (Exception exc)
            {
                _emailHandler.SendErrorEmail(new ErrorInfo {
                    Message = "Error Processing Event : " + JsonConvert.SerializeObject(eventPayLoad), Context = apiContext, Exception = exc
                });
                throw exc;
            }
        }
示例#2
0
 public async Task ProcessEventAsync(IApiContext apiContext, Event eventPayLoad)
 {
     try
     {
         var eventProcessor = _container.Resolve <IGenericEventProcessor>();
         await eventProcessor.ProcessEvent(apiContext, eventPayLoad);
     }
     catch (Exception exc)
     {
         _emailHandler.SendErrorEmail(new ErrorInfo {
             Message = "Error Processing Event : " + JsonConvert.SerializeObject(eventPayLoad), Context = apiContext, Exception = exc
         });
         throw;
     }
 }
 public void TestErrorEmail()
 {
     _emailHandler.SendErrorEmail(new ErrorInfo {
         Message = "Event order.opened failed", Context = new ApiContext(1234), Exception = new Exception("test")
     });
 }