Beispiel #1
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);
        }
Beispiel #2
0
        /// <summary>
        /// 递归获取满足条件的下一步节点列表
        /// </summary>
        /// <param name="root"></param>
        /// <param name="activityResource"></param>
        /// <param name="expression"></param>
        /// <returns></returns>
        private NextActivityComponent GetNextActivityListByExpressionRecurisivly(NextActivityComponent root,
                                                                                 ActivityResource activityResource,
                                                                                 Expression <Func <ActivityResource, ActivityEntity, bool> > expression)
        {
            NextActivityComponent r1 = null;

            foreach (NextActivityComponent c in root)
            {
                if (c.HasChildren)
                {
                    NextActivityComponent child = GetNextActivityListByExpressionRecurisivly(c, activityResource, expression);
                    r1 = AddChildToNewGatewayComponent(r1, c, child);
                }
                else
                {
                    if (expression.Compile().Invoke(activityResource, c.Activity))
                    {
                        r1 = AddChildToNewGatewayComponent(r1, root, c);
                    }
                }
            }
            return(r1);
        }