/// <summary>
        /// 根据Transition,获取下一步节点列表
        /// </summary>
        /// <param name="nextActivityList"></param>
        /// <param name="processInstanceID"></param>
        /// <param name="currentGatewayActivity"></param>
        /// <param name="forwardTransition"></param>
        /// <param name="conditionKeyValuePair"></param>
        protected NextActivityComponent GetNextActivityListFromGatewayCore(TransitionEntity forwardTransition,
            IDictionary<string, string> conditionKeyValuePair,
            out NextActivityMatchedType resultType)
        {
            NextActivityComponent child = null;
            if (forwardTransition.ToActivity.ActivityType == ActivityTypeEnum.TaskNode
                || forwardTransition.ToActivity.ActivityType == ActivityTypeEnum.EndNode)
            {
                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;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取下一步节点列表
        /// </summary>
        /// <param name="fromTransition">起始转移</param>
        /// <param name="currentGatewayActivity">当前节点</param>
        /// <param name="conditionKeyValuePair">条件对</param>
        /// <param name="resultType">结果类型</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;

            //直接取出下步列表,运行时再根据条件执行
            List <TransitionEntity> transitionList = base.ProcessModel.GetForwardTransitionList(currentGatewayActivity.ActivityGUID,
                                                                                                conditionKeyValuePair).ToList();

            foreach (TransitionEntity transition in transitionList)
            {
                child = GetNextActivityListFromGatewayCore(transition,
                                                           conditionKeyValuePair,
                                                           out resultType);

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

            return(gatewayComponent);
        }
 /// <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;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取下一步节点列表
        /// </summary>
        /// <param name="fromTransition">起始转移</param>
        /// <param name="currentGatewayActivity">当前节点</param>
        /// <param name="conditionKeyValuePair">条件对</param>
        /// <param name="session">会话</param>
        /// <param name="resultType">结果类型</param>
        /// <returns>下一步组件类型</returns>
        internal override NextActivityComponent GetNextActivityListFromGateway(TransitionEntity fromTransition,
                                                                               ActivityEntity currentGatewayActivity,
                                                                               IDictionary <string, string> conditionKeyValuePair,
                                                                               IDbSession session,
                                                                               out NextActivityMatchedType resultType)
        {
            NextActivityComponent child            = null;
            NextActivityComponent gatewayComponent = null;

            resultType = NextActivityMatchedType.Unknown;

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

            foreach (TransitionEntity transition in transitionList)
            {
                bool isValidTransition = base.ProcessModel.IsValidTransition(transition, conditionKeyValuePair);
                if (isValidTransition)
                {
                    child = GetNextActivityListFromGatewayCore(transition,
                                                               conditionKeyValuePair,
                                                               session,
                                                               out resultType);

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

            if (gatewayComponent == null)
            {
                resultType = NextActivityMatchedType.NoneTransitionFilteredByCondition;
            }
            return(gatewayComponent);
        }
        /// <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="currentActivity"></param>
        /// <param name="conditionKeyValuePair"></param>
        /// <returns></returns>
        internal NextActivityMatchedResult GetNextActivityList(string currentActivityGUID,
                                                               IDictionary <string, string> conditionKeyValuePair = null)
        {
            try
            {
                NextActivityMatchedResult result     = null;
                NextActivityMatchedType   resultType = NextActivityMatchedType.Unknown;

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

                if (transitionList.Count > 0)
                {
                    //遍历连线,获取下一步节点的列表
                    foreach (TransitionEntity transition in transitionList)
                    {
                        if (transition.ToActivity.ActivityType == ActivityTypeEnum.EndNode ||
                            transition.ToActivity.ActivityType == ActivityTypeEnum.TaskNode ||
                            transition.ToActivity.ActivityType == ActivityTypeEnum.SubProcessNode)
                        {
                            child = NextActivityComponentFactory.CreateNextActivityComponent(transition, transition.ToActivity);
                        }
                        else if (transition.ToActivity.ActivityType == ActivityTypeEnum.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.ActivityType.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);
            }
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取下一步节点列表,满足运行时条件信息
        /// </summary>
        /// <param name="currentActivityGUID"></param>
        /// <returns></returns>
        public NextActivityMatchedResult GetNextActivityList(string currentActivityID)
        {
            try
            {
                NextActivityMatchedResult result     = null;
                NextActivityMatchedType   resultType = NextActivityMatchedType.Unknown;

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

                if (transitionList.Count > 0)
                {
                    //遍历连线,获取下一步节点的列表
                    foreach (TransitionEntity transition in transitionList)
                    {
                        if (XPDLHelper.IsWorkItem(transition.TargetActivity.ActivityType))        //可流转简单类型节点 || 子流程节点
                        {
                            child = NextActivityComponentFactory.CreateNextActivityComponent(transition, transition.TargetActivity);
                        }
                        else if (transition.TargetActivity.ActivityType == ActivityTypeEnum.GatewayNode)
                        {
                            NextActivityScheduleBase activitySchedule = NextActivityScheduleFactory.CreateActivitySchedule(this as IProcessModel,
                                                                                                                           transition.TargetActivity.GatewaySplitJoinType);

                            child = activitySchedule.GetNextActivityListFromGateway(transition,
                                                                                    transition.TargetActivity,
                                                                                    out resultType);
                        }
                        else
                        {
                            throw new XmlDefinitionException(string.Format("未知的节点类型:{0}", transition.TargetActivity.ActivityType.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);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 根据Transition,获取下一步节点列表
        /// </summary>
        /// <param name="forwardTransition">转移实体</param>
        /// <param name="conditionKeyValuePair">条件kv对</param>
        /// <param name="session">会话</param>
        /// <param name="resultType">结果类型</param>
        protected NextActivityComponent GetNextActivityListFromGatewayCore(TransitionEntity forwardTransition,
                                                                           IDictionary <string, string> conditionKeyValuePair,
                                                                           IDbSession session,
                                                                           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,
                                                       session,
                                                       out resultType);
            }
            else if (forwardTransition.ToActivity.ActivityType == ActivityTypeEnum.IntermediateNode)
            {
                if (forwardTransition.ToActivity.ActivityTypeDetail.TriggerType == TriggerTypeEnum.Timer)
                {
                    child      = NextActivityComponentFactory.CreateNextActivityComponent(forwardTransition, forwardTransition.ToActivity);
                    resultType = NextActivityMatchedType.Successed;
                }
                else
                {
                    NextActivityScheduleBase activitySchedule = NextActivityScheduleFactory.CreateActivityScheduleIntermediate(this.ProcessModel);
                    child = activitySchedule.GetNextActivityListFromGateway(forwardTransition,
                                                                            forwardTransition.ToActivity,
                                                                            conditionKeyValuePair,
                                                                            session,
                                                                            out resultType);
                }
            }
            else if (forwardTransition.ToActivity.ActivityType == ActivityTypeEnum.ServiceNode)
            {
                NextActivityScheduleBase activitySchedule = NextActivityScheduleFactory.CreateActivityScheduleIntermediate(this.ProcessModel);
                child = activitySchedule.GetNextActivityListFromGateway(forwardTransition,
                                                                        forwardTransition.ToActivity,
                                                                        conditionKeyValuePair,
                                                                        session,
                                                                        out resultType);
            }
            else
            {
                resultType = NextActivityMatchedType.Failed;

                throw new XmlDefinitionException(LocalizeHelper.GetEngineMessage("nextactivityschedulebase.unknownnodetype", forwardTransition.ToActivity.ActivityType.ToString()));
            }
            return(child);
        }
        /// <summary>
        /// 获取下一步节点列表
        /// </summary>
        /// <param name="processInstanceID"></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;

            //直接取出下步列表,运行时再根据条件执行
            List<TransitionEntity> transitionList = base.ProcessModel.GetForwardTransitionList(currentGatewayActivity.ActivityGUID).ToList();
            foreach (TransitionEntity transition in transitionList)
            {
                child = GetNextActivityListFromGatewayCore(transition,
                    conditionKeyValuePair,
                    out resultType);

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

            return gatewayComponent;
        }
        /// <summary>
        /// 获取下一步节点列表
        /// </summary>
        /// <param name="processInstanceID"></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);
        }
 /// <summary>
 /// 根据网关类型获取下一步节点列表的抽象方法
 /// </summary>
 /// <param name="transition">转移</param>
 /// <param name="activity">活动</param>
 /// <param name="conditionKeyValuePair">条件kv对</param>
 /// <param name="scheduleStatus">匹配类型</param>
 /// <returns></returns>
 internal abstract NextActivityComponent GetNextActivityListFromGateway(TransitionEntity transition,
                                                                        ActivityEntity activity,
                                                                        IDictionary <string, string> conditionKeyValuePair,
                                                                        out NextActivityMatchedType scheduleStatus);
Ejemplo n.º 13
0
 /// <summary>
 /// 根据网关类型获取下一步节点列表的抽象方法
 /// </summary>
 /// <param name="transition">转移</param>
 /// <param name="activity">活动</param>
 /// <param name="conditionKeyValuePair">条件kv对</param>
 /// <param name="scheduleStatus">匹配类型</param>
 /// <returns></returns>
 internal abstract NextActivityComponent GetNextActivityListFromGateway(TransitionEntity transition,
                                                                        ActivityEntity activity,
                                                                        out NextActivityMatchedType scheduleStatus);
Ejemplo n.º 14
0
 private NextActivityMatchedResult(NextActivityMatchedType matchedType,
                                   NextActivityComponent root)
 {
     MatchedType = matchedType;
     Root        = root;
 }
Ejemplo n.º 15
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);
        }
 private NextActivityMatchedResult(NextActivityMatchedType matchedType,
     NextActivityComponent root)
 {
     MatchedType = matchedType;
     Root = root;
 }
Ejemplo n.º 17
0
        /// <summary>
        /// 创建方法
        /// </summary>
        /// <param name="matchedType">匹配类型</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 = LocalizeHelper.GetEngineMessage("nextactivitymatchedresult.Unkonwn");
                break;

            case NextActivityMatchedType.Failed:
                result.Message = LocalizeHelper.GetEngineMessage("nextactivitymatchedresult.Exceptional");
                break;

            case NextActivityMatchedType.Successed:
                result.Message = LocalizeHelper.GetEngineMessage("nextactivitymatchedresult.Successed");
                break;

            case NextActivityMatchedType.NoneTransitionFilteredByCondition:
                result.Message = LocalizeHelper.GetEngineMessage("nextactivitymatchedresult.NoneTransitionFilteredByCondition");
                break;

            case NextActivityMatchedType.WaitingForOtherSplitting:
                result.Message = LocalizeHelper.GetEngineMessage("nextactivitymatchedresult.WaitingForOtherSplitting");
                break;

            case NextActivityMatchedType.WaitingForAgreedOrRefused:
                result.Message = LocalizeHelper.GetEngineMessage("nextactivitymatchedresult.WaitingForAgreedOrRefused");
                break;

            case NextActivityMatchedType.NoneTransitionMatchedToSplit:
                result.Message = LocalizeHelper.GetEngineMessage("nextactivitymatchedresult.NoneWayMatchedToSplit");
                break;

            case NextActivityMatchedType.FailedPassRateOfMulitipleInstance:
                result.Message = LocalizeHelper.GetEngineMessage("nextactivitymatchedresult.FailedPassRateOfMulitipleInstance");
                break;

            case NextActivityMatchedType.WaitingForOthersJoin:
                result.Message = LocalizeHelper.GetEngineMessage("nextactivitymatchedresult.WaitingForOthersJoin");
                break;

            case NextActivityMatchedType.NotMadeItselfToJoin:
                result.Message = LocalizeHelper.GetEngineMessage("nextactivitymatchedresult.NotMadeItselfToJoin");
                break;
            }
            return(result);
        }
Ejemplo n.º 18
0
 /// <summary>
 /// 根据网关类型获取下一步节点列表的抽象方法
 /// </summary>
 /// <param name="fromTransition">转移</param>
 /// <param name="currentGatewayActivity">活动</param>
 /// <param name="conditionKeyValuePair">条件kv对</param>
 /// <param name="resultType">匹配类型</param>
 /// <returns></returns>
 internal abstract NextActivityComponent GetNextActivityListFromGateway(TransitionEntity fromTransition,
                                                                        ActivityEntity currentGatewayActivity,
                                                                        IDictionary <string, string> conditionKeyValuePair,
                                                                        out NextActivityMatchedType resultType);
        /// <summary>
        /// 获取下一步节点列表
        /// </summary>
        /// <param name="fromTransition">起始转移</param>
        /// <param name="currentGatewayActivity">当前节点</param>
        /// <param name="conditionKeyValuePair">条件</param>
        /// <param name="session">会话</param>
        /// <param name="resultType">结果类型</param>
        /// <returns>返回节点</returns>
        internal override NextActivityComponent GetNextActivityListFromGateway(TransitionEntity fromTransition,
                                                                               ActivityEntity currentGatewayActivity,
                                                                               IDictionary <string, string> conditionKeyValuePair,
                                                                               IDbSession session,
                                                                               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 ||
                currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.AndSplitMI)
            {
                //获取AndSplit的每一条后续连线上的To节点
                foreach (TransitionEntity transition in transitionList)
                {
                    child = GetNextActivityListFromGatewayCore(transition,
                                                               conditionKeyValuePair,
                                                               session,
                                                               out resultType);

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

                if (gatewayComponent == null)
                {
                    resultType = NextActivityMatchedType.WaitingForOtherSplitting;
                }
            }
            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,
                                                                   session,
                                                                   out resultType);

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

                if (gatewayComponent == null)
                {
                    //没有分支满足,则选择默认分支流转
                    var defaultTransition = transitionList.Find(t => t.GroupBehaviours != null && t.GroupBehaviours.DefaultBranch == true);
                    if (defaultTransition != null)
                    {
                        child = GetNextActivityListFromGatewayCore(defaultTransition,
                                                                   conditionKeyValuePair,
                                                                   session,
                                                                   out resultType);

                        gatewayComponent = AddChildToGatewayComponent(fromTransition, currentGatewayActivity, gatewayComponent, child);
                    }
                    else
                    {
                        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,
                                                                   session,
                                                                   out resultType);

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

                if (gatewayComponent == null)
                {
                    resultType = NextActivityMatchedType.NoneTransitionMatchedToSplit;
                }
            }
            else if (currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.ApprovalOrSplit)
            {
                var fromActivity     = fromTransition.FromActivity;
                var aim              = new ActivityInstanceManager();
                var nodePassedResult = aim.CheckActivityInstancePassedResult(this.TaskID, session);

                //根据节点通过类型连线类型
                if (nodePassedResult.NodePassedType == NodePassedTypeEnum.Passed)
                {
                    transitionList = transitionList.Where <TransitionEntity>(t => t.GroupBehaviours.Approval == (short)ApprovalStatusEnum.Agreed).ToList();
                }
                else if (nodePassedResult.NodePassedType == NodePassedTypeEnum.NotPassed)
                {
                    transitionList = transitionList.Where <TransitionEntity>(t => t.GroupBehaviours.Approval == (short)ApprovalStatusEnum.Refused).ToList();
                }
                else if (nodePassedResult.NodePassedType == NodePassedTypeEnum.NeedToBeMoreApproved)
                {
                    transitionList = transitionList.Where <TransitionEntity>(t => t.GroupBehaviours.Approval == (short)ApprovalStatusEnum.Agreed).ToList();
                }
                else
                {
                    transitionList = null;
                    resultType     = NextActivityMatchedType.WaitingForAgreedOrRefused;
                }

                //获取有效的下一步节点
                if (transitionList != null)
                {
                    foreach (TransitionEntity transition in transitionList)
                    {
                        child = GetNextActivityListFromGatewayCore(transition,
                                                                   conditionKeyValuePair,
                                                                   session,
                                                                   out resultType);

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

                        if (gatewayComponent == null)
                        {
                            resultType = NextActivityMatchedType.NoneTransitionMatchedToSplit;
                        }
                    }
                }
            }
            else
            {
                resultType = NextActivityMatchedType.Failed;
                throw new WfXpdlException(LocalizeHelper.GetEngineMessage("nextactivityschedulesplit.error",
                                                                          currentGatewayActivity.GatewayDirectionType.ToString()));
            }
            return(gatewayComponent);
        }
 /// <summary>
 /// 根据网关类型获取下一步节点列表的抽象方法
 /// </summary>
 /// <param name="processInstanceID"></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);
        /// <summary>
        /// 获取下一步节点列表
        /// </summary>
        /// <param name="processInstanceID"></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;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 获取下一步节点列表
        /// </summary>
        /// <param name="fromTransition">起始转移</param>
        /// <param name="currentGatewayActivity">当前节点</param>
        /// <param name="conditionKeyValuePair">条件</param>
        /// <param name="resultType">结果类型</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 ||
                currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.AndSplitMI)
            {
                //获取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
            {
                resultType = NextActivityMatchedType.Failed;
                throw new WfXpdlException(LocalizeHelper.GetEngineMessage("nextactivityschedulesplit.error",
                                                                          currentGatewayActivity.GatewayDirectionType.ToString()));
            }
            return(gatewayComponent);
        }