应用执行运行时
Inheritance: WfRuntimeManager
示例#1
0
        /// <summary>
        /// 创建运行时实例对象
        /// </summary>
        /// <param name="runner">执行者</param>
        /// <param name="result">结果对象</param>
        /// <returns>运行时实例对象</returns>
        public static WfRuntimeManager CreateRuntimeInstanceAppRunning(
            WfAppRunner runner,
            ref WfExecutedResult result)
        {
            //检查传人参数是否有效
            var rmins = new WfRuntimeManagerAppRunning();

            rmins.WfExecutedResult = result = new WfExecutedResult();
            if (string.IsNullOrEmpty(runner.AppName) ||
                String.IsNullOrEmpty(runner.AppInstanceID) ||
                runner.ProcessGUID == null)
            {
                result.Status        = WfExecutedStatus.Exception;
                result.ExceptionType = WfExceptionType.RunApp_ErrorArguments;
                result.Message       = "方法参数错误,无法运行流程!";
                return(rmins);
            }

            //传递runner变量
            rmins.AppRunner = runner;

            var            aim         = new ActivityInstanceManager();
            TaskViewEntity taskView    = null;
            var            runningNode = aim.GetRunningNode(runner, out taskView);

            //判断是否是当前登录用户的任务
            if (runningNode.AssignedToUserIDs.Contains(runner.UserID.ToString()) == false)
            {
                result.Status        = WfExecutedStatus.Exception;
                result.ExceptionType = WfExceptionType.RunApp_HasNoTask;
                result.Message       = "当前没有登录用户要办理的任务,无法运行流程!";
                return(rmins);
            }

            var processModel     = ProcessModelFactory.Create(taskView.ProcessGUID, taskView.Version);
            var activityResource = new ActivityResource(runner,
                                                        runner.NextActivityPerformers,
                                                        runner.Conditions,
                                                        runner.DynamicVariables);

            var tm = new TaskManager();

            rmins.TaskView = taskView;
            rmins.RunningActivityInstance = runningNode;
            rmins.ProcessModel            = processModel;
            rmins.ActivityResource        = activityResource;

            return(rmins);
        }
        /// <summary>
        /// 创建运行时实例
        /// </summary>
        /// <param name="appName"></param>
        /// <param name="appInstanceID"></param>
        /// <param name="processGUID"></param>
        /// <param name="userID"></param>
        /// <param name="userName"></param>
        /// <param name="nextActivityPerformers"></param>
        /// <returns></returns>
        public static WfRuntimeManager CreateRuntimeInstanceAppRunning(
            WfAppRunner runner,
            ref WfExecutedResult result)
        {
            //检查传人参数是否有效
            var rmins = new WfRuntimeManagerAppRunning();
            rmins.WfExecutedResult = result = new WfExecutedResult();
            if (string.IsNullOrEmpty(runner.AppName)
                || String.IsNullOrEmpty(runner.AppInstanceID)
                || runner.ProcessGUID == null)
            {
                result.Status = WfExecutedStatus.Exception;
                result.ExceptionType = WfExceptionType.RunApp_ErrorArguments;
                result.Message = "方法参数错误,无法运行流程!";
                return rmins;
            }

            //传递runner变量
            rmins.AppRunner = runner;

            var aim = new ActivityInstanceManager();
            TaskViewEntity taskView = null;
            var runningNode = aim.GetRunningNodeOfMine(runner, out taskView);

            //判断是否是当前登录用户的任务
            if (runningNode.AssignedToUsers.Contains(runner.UserID.ToString()) == false)
            {
                result.Status = WfExecutedStatus.Exception;
                result.ExceptionType = WfExceptionType.RunApp_HasNoTask;
                result.Message = "当前没有登录用户要办理的任务,无法运行流程!";
                return rmins;
            }

            var processModel = new ProcessModel(runningNode.ProcessGUID);
            var activityResource = new ActivityResource(runner, runner.NextActivityPerformers, runner.Conditions);

            var tm = new TaskManager();
            rmins.TaskView = taskView;
            rmins.RunningActivityInstance = runningNode;
            rmins.ProcessModel = processModel;
            rmins.ActivityResource = activityResource;

            return rmins;
        }