public virtual void ValidateActionData(WorkflowDataValidationResult result, IeBaseAction action, bool ignoreIds) { if (action == null) { return; } switch (action.ActionType) { case ActionTypes.EmailNotification: ValidateEmailNotificationActionData(result, (IeEmailNotificationAction)action, ignoreIds); break; case ActionTypes.PropertyChange: ValidatePropertyChangeActionData(result, (IePropertyChangeAction)action, ignoreIds); break; case ActionTypes.Generate: ValidateGenerateActionData(result, (IeGenerateAction)action, ignoreIds); break; case ActionTypes.Webhook: // No data to validate break; default: throw new ArgumentOutOfRangeException(nameof(action.ActionType)); } }
private static XmlAction ToXmlModel(IeBaseAction ieAction, WorkflowDataMaps dataMaps) { if (ieAction == null) { return(null); } switch (ieAction.ActionType) { case ActionTypes.EmailNotification: return(ToXmlModel(ieAction as IeEmailNotificationAction, dataMaps.PropertyTypeMap)); case ActionTypes.PropertyChange: return(ToXmlModel(ieAction as IePropertyChangeAction, dataMaps)); case ActionTypes.Generate: return(ToXmlModel(ieAction as IeGenerateAction, dataMaps.ArtifactTypeMap)); case ActionTypes.Webhook: return(ToXmlModel(ieAction as IeWebhookAction, dataMaps)); default: throw new ArgumentOutOfRangeException(nameof(ieAction.ActionType)); } }
private static void NormalizeAction(IeBaseAction action) { if (action == null) { return; } switch (action.ActionType) { case ActionTypes.EmailNotification: NormalizeEmailNotificationAction((IeEmailNotificationAction)action); break; case ActionTypes.PropertyChange: NormalizePropertyChangeAction((IePropertyChangeAction)action); break; case ActionTypes.Generate: break; case ActionTypes.Webhook: break; default: throw new ArgumentOutOfRangeException(nameof(action.ActionType)); } }
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); }
private static DBaseAction MapToDAction(IeBaseAction ieBaseAction) { switch (ieBaseAction?.ActionType) { case ActionTypes.EmailNotification: var ieEmailNotificationAction = ieBaseAction as IeEmailNotificationAction; if (ieEmailNotificationAction != null) { return(new DEmailNotificationAction { Name = ieEmailNotificationAction.Name, Emails = ieEmailNotificationAction.Emails?.ToList(), Message = ieEmailNotificationAction.Message, PropertyId = ieEmailNotificationAction.PropertyId, PropertyName = ieEmailNotificationAction.PropertyName }); } break; case ActionTypes.Generate: var ieGenerateAction = ieBaseAction as IeGenerateAction; if (ieGenerateAction != null) { return(new DGenerateAction { Name = ieGenerateAction.Name, ArtifactType = ieGenerateAction.ArtifactType, ArtifactTypeId = ieGenerateAction.ArtifactTypeId, ChildCount = ieGenerateAction.ChildCount, GenerateActionType = ieGenerateAction.GenerateActionType }); } break; case ActionTypes.PropertyChange: var iePropertyChangeAction = ieBaseAction as IePropertyChangeAction; if (iePropertyChangeAction != null) { return(new DPropertyChangeAction { Name = iePropertyChangeAction.Name, PropertyName = iePropertyChangeAction.PropertyName, PropertyId = iePropertyChangeAction.PropertyId, PropertyValue = iePropertyChangeAction.PropertyValue, UsersGroups = iePropertyChangeAction.UsersGroups != null ? new DUsersGroups { IncludeCurrentUser = iePropertyChangeAction.UsersGroups?.IncludeCurrentUser, UsersGroups = iePropertyChangeAction.UsersGroups?.UsersGroups?.Select(ieUserGroup => new DUserGroup { Id = ieUserGroup.Id, Name = ieUserGroup.Name, DisplayName = ieUserGroup.DisplayName, GroupProjectId = ieUserGroup.GroupProjectId, GroupProjectPath = ieUserGroup.GroupProjectPath, IsGroup = ieUserGroup.IsGroup }).ToList() } : null, ValidValues = iePropertyChangeAction.ValidValues?.Select(ieValidValue => new DValidValue { Id = ieValidValue.Id, Value = ieValidValue.Value }).ToList() }); } break; case ActionTypes.Webhook: var ieWebhookAction = ieBaseAction as IeWebhookAction; if (ieWebhookAction != null) { return(new DWebhookAction { WebhookId = ieWebhookAction.IdSerializable, Name = ieWebhookAction.Name, Url = ieWebhookAction.Url }); } break; default: return(null); } return(null); }