public XmlWorkflowEventTriggers ToXmlModel(IEnumerable <IeTrigger> ieTriggers, WorkflowDataMaps dataMaps) { if (ieTriggers == null) { return(null); } var xmlTriggers = new XmlWorkflowEventTriggers(); ieTriggers.ForEach(t => xmlTriggers.Triggers.Add(ToXmlModel(t, dataMaps))); return(xmlTriggers); }
public List <EmailNotificationAction> GetNotificationActions(IEnumerable <SqlWorkflowEvent> sqlArtifactTriggers) { var notifications = new List <EmailNotificationAction>(); foreach (var workflowEvent in sqlArtifactTriggers) { var triggersXml = workflowEvent.Triggers; var xmlWorkflowEventTriggers = new XmlWorkflowEventTriggers(); if (!string.IsNullOrWhiteSpace(triggersXml)) { try { Log.Debug($"Deserializing triggers: {triggersXml}"); var triggersFromXml = SerializationHelper.FromXml <XmlWorkflowEventTriggers>(triggersXml); if (triggersFromXml != null) { xmlWorkflowEventTriggers = triggersFromXml; } else { Log.Debug($"Invalid triggers XML: {triggersXml}"); } } catch (Exception ex) { Log.Error($"Deserialization failed for triggers: {triggersXml}", ex); } } var triggersWithEmailActions = xmlWorkflowEventTriggers.Triggers.Where(trigger => trigger.Action.ActionType == ActionTypes.EmailNotification); foreach (var trigger in triggersWithEmailActions) { var action = (XmlEmailNotificationAction)trigger.Action; XmlStateCondition condition = null; if (trigger.Condition?.ConditionType == ConditionTypes.State) { condition = (XmlStateCondition)trigger.Condition; } var emailNotification = new EmailNotificationAction { ConditionalStateId = condition?.StateId, EventPropertyTypeId = workflowEvent.EventPropertyTypeId ?? 0, PropertyTypeId = action.PropertyTypeId, Message = action.Message }; emailNotification.Emails.AddRange(action.Emails); notifications.Add(emailNotification); } } return(notifications); }
private WorkflowEventTriggers ToWorkflowTriggers(XmlWorkflowEventTriggers xmlWorkflowEventTriggers, int currentUserId) { WorkflowEventTriggers triggers = new WorkflowEventTriggers(); if (xmlWorkflowEventTriggers == null || xmlWorkflowEventTriggers.Triggers == null) { return(triggers); } triggers.AddRange(xmlWorkflowEventTriggers.Triggers.Select(xmlWorkflowEventTrigger => new WorkflowEventTrigger { Name = xmlWorkflowEventTrigger.Name, Condition = new WorkflowEventCondition(), Action = GenerateAction(xmlWorkflowEventTrigger.Action, currentUserId) })); return(triggers); }
public IEnumerable <IeTrigger> FromXmlModel(XmlWorkflowEventTriggers xmlTriggers, WorkflowDataNameMaps dataMaps, ISet <int> userIdsToCollect, ISet <int> groupIdsToCollect) { if (xmlTriggers == null) { return(null); } var triggers = new List <IeTrigger>(); xmlTriggers.Triggers?.ForEach(t => { var trigger = FromXmlModel(t, dataMaps, userIdsToCollect, groupIdsToCollect); if (trigger != null) { triggers.Add(trigger); } }); return(triggers); }