internal ActivityInstanceEntity GetRunningNodeOfMine(WfAppRunner runner, out TaskViewEntity taskView)
        {
            var appInstanceID = runner.AppInstanceID;
            var processGUID   = runner.ProcessGUID;
            var taskID        = runner.TaskID;

            taskView = null;
            ActivityInstanceEntity activityInstance = null;

            //如果流程在运行状态,则返回运行时信息
            var tm = new TaskManager();

            var aim          = new ActivityInstanceManager();
            var activityList = aim.GetRunningActivityInstanceList(runner).ToList();

            if ((activityList != null) && (activityList.Count == 1))
            {
                activityInstance = activityList[0];
                taskView         = tm.GetTaskOfMine(activityInstance.ID, runner.UserID);
            }
            else if (activityList.Count > 0)
            {
                if (runner.TaskID != null && runner.TaskID.Value != 0)
                {
                    taskView = tm.GetTaskView(taskID.Value);

                    foreach (var ai in activityList)
                    {
                        if (ai.ID == taskView.ActivityInstanceID)
                        {
                            activityInstance = ai;
                            break;
                        }
                    }
                }
                else
                {
                    //当前流程运行节点不唯一
                    var e = new WorkflowException("当前流程有多个运行节点,但没有TaskID传入,状态异常!");
                    LogManager.RecordLog("获取当前运行节点信息异常", LogEventType.Exception, LogPriority.Normal, null, e);
                    throw e;
                }
            }
            else
            {
                //当前没有运行状态的节点存在,流程不存在,或者已经结束或取消
                var e = new WorkflowException("当前流程没有运行节点,状态异常!");
                LogManager.RecordLog("获取当前运行节点信息异常", LogEventType.Exception, LogPriority.Normal, null, e);
                throw e;
            }
            return(activityInstance);
        }
        internal ActivityInstanceEntity GetRunningNodeOfMine(WfAppRunner runner, out TaskViewEntity taskView)
        {
            var appInstanceID = runner.AppInstanceID;
            var processGUID = runner.ProcessGUID;
            var taskID = runner.TaskID;

            taskView = null;
            ActivityInstanceEntity activityInstance = null;

            //如果流程在运行状态,则返回运行时信息
            var tm = new TaskManager();

            var aim = new ActivityInstanceManager();
            var activityList = aim.GetRunningActivityInstanceList(runner).ToList();

            if ((activityList != null) && (activityList.Count == 1))
            {
                activityInstance = activityList[0];
                taskView = tm.GetTaskOfMine(activityInstance.ID, runner.UserID);
            }
            else if (activityList.Count > 0)
            {
                if (runner.TaskID != null && runner.TaskID.Value != 0)
                {
                    taskView = tm.GetTaskView(taskID.Value);

                    foreach (var ai in activityList)
                    {
                        if (ai.ID == taskView.ActivityInstanceID)
                        {
                            activityInstance = ai;
                            break;
                        }
                    }
                }
                else
                {
                    //当前流程运行节点不唯一
                    var e = new WorkflowException("当前流程有多个运行节点,但没有TaskID传入,状态异常!");
                    LogManager.RecordLog("获取当前运行节点信息异常", LogEventType.Exception, LogPriority.Normal, null, e);
                    throw e;
                }
            }
            else
            {
                //当前没有运行状态的节点存在,流程不存在,或者已经结束或取消
                var e = new WorkflowException("当前流程没有运行节点,状态异常!");
                LogManager.RecordLog("获取当前运行节点信息异常", LogEventType.Exception, LogPriority.Normal, null, e);
                throw e;
            }
            return activityInstance;
        }
        /// <summary>
        /// 根据应用获取流程下一步节点列表
        /// </summary>
        /// <param name="runner">应用执行人</param>
        /// <param name="condition">条件</param>
        /// <returns></returns>
        public IList<NodeView> GetNextActivityTree(WfAppRunner runner, 
            IDictionary<string, string> condition = null,
            IUserRoleService roleService = null)
        {
            var tm = new TaskManager();
            var taskView = tm.GetTaskOfMine(runner.AppInstanceID, runner.ProcessGUID, runner.UserID);
            var processModel = new ProcessModel(taskView.ProcessGUID, taskView.Version);
            var nextSteps = processModel.GetNextActivityTree(taskView.ProcessInstanceID,
                taskView.ActivityGUID,
                condition,
                roleService);

            return nextSteps;
        }
示例#4
0
        /// <summary>
        /// 获取流程当前运行节点信息
        /// </summary>
        /// <param name="runner">执行者</param>
        /// <param name="taskView">任务视图</param>
        /// <returns>活动实例</returns>
        internal ActivityInstanceEntity GetRunningNode(WfAppRunner runner,
                                                       out TaskViewEntity taskView)
        {
            var appInstanceID = runner.AppInstanceID;
            var processGUID   = runner.ProcessGUID;
            var taskID        = runner.TaskID;

            taskView = null;
            ActivityInstanceEntity activityInstance = null;

            //如果流程在运行状态,则返回运行时信息
            var tm = new TaskManager();

            var aim = new ActivityInstanceManager();
            var activityInstanceList = aim.GetRunningActivityInstanceList(runner.AppInstanceID, runner.ProcessGUID).ToList();

            if ((activityInstanceList != null) && (activityInstanceList.Count == 1))
            {
                activityInstance = activityInstanceList[0];
                taskView         = tm.GetTaskOfMine(activityInstance.ID, runner.UserID);
            }
            else if (activityInstanceList.Count > 0)
            {
                if (runner.TaskID != null && runner.TaskID.Value != 0)
                {
                    taskView = tm.GetTaskView(taskID.Value);

                    foreach (var ai in activityInstanceList)
                    {
                        if (ai.ID == taskView.ActivityInstanceID)
                        {
                            activityInstance = ai;
                            break;
                        }
                    }

                    //判断是否有并行节点存在,如果有并行节点存在,取并行节点的主节点(并行会签)
                    if (activityInstance == null && activityInstanceList[0].MIHostActivityInstanceID != null)
                    {
                        var mainActivityInstanceID = activityInstanceList[0].MIHostActivityInstanceID;
                        activityInstance = aim.GetById(mainActivityInstanceID.Value);
                    }
                }
                else
                {
                    //并行模式处理
                    //根据当前执行者身份取出(他或她)要办理的活动实例(并行模式下有多个处于待办或运行状态的节点)
                    foreach (var ai in activityInstanceList)
                    {
                        if (ai.AssignedToUserIDs == runner.UserID)
                        {
                            activityInstance = ai;
                            break;
                        }
                    }

                    if (activityInstance != null)
                    {
                        //获取taskview
                        taskView = tm.GetTaskOfMine(activityInstance.ID, runner.UserID);
                    }
                    else
                    {
                        //当前用户的待办任务不唯一,抛出异常,需要TaskID唯一界定
                        var e = new WorkflowException("当前流程有多个运行节点,但没有TaskID传入,状态异常!");
                        LogManager.RecordLog("获取当前运行节点信息异常", LogEventType.Exception, LogPriority.Normal, null, e);
                        throw e;
                    }
                }
            }
            else
            {
                //当前没有运行状态的节点存在,流程不存在,或者已经结束或取消
                var e = new WorkflowException("当前流程没有运行节点,状态异常!");
                LogManager.RecordLog("获取当前运行节点信息异常", LogEventType.Exception, LogPriority.Normal, null, e);
                throw e;
            }
            return(activityInstance);
        }