/// <summary>
        /// 创建下一步活动的节点
        /// </summary>
        /// <param name="activity"></param>
        /// <returns></returns>
        internal static NextActivityComponent CreateNextActivityComponent(TransitionEntity transition,
                                                                          ActivityEntity activity)
        {
            NextActivityComponent component = null;

            if (XPDLHelper.IsSimpleComponentNode(activity.ActivityType) == true)           //可流转简单类型节点
            {
                string name = "单一节点";
                component = new NextActivityItem(name, transition, activity);
            }
            else if (activity.ActivityType == ActivityTypeEnum.SubProcessNode)
            {
                string name = "子流程节点";
                component = new NextActivityItem(name, transition, activity);
            }
            else
            {
                string name = string.Empty;
                if (activity.GatewayDirectionType == Slickflow.Engine.Common.GatewayDirectionEnum.AndSplit)
                {
                    name = "必全选节点";
                }
                else
                {
                    name = "或多选节点";
                }

                component = new NextActivityGateway(name, transition, activity);
            }
            return(component);
        }
Exemple #2
0
        /// <summary>
        /// 根据Transition,获取下一步节点列表
        /// </summary>
        /// <param name="forwardTransition">转移实体</param>
        /// <param name="conditionKeyValuePair">条件kv对</param>
        /// <param name="resultType">结果类型</param>
        protected NextActivityComponent GetNextActivityListFromGatewayCore(TransitionEntity forwardTransition,
                                                                           IDictionary <string, string> conditionKeyValuePair,
                                                                           out NextActivityMatchedType resultType)
        {
            NextActivityComponent child = null;

            if (XPDLHelper.IsSimpleComponentNode(forwardTransition.ToActivity.ActivityType) == true)       //可流转简单类型节点
            {
                child      = NextActivityComponentFactory.CreateNextActivityComponent(forwardTransition, forwardTransition.ToActivity);
                resultType = NextActivityMatchedType.Successed;
            }
            else if (forwardTransition.ToActivity.ActivityType == ActivityTypeEnum.GatewayNode)
            {
                child = GetNextActivityListFromGateway(forwardTransition,
                                                       forwardTransition.ToActivity,
                                                       conditionKeyValuePair,
                                                       out resultType);
            }
            else
            {
                resultType = NextActivityMatchedType.Failed;

                throw new XmlDefinitionException(string.Format("未知的节点类型:{0}", forwardTransition.ToActivity.ActivityType.ToString()));
            }
            return(child);
        }
        /// <summary>
        /// 创建跳转节点(强制拉取跳转方式,后续节点状态可以强制拉取前置节点到当前节点[后续节点])
        /// </summary>
        /// <param name="fromActivity">要拉取的节点</param>
        /// <param name="toActivity">拉取到节点</param>
        /// <returns></returns>
        internal static NextActivityComponent CreateNextActivityComponent(ActivityEntity fromActivity,
                                                                          ActivityEntity toActivity)
        {
            NextActivityComponent component = null;

            if (XPDLHelper.IsSimpleComponentNode(fromActivity.ActivityType) == true)       //可流转简单类型节点
            {
                string name       = "单一节点";
                var    transition = TransitionBuilder.CreateJumpforwardEmptyTransition(fromActivity, toActivity);

                component = new NextActivityItem(name, transition, fromActivity);     //强制拉取跳转类型的transition 为空类型
            }
            else
            {
                throw new ApplicationException(string.Format("不能跳转到其它非任务类型的节点!当前节点:{0}",
                                                             fromActivity.ActivityType));
            }
            return(component);
        }
Exemple #4
0
        /// <summary>
        /// Convert XmlNode to Activity Entity
        /// </summary>
        /// <param name="node">Xml Node</param>
        /// <param name="processGUID">ProcessGUID</param>
        /// <returns>Activity Entity</returns>
        public static ActivityEntity ConvertXmlActivityNodeToActivityEntity(XmlNode node, string processGUID)
        {
            ActivityEntity entity = new ActivityEntity();

            entity.ActivityGUID = XMLHelper.GetXmlAttribute(node, "id");
            entity.ActivityName = XMLHelper.GetXmlAttribute(node, "name");
            entity.ActivityCode = XMLHelper.GetXmlAttribute(node, "code");
            entity.ActivityUrl  = XMLHelper.GetXmlAttribute(node, "url");
            entity.ProcessGUID  = processGUID;

            //描述信息
            XmlNode descNode = node.SelectSingleNode("Description");

            entity.Description = (descNode != null) ? descNode.InnerText : string.Empty;

            //节点类型信息
            XmlNode typeNode = node.SelectSingleNode("ActivityType");

            entity.ActivityType       = (ActivityTypeEnum)Enum.Parse(typeof(ActivityTypeEnum), XMLHelper.GetXmlAttribute(typeNode, "type"));
            entity.ActivityTypeDetail = ConvertXmlNodeToActivityTypeDetail(typeNode);
            entity.WorkItemType       = XPDLHelper.GetWorkItemType(entity.ActivityType);

            if (entity.ActivityType == ActivityTypeEnum.SubProcessNode)             //sub process node
            {
                //子流程节点
                var subProcessNode = new SubProcessNode(entity);
                var strSubType     = XMLHelper.GetXmlAttribute(typeNode, "subType");
                if (!string.IsNullOrEmpty(strSubType))
                {
                    subProcessNode.SubProcessType = (SubProcessTypeEnum)Enum.Parse(typeof(SubProcessTypeEnum), strSubType);
                    subProcessNode.SubVarName     = XMLHelper.GetXmlAttribute(typeNode, "subVar");
                }
                else
                {
                    subProcessNode.SubProcessType = SubProcessTypeEnum.Fixed;
                }
                subProcessNode.SubProcessGUID = XMLHelper.GetXmlAttribute(typeNode, "subId");
                entity.Node = subProcessNode;
            }
            else if (entity.ActivityType == ActivityTypeEnum.MultipleInstanceNode)      //multiple instance node
            {
                var multipleInstanceNode = new MultipleInstanceNode(entity);
                entity.Node = multipleInstanceNode;
            }

            //获取节点的操作列表
            XmlNode actionsNode = node.SelectSingleNode("Actions");

            if (actionsNode != null)
            {
                XmlNodeList         xmlActionList = actionsNode.ChildNodes;
                List <ActionEntity> actionList    = new List <ActionEntity>();
                foreach (XmlNode element in xmlActionList)
                {
                    actionList.Add(ConvertXmlActionNodeToActionEntity(element));
                }
                entity.ActionList = actionList;
            }

            //获取节点的服务列表
            XmlNode servicesNode = node.SelectSingleNode("Services");

            if (servicesNode != null)
            {
                XmlNodeList          xmlServiceList = servicesNode.ChildNodes;
                List <ServiceEntity> serviceList    = new List <ServiceEntity>();
                foreach (XmlNode element in xmlServiceList)
                {
                    serviceList.Add(ConvertXmlServiceNodeToServiceEntity(element));
                }
                entity.ServiceList = serviceList;
            }

            //获取节点边界列表
            XmlNode boundariesNode = node.SelectSingleNode("Boundaries");

            if (boundariesNode != null)
            {
                XmlNodeList           xmlBoundaryList = boundariesNode.ChildNodes;
                List <BoundaryEntity> boundaryList    = new List <BoundaryEntity>();
                foreach (XmlNode element in xmlBoundaryList)
                {
                    boundaryList.Add(ConvertXmlBoundaryNodeToBoundaryEntity(element));
                }
                entity.BoundaryList = boundaryList;
            }

            //获取节点自定义章节信息
            XmlNode sectionsNode = node.SelectSingleNode("Sections");

            if (sectionsNode != null)
            {
                XmlNodeList          xmlSectionList = sectionsNode.ChildNodes;
                List <SectionEntity> sectionList    = new List <SectionEntity>();
                foreach (XmlNode element in xmlSectionList)
                {
                    sectionList.Add(ConvertXmlSectionNodeToSectionEntity(element));
                }
                entity.SectionList = sectionList;
            }


            //节点的Split Join 类型
            string gatewaySplitJoinType = XMLHelper.GetXmlAttribute(typeNode, "gatewaySplitJoinType");

            if (!string.IsNullOrEmpty(gatewaySplitJoinType))
            {
                entity.GatewaySplitJoinType = (GatewaySplitJoinTypeEnum)Enum.Parse(typeof(GatewaySplitJoinTypeEnum), gatewaySplitJoinType);
            }

            string gatewayDirection = XMLHelper.GetXmlAttribute(typeNode, "gatewayDirection");

            //节点的路由信息
            if (!string.IsNullOrEmpty(gatewayDirection))
            {
                entity.GatewayDirectionType = (GatewayDirectionEnum)Enum.Parse(typeof(GatewayDirectionEnum), gatewayDirection);
            }

            string gatewayJoinPass = XMLHelper.GetXmlAttribute(typeNode, "gatewayJoinPass");

            if (!string.IsNullOrEmpty(gatewayJoinPass))
            {
                entity.GatewayJoinPassType = EnumHelper.TryParseEnum <GatewayJoinPassEnum>(gatewayJoinPass);
            }

            return(entity);
        }