Esempio n. 1
0
        /// <summary>
        /// 获取上一步节点树
        /// </summary>
        /// <param name="runningNode">运行活动</param>
        /// <param name="hasGatewayPassed">是否经过网关</param>
        /// <returns>上一步步骤列表</returns>
        private IList <NodeView> GetPreviousActivityTree(ActivityInstanceEntity runningNode, out Boolean hasGatewayPassed)
        {
            var aim = new ActivityInstanceManager();

            //获取前置节点列表
            var processInstance      = (new ProcessInstanceManager()).GetById(runningNode.ProcessInstanceID);
            var processModel         = ProcessModelFactory.Create(processInstance.ProcessGUID, processInstance.Version);
            var previousActivityList = GetPreviousActivityList(runningNode, processModel, out hasGatewayPassed);

            //封装返回结果集合
            var nodeList = new List <NodeView>();

            foreach (var activity in previousActivityList)
            {
                //判断是否是会签节点
                if (processModel.IsMINode(activity) == true)
                {
                    //获取上一步节点的运行记录
                    if (processModel.IsMIParallel(activity) == true)
                    {
                        //并行会签节点读取所有完成的子节点
                        var activityInstanceList = aim.GetPreviousParallelMultipleInstanceListCompleted(runningNode, activity.ActivityGUID);
                        foreach (var ai in activityInstanceList)
                        {
                            AppendNodeViewList(nodeList, activity, ai.EndedByUserID, ai.EndedByUserName);
                        }
                    }
                    else if (processModel.IsMISequence(activity) == true)
                    {
                        if (processModel.IsTaskNode(runningNode) == true)
                        {
                            //当前节点是任务节点
                            //退回到会签节点的最后一步
                            var activityInstance = aim.GetPreviousActivityInstanceSimple(runningNode, activity.ActivityGUID);
                            if (activityInstance != null)
                            {
                                AppendNodeViewList(nodeList, activity, activityInstance.EndedByUserID, activityInstance.EndedByUserName);
                            }
                        }
                        else if (processModel.IsMISequence(activity) == true)
                        {
                            //串行会签节点按照CompleteOrder顺序递减读取上一步
                            var previousAdjacentBrotherNode = GetPreviousOfMultipleInstanceNode(
                                runningNode.MIHostActivityInstanceID.Value,
                                runningNode.ID,
                                runningNode.CompleteOrder.Value);
                            if (previousAdjacentBrotherNode != null)
                            {
                                AppendNodeViewList(nodeList, activity, previousAdjacentBrotherNode.EndedByUserID, previousAdjacentBrotherNode.EndedByUserName);
                            }
                        }
                    }
                }
                else
                {
                    if (hasGatewayPassed == true)
                    {
                        //跨越网关类型
                        var activityInstanceList = aim.GetActivityInstanceListCompletedSimple(runningNode.ProcessInstanceID, activity.ActivityGUID);
                        foreach (var a in activityInstanceList)
                        {
                            AppendNodeViewList(nodeList, activity, a.EndedByUserID, a.EndedByUserName);
                        }
                    }
                    else
                    {
                        //普通任务节点
                        var activityInstance = aim.GetPreviousActivityInstanceSimple(runningNode, activity.ActivityGUID);
                        if (activityInstance != null)
                        {
                            AppendNodeViewList(nodeList, activity, activityInstance.EndedByUserID, activityInstance.EndedByUserName);
                        }
                    }
                }
            }
            return(nodeList);
        }