Esempio n. 1
0
        private static XmlWebhookAction ToXmlModel(IeWebhookAction ieWebhookAction, WorkflowDataMaps dataMaps)
        {
            if (ieWebhookAction == null)
            {
                return(null);
            }

            if (!dataMaps.WebhooksByActionObj.ContainsKey(ieWebhookAction))
            {
                return(null);
            }

            return(new XmlWebhookAction
            {
                Name = ieWebhookAction.Name,
                WebhookId = dataMaps.WebhooksByActionObj[ieWebhookAction]
            });
        }
Esempio n. 2
0
        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);
        }