/// <summary> /// 每次审核办理执行 /// </summary> /// <param name="input"></param> public void CompleteTask(CompleteTaskInput <UpdateQualityProblemInput> input) { var authInfo = _authInfoProvider.GetCurrent(); var userId = authInfo?.User?.Id; var task = _taskProvider.GetTask(input.Id); if (task.Assignee != userId.Value.ToString()) { throw new AppCoreException($"id:为{userId.Value}的用户不是任务【{task.NodeName}】的委托人"); } var processDefinition = _definitionProvder.Get(task.ProcessDefinitionId); var editableFields = ((UserTaskNode)processDefinition.GetNode(task.NodeUid)).GetEditableFields(); if (input.Data != null) { var project = input.Data.MapTo <QualityProblem>(); if (editableFields == null) { _problemRepository.Update(project, new System.Linq.Expressions.Expression <Func <QualityProblem, object> >[] { u => u.State, u => u.Mid, u => u.ProcessInstanceId }, false); } else { _problemRepository.Update(project, editableFields.ToArray()); } } if (!input.PreventCommit) { _taskProvider.Complete(input.Id, input.Comment); } }
//在注入事件总线上,属性注入比构造器注入更合适。 // 你的类可以没有事件总线,NullEventBus实现了空对象模式, // 当你调用它的方法时,方法里什么也不做。 public void CompleteTask(CompleteTaskInput input) { //TODO: complete the task on database... //有一些触发方法的重载: EventBus.Trigger(new TaskCompletedEventData { TaskId = 42 }); EventBus.Trigger(this, new TaskCompletedEventData { TaskId = 42 }); EventBus.Trigger(typeof(TaskCompletedEventData), this, new TaskCompletedEventData { TaskId = 42 }); EventBus.Register <TaskCompletedEventData>(eventData => { WriteActivity("A task is completed by id = " + eventData.TaskId); }); //“任务完成”事件发生后,这个lambda方法就会被调用。 //第二个是接受一个实现了IEventHantler<T> 的对象: EventBus.Register <TaskCompletedEventData>(new ActivityWriter()); //同样是为事件调用ActivityWriter实例。第三个重载接受两个泛型参数: EventBus.Register <TaskCompletedEventData, ActivityWriter>(); //注册一个事件 var registration = EventBus.Register <TaskCompletedEventData> (eventData => WriteActivity("A task is completed by id = " + eventData.TaskId)); //取消注册一个事件 registration.Dispose(); //当然,取消注册可以在任何地方任何时候进行。 //保存(keep)好注册的对象并且在你想要取消注册的时候释放(dispose)掉它。 //所有注册方法的重载(overload)都会返回一个可释放(disposable)的对象来取消事件的注册。 //------------------------ //事件总线也提供取消注册方法。使用范例: //创建一个处理器 var handler = new ActivityWriter(); //注册一个事件 EventBus.Register <TaskCompletedEventData>(handler); //取消这个事件的注册 EventBus.Unregister <TaskCompletedEventData>(handler); }
public async Task <IActionResult> Complete( [FromServices] IMediator mediator, [FromServices] CompleteTaskPresenter presenter, [FromBody][Required] CompleteTaskRequest request) { var accountId = this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "AccountId").Value; var input = new CompleteTaskInput( new BaseEntityId(new Guid(accountId)), new BaseEntityId(request.TableId), new BaseEntityId(request.TaskId)); await mediator.PublishAsync(input); return(presenter.ViewModel); }
public void CompleteTask(CompleteTaskInput <UpdateRecordInput> input) { NullableHelper.SetNull(input.Data); var authInfo = _authInfoProvider.GetCurrent(); var userId = authInfo?.User?.Id; var task = _taskProvider.GetTask(input.Id); if (task.Assignee != userId.Value.ToString()) { throw new AppCoreException($"id:为{userId.Value}的用户不是任务【{task.NodeName}】的委托人"); } var processDefinition = _definitionProvder.Get(task.ProcessDefinitionId); var editableFields = ((UserTaskNode)processDefinition.GetNode(task.NodeUid)).GetEditableFields(); if (input.Data != null) { var record = input.Data.MapTo <Record>(); var existing = _recordRepository.Get() .Include(u => u.Attachments) .Where(u => u.ProcessInstanceId == task.ProcessInstanceId).FirstOrDefault(); record.Id = existing.Id; if (existing == null) { throw new EntityException("RecordInstanceId", task.ProcessInstanceId, "Record", "不存在"); } if (editableFields == null) { _recordRepository.Update(record, existing, new System.Linq.Expressions.Expression <Func <Record, object> >[] { u => u.DataState, u => u.Mid, u => u.ProcessInstanceId, u => u.ProjectId }, false); } else { _recordRepository.Update(record, editableFields.ToArray()); } } if (!input.PreventCommit) { _taskProvider.Complete(input.Id, input.Comment); } }
public void CompleteTask(CompleteTaskInput input) { var authInfo = _authInfoProvider.GetCurrent(); var userId = authInfo?.User?.Id; var task = _taskProvider.GetTask(input.Id); if (task.Assignee != userId.Value.ToString()) { throw new AppCoreException($"id:为{userId.Value}的用户不是任务【{task.NodeName}】的委托人"); } if (input.FormContents.Count > 0) { _taskProvider.SetFields(input.Id, input.FormContents); } if (!input.PreventCommit) { _taskProvider.Complete(input.Id, input.Comment); } }
public async Task Handle(CompleteTaskInput input) { if (input is null) { outputPort.WriteError(Message.InputIsNull); return; } try { var task = await tableRepository.GetTaskAsync(input.TableId, input.AccountId, input.TaskId); task.Complete(); await unitOfWork.Save(); BuildOutput(task); } catch (Exception e) { outputPort.WriteError(e.Message); } }
public void CompleteTask(CompleteTaskInput <UpdateProjectInput> input) { NullableHelper.SetNull(input.Data); var authInfo = _authInfoProvider.GetCurrent(); var userId = authInfo?.User?.Id; var task = _taskProvider.GetTask(input.Id); if (task.Assignee != userId.Value.ToString()) { throw new AppCoreException($"id:为{userId.Value}的用户不是任务【{task.NodeName}】的委托人"); } var processDefinition = _definitionProvder.Get(task.ProcessDefinitionId); var editableFields = ((UserTaskNode)processDefinition.GetNode(task.NodeUid)).GetEditableFields(); if (input.Data != null) { var project = input.Data.MapTo <Project>(); var existing = _projectRepository.Get() .Include(u => u.Location) .Include(u => u.Members) .Include(u => u.Units).ThenInclude(u => u.Members) .Include(u => u.Attachments) .Where(u => u.ProcessInstanceId == task.ProcessInstanceId).FirstOrDefault(); project.Id = existing.Id; if (existing == null) { throw new EntityException("ProjectInstanceId", task.ProcessInstanceId, "Project", "不存在"); } if (editableFields == null) { using (var transaction = _dbContextProvider.BeginTransaction()) { if (project.Location != null && project.Location.IsTransient()) { project.Location.ProjectId = project.Id; } _projectRepository.Update(project, existing, new System.Linq.Expressions.Expression <Func <Project, object> >[] { u => u.DataState, u => u.Mid, u => u.ProcessInstanceId, u => u.Units, u => u.No }, false); var addedUnits = project.Units.Except(existing.Units, u => u.Id).ToList(); var deletedUnits = existing.Units.Except(project.Units, u => u.Id).ToList(); var updatedUnits = project.Units.Intersect(existing.Units, u => u.Id).ToList(); foreach (var added in addedUnits) { _projectUnitRepository.Add(added); } foreach (var deleted in deletedUnits) { _projectUnitRepository.Delete(deleted); } foreach (var updated in updatedUnits) { var existed = existing.Units.Where(u => u.Id == updated.Id).FirstOrDefault(); _projectUnitRepository.Update(updated, existed, new Expression <Func <ProjectUnit, object> >[] { }, false); } transaction.Commit(); } } else { if (editableFields.Contains("Units")) { var addedUnits = project.Units.Except(existing.Units, u => u.Id).ToList(); var deletedUnits = existing.Units.Except(project.Units, u => u.Id).ToList(); var updatedUnits = project.Units.Intersect(existing.Units, u => u.Id).ToList(); foreach (var added in addedUnits) { _projectUnitRepository.Add(added); } foreach (var deleted in deletedUnits) { _projectUnitRepository.Delete(deleted); } foreach (var updated in updatedUnits) { var existed = existing.Units.Where(u => u.Id == updated.Id).FirstOrDefault(); _projectUnitRepository.Update(updated, existed, new Expression <Func <ProjectUnit, object> >[] { }, false); } editableFields.Remove("Units"); } _projectRepository.Update(project, editableFields.ToArray()); } } if (!input.PreventCommit) { _taskProvider.Complete(input.Id, input.Comment); } }
public IActionResult CompletePaymentTaskTask(int id, [FromBody] CompleteTaskInput <UpdateContractPaymentInput> input) { input.Id = id; _paymentService.CompleteTask(input); return(Created("", null)); }
public IActionResult CompleteMonthlyProgressTaskTask(int id, [FromBody] CompleteTaskInput <UpdateMonthlyProgressInput> input) { input.Id = id; _monthlyProgressService.CompleteTask(input); return(Created("", null)); }
public IActionResult CompleteProblemsTaskTask(int id, [FromBody] CompleteTaskInput <UpdateProblemInput> input) { input.Id = id; _problemsTaskService.CompleteTask(input); return(Created("", null)); }
public IActionResult CompleteRecordTask(int id, [FromBody] CompleteTaskInput <UpdateRecordInput> input) { input.Id = id; _recordService.CompleteTask(input); return(Created("", null)); }
public IActionResult CompleteEarlyStageTaskTask(int id, [FromBody] CompleteTaskInput <UpdateEarlyStageInput> input) { input.Id = id; _earlyStageTaskService.CompleteTask(input); return(Created("", null)); }
public IActionResult CompleteSafetyAccidentTaskTask(int id, [FromBody] CompleteTaskInput <UpdateSafetyAccidentInput> input) { input.Id = id; _safetyAccidentTaskService.CompleteTask(input); return(Created("", null)); }
public IActionResult CompleteConstructionUnitTask(int id, [FromBody] CompleteTaskInput <UpdateConstructionUnitInput> input) { input.Id = id; _constructionUnitService.CompleteTask(input); return(Created("", null)); }
public IActionResult CompleteTask(int id, [FromBody] CompleteTaskInput input) { input.Id = id; _taskService.CompleteTask(input); return(Created("", null)); }