public bool TurnTask(string taskId, WfAppRunner runner) { TaskManager tim = new TaskManager(_dataAccessor, _loggerFactory); WfTask task = tim.GetTask(taskId); if (task == null) { throw new FapException("任务不存在"); } Performer turner = runner.Turners[0]; ActivityInstanceManager aim = new ActivityInstanceManager(_dataAccessor, _loggerFactory); WfActivityInstance activity = aim.GetByFid(task.ActivityInsUid); activity.AssignedToUserIds = activity.AssignedToUserIds.Replace(runner.UserId, turner.UserId); activity.AssignedToUserNames = activity.AssignedToUserNames.Replace(runner.UserName, turner.UserName); aim.Update(activity); task.ExecutorEmpUid = turner.UserId; task.ExecutorEmpName = turner.UserName; task.UpdateBy = runner.UserId; task.UpdateName = runner.UserName; task.UpdateDate = DateTimeUtils.CurrentDateStr; tim.Update(task); TaskAdviceManager tam = new TaskAdviceManager(_dataAccessor, _applicationContext, _loggerFactory); tam.RecordWhenTurnTask(runner.ProcessUid, runner.CurrNodeId, runner.Comment, turner.UserId, turner.UserName); return(true); }
/// <summary> /// 创建运行时实例对象 /// </summary> /// <param name="runner">执行者</param> /// <param name="result">结果对象</param> /// <returns>运行时实例对象</returns> public static WfRuntimeManager CreateRuntimeInstanceAppRunning( WfAppRunner runner, IServiceProvider serviceProvider, ref WfExecutedResult result) { //检查传人参数是否有效 var rmins = new WfRuntimeManagerAppRunning(serviceProvider); rmins.WfExecutedResult = result = new WfExecutedResult(); if (string.IsNullOrEmpty(runner.BillUid) || runner.ProcessUid == null || runner.CurrActivityInsUid == null || runner.CurrProcessInsUid == null || runner.CurrWfTaskUid == null || runner.CurrNodeId == null) { result.Status = WfExecutedStatus.Exception; result.ExceptionType = WfExceptionType.RunApp_ErrorArguments; result.Message = "方法参数错误,无法运行流程!"; return(rmins); } //传递runner变量 rmins.AppRunner = runner; var aim = new ActivityInstanceManager(serviceProvider); WfActivityInstance wfActivityInstance = aim.GetByFid(runner.CurrActivityInsUid); if (wfActivityInstance.ActivityState == WfActivityInstanceState.Completed) { result.Status = WfExecutedStatus.Exception; result.Message = "任务已经完成,不需要再审批。"; return(rmins); } rmins.RunningActivityInstance = wfActivityInstance; rmins.ProcessModel = new ProcessModel(serviceProvider, runner.ProcessUid, runner.BillUid); var tm = new TaskManager(serviceProvider); rmins.TaskView = tm.GetTask(runner.CurrWfTaskUid); return(rmins); }