/// <summary> /// Process an event asynchronously. /// </summary> /// <param name="e">event to process</param> /// <returns> /// Task to wait on. /// </returns> public async Task HandleAsync(IMessageContext context, ReportAddedToIncident e) { _logger.Debug("doing filters.."); IEnumerable <Trigger> triggers; try { triggers = _repository.GetForApplication(e.Incident.ApplicationId); } catch (Exception exception) { _logger.Error("Failed to load triggers for " + e.Incident.ApplicationId, exception); return; } foreach (var trigger in triggers) { var triggerContext = new TriggerExecutionContext { Incident = e.Incident, ErrorReport = e.Report }; var triggerResults = trigger.Run(triggerContext); foreach (var actionData in triggerResults) { var action = _actionFactory.Create(actionData.ActionName); var actionContext = new ActionExecutionContext { Config = actionData, ErrorReport = e.Report, Incident = e.Incident }; await action.ExecuteAsync(actionContext); } } _logger.Debug("filters done.."); }