Esempio n. 1
0
        /// <summary>
        /// 获取下一步节点列表,伴随运行时条件信息
        /// </summary>
        /// <param name="currentActivity"></param>
        /// <param name="conditionKeyValuePair"></param>
        /// <returns></returns>
        internal NextActivityMatchedResult GetNextActivityList(ActivityEntity currentActivity,
                                                               IDictionary <string, string> conditionKeyValuePair = null)
        {
            try
            {
                NextActivityMatchedResult result     = null;
                NextActivityMatchedType   resultType = NextActivityMatchedType.Unknown;

                //创建“下一步节点”的根节点
                NextActivityComponent   root           = NextActivityComponentFactory.CreateNextActivityComponent();
                NextActivityComponent   child          = null;
                List <TransitionEntity> transitionList = GetForwardTransitionList(currentActivity.ActivityGUID,
                                                                                  conditionKeyValuePair).ToList();

                if (transitionList.Count > 0)
                {
                    //遍历连线,获取下一步节点的列表
                    foreach (TransitionEntity transition in transitionList)
                    {
                        if (transition.ToActivity.NodeType == NodeTypeEnum.EndNode ||
                            transition.ToActivity.NodeType == NodeTypeEnum.TaskNode)
                        {
                            child = NextActivityComponentFactory.CreateNextActivityComponent(transition, transition.ToActivity);
                        }
                        else if (transition.ToActivity.NodeType == NodeTypeEnum.GatewayNode)
                        {
                            NextActivityScheduleBase activitySchedule = NextActivityScheduleFactory.CreateActivitySchedule(this,
                                                                                                                           transition.ToActivity.GatewaySplitJoinType);

                            child = activitySchedule.GetNextActivityListFromGateway(transition,
                                                                                    transition.ToActivity,
                                                                                    conditionKeyValuePair,
                                                                                    out resultType);
                        }
                        else
                        {
                            throw new XmlDefinitionException(string.Format("未知的节点类型:{0}", transition.ToActivity.NodeType.ToString()));
                        }

                        if (child != null)
                        {
                            root.Add(child);
                            resultType = NextActivityMatchedType.Successed;
                        }
                    }
                }
                else
                {
                    resultType = NextActivityMatchedType.NoneTransitionFilteredByCondition;
                }
                result = NextActivityMatchedResult.CreateNextActivityMatchedResultObject(resultType, root);
                return(result);
            }
            catch (System.Exception e)
            {
                throw new WfXpdlException(string.Format("解析流程定义文件发生异常,异常描述:{0}", e.Message), e);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 获取下一步节点列表,伴随条件信息
        /// </summary>
        /// <param name="currentActivity"></param>
        /// <param name="conditionKeyValuePair"></param>
        /// <returns></returns>
        internal NextActivityMatchedResult GetNextActivityList(Guid ProcessInstanceGUID,
                                                               ActivityEntity currentActivity,
                                                               ConditionKeyValuePair conditionKeyValuePair)
        {
            NextActivityMatchedResult result     = null;
            NextActivityMatchedType   resultType = NextActivityMatchedType.Unknown;

            //创建“下一步节点”的根节点
            NextActivityComponent root  = NextActivityComponentFactory.CreateNextActivityComponent();
            NextActivityComponent child = null;

            TransitionManager       tm             = new TransitionManager(this.ProcessEntity);
            List <TransitionEntity> transitionList = tm.GetForwardTransitionList(currentActivity.ActivityGUID,
                                                                                 conditionKeyValuePair).ToList();

            if (transitionList.Count > 0)
            {
                //遍历连线,获取下一步节点的列表
                foreach (TransitionEntity transition in transitionList)
                {
                    if (transition.ToActivity.NodeType == NodeTypeEnum.EndNode ||
                        transition.ToActivity.NodeType == NodeTypeEnum.TaskNode)
                    {
                        child = NextActivityComponentFactory.CreateNextActivityComponent(transition, transition.ToActivity);
                    }
                    else if (transition.ToActivity.NodeType == NodeTypeEnum.GatewayNode)
                    {
                        NextActivityScheduleBase activitySchedule = NextActivityScheduleFactory.CreateActivitySchedule(this.ProcessEntity,
                                                                                                                       transition.ToActivity.GatewaySplitJoinType);

                        child = activitySchedule.GetNextActivityListFromGateway(ProcessInstanceGUID,
                                                                                transition,
                                                                                transition.ToActivity,
                                                                                conditionKeyValuePair,
                                                                                out resultType);
                    }
                    else
                    {
                        throw new XmlDefinitionException(string.Format("未知的节点类型:{0}", transition.ToActivity.NodeType.ToString()));
                    }

                    if (child != null)
                    {
                        root.Add(child);
                        resultType = NextActivityMatchedType.Successed;
                    }
                }
            }
            else
            {
                resultType = NextActivityMatchedType.NoneTransitionFilteredByCondition;
            }
            result = NextActivityMatchedResult.CreateNextActivityMatchedResultObject(resultType, root);
            return(result);
        }