Example #1
0
 /// <summary>
 /// 根据网关类型获取下一步节点列表的抽象方法
 /// </summary>
 /// <param name="processInstanceGUID"></param>
 /// <param name="transition"></param>
 /// <param name="activity"></param>
 /// <param name="conditionKeyValuePair"></param>
 /// <returns></returns>
 internal abstract NextActivityComponent GetNextActivityListFromGateway(TransitionEntity transition,
                                                                        ActivityEntity activity,
                                                                        IDictionary <string, string> conditionKeyValuePair,
                                                                        out NextActivityMatchedType scheduleStatus);
Example #2
0
        /// <summary>
        /// 获取下一步节点列表
        /// </summary>
        /// <param name="processInstanceGUID"></param>
        /// <param name="fromTransition"></param>
        /// <param name="currentGatewayActivity"></param>
        /// <param name="conditionKeyValuePair"></param>
        /// <returns></returns>
        internal override NextActivityComponent GetNextActivityListFromGateway(TransitionEntity fromTransition,
                                                                               ActivityEntity currentGatewayActivity,
                                                                               IDictionary <string, string> conditionKeyValuePair,
                                                                               out NextActivityMatchedType resultType)
        {
            NextActivityComponent child            = null;
            NextActivityComponent gatewayComponent = null;

            resultType = NextActivityMatchedType.Unknown;
            var transitionList = this.ProcessModel.GetForwardTransitionList(currentGatewayActivity.ActivityGUID).ToList();

            if (currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.AndSplit)
            {
                //判读连线上的条件是否都满足,如果都满足才可以取出后续节点列表
                bool isCheckedOk = base.ProcessModel.CheckAndSplitOccurrenceCondition(transitionList, conditionKeyValuePair);
                if (isCheckedOk)
                {
                    //获取AndSplit的每一条后续连线上的To节点
                    foreach (TransitionEntity transition in transitionList)
                    {
                        child = GetNextActivityListFromGatewayCore(transition,
                                                                   conditionKeyValuePair,
                                                                   out resultType);

                        gatewayComponent = AddChildToGatewayComponent(fromTransition, currentGatewayActivity, gatewayComponent, child);
                    }
                }

                if (gatewayComponent == null)
                {
                    resultType = NextActivityMatchedType.WaitingForSplitting;
                }
            }
            else if (currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.OrSplit)
            {
                //获取OrSplit的,满足条件的后续连线上的To节点
                foreach (TransitionEntity transition in transitionList)
                {
                    bool isValidTransition = base.ProcessModel.IsValidTransition(transition, conditionKeyValuePair);
                    if (isValidTransition)
                    {
                        child = GetNextActivityListFromGatewayCore(transition,
                                                                   conditionKeyValuePair,
                                                                   out resultType);

                        gatewayComponent = AddChildToGatewayComponent(fromTransition, currentGatewayActivity, gatewayComponent, child);
                    }

                    if (gatewayComponent == null)
                    {
                        resultType = NextActivityMatchedType.NoneTransitionMatchedToSplit;
                    }
                }
            }
            else if (currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.XOrSplit)
            {
                //按连线定义的优先级排序
                transitionList.Sort(new TransitionPriorityCompare());

                //获取XOrSplit的,第一条满足条件的后续连线上的To节点
                foreach (TransitionEntity transition in transitionList)
                {
                    bool isValidTransitionXOr = base.ProcessModel.IsValidTransition(transition, conditionKeyValuePair);
                    if (isValidTransitionXOr)
                    {
                        child = GetNextActivityListFromGatewayCore(transition,
                                                                   conditionKeyValuePair,
                                                                   out resultType);

                        gatewayComponent = AddChildToGatewayComponent(fromTransition, currentGatewayActivity, gatewayComponent, child);
                        //退出循环
                        break;
                    }
                }

                if (gatewayComponent == null)
                {
                    resultType = NextActivityMatchedType.NoneTransitionMatchedToSplit;
                }
            }
            else if (currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.ComplexSplit)
            {
                resultType = NextActivityMatchedType.Failed;
                throw new Exception("ComplexSplit 没有具体实现!");
            }
            else
            {
                resultType = NextActivityMatchedType.Failed;
                throw new Exception("Split 分支节点的类型不明确!");
            }

            return(gatewayComponent);
        }