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;
            }
        }
 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;
     }
 }
Example #3
0
        private void InvokeMethod(string type, string action, IApiContext apiContext, Event mzEvent)
        {
            var assemblyType = Type.GetType(type);

            if (assemblyType == null)
                throw new Exception("Method : " + type + " could not be loaded");

            var typeConstructor = assemblyType.GetConstructor(Type.EmptyTypes);

            if (typeConstructor == null)
                throw new Exception("Method : Default constructor not be found for type "+ type);

            var typeObject = typeConstructor.Invoke(new Object[] { });

            var methodInfo = assemblyType.GetMethod(action, BindingFlags.IgnoreCase | BindingFlags.Public);

            if (methodInfo == null)
                throw new Exception("Method : " + action + " not found in " + type);
            methodInfo.Invoke(typeObject, new Object[] { apiContext, mzEvent });
        }
Example #4
0
        public void ProcessEvent(IApiContext apiContext, Event eventPayLoad)
        {
            var eventConfigSection = ConfigurationManager.GetSection("eventSection") as EventSection;

            if (eventConfigSection == null)
                throw new Exception("Events are not configured");

            var eventType = eventPayLoad.Topic.Split('.');

            var topic = eventType[0];
            var action = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(eventType[1]);

            var entityConfigElement = eventConfigSection.Events[topic];

            if (entityConfigElement == null)
                throw new Exception("CorrelationId:{0},No Registered module found for "+topic);
            var type = entityConfigElement.Type;

            InvokeMethod(type, action, apiContext, eventPayLoad);
        }
        public async Task ProcessEventAsync(IApiContext apiContext, Event eventPayLoad)
        {
            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 (topic != "application" && !IsAppEnabled(apiContext).Result)
            {
                _logger.Info("App is not enabled, skipping processing of event");
                return;
            }

            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);

        }
 public void Updated(IApiContext apiContext, Event eventPayLoad)
 {
     throw new NotImplementedException();
 }
 public void PendingReview(IApiContext apiContext, Event eventPayLoad)
 {
     throw new NotImplementedException();
 }
 public Task UpdatedAsync(IApiContext apiContext, Event eventPayLoad)
 {
     throw new NotImplementedException();
 }
 public Task PendingReviewAsync(IApiContext apiContext, Event eventPayLoad)
 {
     throw new NotImplementedException();
 }