예제 #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);
            }
        }
예제 #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);
        }
예제 #3
0
        /// <summary>
        /// 获取下一步节点列表(伴随条件和资源)
        /// </summary>
        /// <param name="currentActivity"></param>
        /// <param name="conditionKeyValuePair"></param>
        /// <returns></returns>
        internal NextActivityMatchedResult GetNextActivityList(ActivityEntity currentActivity,
                                                               IDictionary <string, string> conditionKeyValuePair,
                                                               ActivityResource activityResource,
                                                               Expression <Func <ActivityResource, ActivityEntity, bool> > expression)
        {
            NextActivityComponent newRoot = NextActivityComponentFactory.CreateNextActivityComponent();

            //先获取未加运行时表达式过滤的下一步节点列表
            NextActivityMatchedResult result = GetNextActivityList(currentActivity,
                                                                   conditionKeyValuePair);

            foreach (NextActivityComponent c in result.Root)
            {
                if (c.HasChildren)
                {
                    NextActivityComponent child = GetNextActivityListByExpressionRecurisivly(c, activityResource, expression);
                    if (child != null)
                    {
                        newRoot.Add(child);
                    }
                }
                else
                {
                    if (expression.Compile().Invoke(activityResource, c.Activity))
                    {
                        newRoot.Add(c);
                    }
                }
            }

            NextActivityMatchedResult newResult = null;

            if (newRoot.HasChildren)
            {
                newResult = NextActivityMatchedResult.CreateNextActivityMatchedResultObject(result.MatchedType, newRoot);
            }
            else
            {
                newResult = NextActivityMatchedResult.CreateNextActivityMatchedResultObject(NextActivityMatchedType.NoneTransitionFilteredByCondition,
                                                                                            newRoot);
            }
            return(newResult);
        }
예제 #4
0
        /// <summary>
        /// 创建方法
        /// </summary>
        /// <param name="scheduleStatus"></param>
        /// <param name="root"></param>
        /// <returns></returns>
        internal static NextActivityMatchedResult CreateNextActivityMatchedResultObject(NextActivityMatchedType matchedType,
                                                                                        NextActivityComponent root)
        {
            NextActivityMatchedResult result = new NextActivityMatchedResult(matchedType, root);

            switch (matchedType)
            {
            case NextActivityMatchedType.Unknown:
                result.Message = NextActivityMatchedResult.Unkonwn;
                break;

            case NextActivityMatchedType.Failed:
                result.Message = NextActivityMatchedResult.Exceptional;
                break;

            case NextActivityMatchedType.Successed:
                result.Message = NextActivityMatchedResult.Successed;
                break;

            case NextActivityMatchedType.NoneTransitionFilteredByCondition:
                result.Message = NextActivityMatchedResult.NoneTransitionFilteredByCondition;
                break;

            case NextActivityMatchedType.WaitingForSplitting:
                result.Message = NextActivityMatchedResult.NoneTransitionAsBeingFiltered;
                break;

            case NextActivityMatchedType.NoneTransitionMatchedToSplit:
                result.Message = NextActivityMatchedResult.NoneWayMatchedToSplit;
                break;

            case NextActivityMatchedType.WaitingForOthersJoin:
                result.Message = NextActivityMatchedResult.WaitingForOthersJoin;
                break;

            case NextActivityMatchedType.NotMadeItselfToJoin:
                result.Message = NextActivityMatchedResult.NotMadeItselfToJoin;
                break;
            }
            return(result);
        }