コード例 #1
0
        /// <summary>
        /// 根据Transition,获取下一步节点列表
        /// </summary>
        /// <param name="forwardTransition">转移实体</param>
        /// <param name="conditionKeyValuePair">条件kv对</param>
        /// <param name="resultType">结果类型</param>
        protected NextActivityComponent GetNextActivityListFromGatewayCore(TransitionEntity forwardTransition,

                                                                           out NextActivityMatchedType resultType)
        {
            NextActivityComponent child = null;

            if (XPDLHelper.IsSimpleComponentNode(forwardTransition.TargetActivity.ActivityType) == true)       //可流转简单类型节点
            {
                child      = NextActivityComponentFactory.CreateNextActivityComponent(forwardTransition, forwardTransition.TargetActivity);
                resultType = NextActivityMatchedType.Successed;
            }
            else if (forwardTransition.TargetActivity.ActivityType == ActivityTypeEnum.GatewayNode)
            {
                child = GetNextActivityListFromGateway(forwardTransition,
                                                       forwardTransition.TargetActivity,
                                                       out resultType);
            }
            else
            {
                resultType = NextActivityMatchedType.Failed;

                throw new XmlDefinitionException(string.Format("未知的节点类型:{0}", forwardTransition.TargetActivity.ActivityType.ToString()));
            }
            return(child);
        }
コード例 #2
0
 public override bool Remove(NextActivityComponent nextActivity)
 {
     bool isRemoved = nextActivityList.Remove(nextActivity);
     if (nextActivityList.Count == 0)
         hasChildren = false;
     return isRemoved;
 }
コード例 #3
0
        /// <summary>
        /// 创建下一步活动的节点
        /// </summary>
        /// <param name="activity"></param>
        /// <returns></returns>
        internal static NextActivityComponent CreateNextActivityComponent(TransitionEntity transition,
                                                                          ActivityEntity activity)
        {
            NextActivityComponent component = null;

            if (XPDLHelper.IsSimpleComponentNode(activity.ActivityType))           //可流转简单类型节点
            {
                string name = "单一节点";
                component = new NextActivityItem(name, transition, activity);
            }
            else if (activity.ActivityType == ActivityTypeEnum.SubProcessNode)
            {
                string name = "子流程节点";
                component = new NextActivityItem(name, transition, activity);
            }
            else
            {
                string name = string.Empty;
                if (activity.GatewayDirectionType == GatewayDirectionEnum.AndSplit)
                {
                    name = "必全选节点";
                }
                else
                {
                    name = "或多选节点";
                }

                component = new NextActivityGateway(name, transition, activity);
            }
            return(component);
        }
コード例 #4
0
ファイル: ProcessModel.cs プロジェクト: egman77/FapCore3.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);
            }
        }
コード例 #5
0
ファイル: ProcessModel.cs プロジェクト: egman77/FapCore3.0
        /// <summary>
        /// 添加子节点到网关节点
        /// </summary>
        /// <param name="newRoot">新的根节点</param>
        /// <param name="root">根节点</param>
        /// <param name="child">子节点</param>
        /// <returns>下一步活动节点</returns>
        private NextActivityComponent AddChildToNewGatewayComponent(NextActivityComponent newRoot,
                                                                    NextActivityComponent root,
                                                                    NextActivityComponent child)
        {
            if ((newRoot == null) && (child != null))
            {
                newRoot = NextActivityComponentFactory.CreateNextActivityComponent(root);
            }

            if ((newRoot != null) && (child != null))
            {
                newRoot.Add(child);
            }
            return(newRoot);
        }
コード例 #6
0
        /// <summary>
        /// 把子节点添加到网关路由节点,根据网关节点和子节点是否为空处理
        /// </summary>
        /// <param name="fromTransition">起始转移</param>
        /// <param name="currentGatewayActivity">当前网关节点</param>
        /// <param name="gatewayComponent">网关Component</param>
        /// <param name="child">子节点</param>
        /// <returns>下一步Component</returns>
        protected NextActivityComponent AddChildToGatewayComponent(TransitionEntity fromTransition,
                                                                   ActivityEntity currentGatewayActivity,
                                                                   NextActivityComponent gatewayComponent,
                                                                   NextActivityComponent child)
        {
            if ((gatewayComponent == null) && (child != null))
            {
                gatewayComponent = NextActivityComponentFactory.CreateNextActivityComponent(fromTransition, currentGatewayActivity);
            }

            if ((gatewayComponent != null) && (child != null))
            {
                gatewayComponent.Add(child);
            }

            return(gatewayComponent);
        }
コード例 #7
0
        /// <summary>
        /// 创建跳转节点(强制拉取跳转方式,后续节点状态可以强制拉取前置节点到当前节点[后续节点])
        /// </summary>
        /// <param name="sourceActivity">要拉取的节点</param>
        /// <param name="targetActivity">拉取到节点</param>
        /// <returns></returns>
        internal static NextActivityComponent CreateNextActivityComponent(ActivityEntity sourceActivity,
                                                                          ActivityEntity targetActivity)
        {
            NextActivityComponent component = null;

            if (XPDLHelper.IsSimpleComponentNode(sourceActivity.ActivityType) == true)       //可流转简单类型节点
            {
                string name       = "单一节点";
                var    transition = TransitionBuilder.CreateJumpforwardEmptyTransition(sourceActivity, targetActivity);

                component = new NextActivityItem(name, transition, sourceActivity);     //强制拉取跳转类型的transition 为空类型
            }
            else
            {
                throw new ApplicationException(string.Format("不能跳转到其它非任务类型的节点!当前节点:{0}",
                                                             sourceActivity.ActivityType));
            }
            return(component);
        }
コード例 #8
0
ファイル: ProcessModel.cs プロジェクト: egman77/FapCore3.0
        /// <summary>
        /// 获取下一步活动节点树,供流转界面使用
        /// </summary>
        /// <param name="currentActivityGUID"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        //public IList<NodeView> GetNextActivityTree(int processInstanceID,
        //    string currentActivityID)
        //{
        //    var treeNodeList = new List<NodeView>();
        //    var activity = GetActivity(currentActivityID);

        //    //判断有没有指定的跳转节点信息
        //    if (activity.ActivityTypeDetail.SkipInfo != null
        //        && activity.ActivityTypeDetail.SkipInfo.IsSkip == true)
        //    {
        //        //获取跳转节点信息
        //        var skipto = activity.ActivityTypeDetail.SkipInfo.Skipto;
        //        var skiptoActivity = GetActivity(skipto);

        //        treeNodeList.Add(new NodeView
        //        {
        //            ActivityId = skiptoActivity.ActivityID,
        //            ActivityName = skiptoActivity.ActivityName,
        //            ActivityCode = skiptoActivity.ActivityCode,

        //            Participants = GetActivityParticipants(skiptoActivity.ActivityID),
        //            //ReceiverType = skiptoActivity.Transition.Receiver.ReceiverType
        //            IsSkipTo = true
        //        });
        //    }
        //    else
        //    {
        //        //Transiton方式的流转定义
        //        var nextSteps = GetNextActivityList(activity.ActivityID);

        //        foreach (var child in nextSteps.Root)
        //        {
        //            if (child.HasChildren)
        //            {
        //                Tranverse(child, treeNodeList);
        //            }
        //            else
        //            {
        //                treeNodeList.Add(new NodeView
        //                {
        //                    ActivityId = child.Activity.ActivityID,
        //                    ActivityName = child.Activity.ActivityName,
        //                    ActivityCode = child.Activity.ActivityCode,

        //                    Participants = GetActivityParticipants(child.Activity.ActivityID),

        //                });
        //            }
        //        }
        //    }

        //    return treeNodeList;
        //}

        /// <summary>
        /// 迭代遍历
        /// </summary>
        /// <param name="root"></param>
        /// <param name="treeNodeList"></param>
        private void Tranverse(NextActivityComponent root, IList <NodeView> treeNodeList)
        {
            foreach (var child in root)
            {
                if (child.HasChildren)
                {
                    Tranverse(child, treeNodeList);
                }
                else
                {
                    treeNodeList.Add(new NodeView
                    {
                        ActivityId   = child.Activity.ActivityID,
                        ActivityName = child.Activity.ActivityName,
                        ActivityCode = child.Activity.ActivityCode,

                        Participants = GetActivityParticipants(child.Activity.ActivityID),
                    });
                }
            }
        }
コード例 #9
0
        /// <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,
                                                                               out NextActivityMatchedType resultType)
        {
            NextActivityComponent child            = null;
            NextActivityComponent gatewayComponent = null;

            resultType = NextActivityMatchedType.Unknown;

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

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

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

            return(gatewayComponent);
        }
コード例 #10
0
 public override void Add(NextActivityComponent nextActivity)
 {
     nextActivityList.Add(nextActivity);
     if (hasChildren == false)
         hasChildren = true;
 }
コード例 #11
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);
        }
コード例 #12
0
 private NextActivityMatchedResult(NextActivityMatchedType matchedType,
                                   NextActivityComponent root)
 {
     MatchedType = matchedType;
     Root        = root;
 }
コード例 #13
0
        /// <summary>
        /// 根据现有下一步节点列表,创建新的下一步节点列表对象
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        internal static NextActivityComponent CreateNextActivityComponent(NextActivityComponent c)
        {
            NextActivityComponent newComp = CreateNextActivityComponent(c.Transition, c.Activity);

            return(newComp);
        }
コード例 #14
0
 public virtual bool Remove(NextActivityComponent nextActivity)
 {
     throw new InvalidOperationException("非组合节点,无子项可以删除!");
 }
コード例 #15
0
 public virtual void Add(NextActivityComponent nextActivity)
 {
     throw new InvalidOperationException("非组合节点,不能添加子项!");
 }
コード例 #16
0
        /// <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,
                                                                               out NextActivityMatchedType resultType)
        {
            NextActivityComponent child            = null;
            NextActivityComponent gatewayComponent = null;

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

            if (currentGatewayActivity.GatewayDirectionType == GatewayDirectionEnum.AndSplit)
            {
                //判读连线上的条件是否都满足,如果都满足才可以取出后续节点列表
                //获取AndSplit的每一条后续连线上的To节点
                foreach (TransitionEntity transition in transitionList)
                {
                    child = GetNextActivityListFromGatewayCore(transition,
                                                               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)
                {
                    child = GetNextActivityListFromGatewayCore(transition,
                                                               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)
                {
                    child = GetNextActivityListFromGatewayCore(transition,
                                                               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);
        }