private static IeCondition FromXmlModel(XmlCondition xmlCondition, WorkflowDataNameMaps dataMaps) { if (xmlCondition == null) { return(null); } switch (xmlCondition.ConditionType) { case ConditionTypes.State: string name; var stateId = (xmlCondition as XmlStateCondition).StateId; var ieCondition = dataMaps.StateMap.TryGetValue(stateId, out name) ? new IeStateCondition { StateId = stateId, State = name } : null; return(ieCondition); default: throw new ArgumentOutOfRangeException(nameof(xmlCondition.ConditionType)); } }
private static List <IeValidValue> FromXmlModel(List <int> valueIds, WorkflowDataNameMaps dataMaps) { var values = new List <IeValidValue>(); valueIds?.ForEach(id => { string value; if (dataMaps.ValidValueMap.TryGetValue(id, out value)) { values.Add(new IeValidValue { Id = id, Value = value }); } }); return(values.Any() ? values : null); }
private static IeTrigger FromXmlModel(XmlWorkflowEventTrigger xmlTrigger, WorkflowDataNameMaps dataMaps, ISet <int> userIdsToCollect, ISet <int> groupIdsToCollect) { if (xmlTrigger == null) { return(null); } var action = FromXmlModel(xmlTrigger.Action, dataMaps, userIdsToCollect, groupIdsToCollect); var ieTrigger = action != null ? new IeTrigger { Name = xmlTrigger.Name, Action = action, Condition = FromXmlModel(xmlTrigger.Condition, dataMaps) } : null; return(ieTrigger); }
private static IeBaseAction FromXmlModel(XmlAction xmlAction, WorkflowDataNameMaps dataMaps, ISet <int> userIdsToCollect, ISet <int> groupIdsToCollect) { if (xmlAction == null) { return(null); } string name = null; IeBaseAction action = null; switch (xmlAction.ActionType) { case ActionTypes.EmailNotification: var xeAction = xmlAction as XmlEmailNotificationAction; action = !xeAction.PropertyTypeId.HasValue || dataMaps.PropertyTypeMap.TryGetValue(xeAction.PropertyTypeId.Value, out name) ? new IeEmailNotificationAction { Name = xeAction.Name, Emails = xeAction.Emails, PropertyId = xeAction.PropertyTypeId, PropertyName = name, Message = xeAction.Message } : null; break; case ActionTypes.PropertyChange: var xpAction = xmlAction as XmlPropertyChangeAction; var isPropertyFound = dataMaps.PropertyTypeMap.TryGetValue(xpAction.PropertyTypeId, out name) || WorkflowHelper.TryGetNameOrDescriptionPropertyTypeName(xpAction.PropertyTypeId, out name); action = isPropertyFound ? new IePropertyChangeAction { Name = xpAction.Name, PropertyId = xpAction.PropertyTypeId, PropertyName = name, PropertyValue = xpAction.PropertyValue, ValidValues = FromXmlModel(xpAction.ValidValues, dataMaps), UsersGroups = FromXmlModel(xpAction.UsersGroups, userIdsToCollect, groupIdsToCollect) } : null; break; case ActionTypes.Generate: var xgAction = xmlAction as XmlGenerateAction; action = xgAction.GenerateActionType != GenerateActionTypes.Children || (xgAction.ArtifactTypeId.HasValue && dataMaps.ArtifactTypeMap.TryGetValue(xgAction.ArtifactTypeId.Value, out name)) ? new IeGenerateAction { Name = xgAction.Name, GenerateActionType = xgAction.GenerateActionType, ChildCount = xgAction.ChildCount, ArtifactTypeId = xgAction.ArtifactTypeId, ArtifactType = name } : null; break; case ActionTypes.Webhook: var xwAction = xmlAction as XmlWebhookAction; action = new IeWebhookAction { Name = xmlAction.Name, Id = xwAction.WebhookId }; break; } return(action); }
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); }