using Kean.Domain.Task.Commands; using Kean.Domain.Task.Repositories; namespace Kean.Domain.Task.SharedServices { /// /// 任务取消 /// public sealed class Error { private readonly ICommandBus _commandBus; private readonly ITaskRepository _taskRepository; // 任务仓库 /// /// 依赖注入 /// public Error(ICommandBus commandBus, ITaskRepository taskRepository) { _commandBus = commandBus; _taskRepository = taskRepository; } /// /// 处理程序 /// /// 标识 public async System.Threading.Tasks.Task Handler(string scanBarcode, string parameters) { if (!string.IsNullOrEmpty(parameters) && parameters.StartsWith("errorMessage:")) { var task = await _taskRepository.GetTaskByBarcode(parameters[13..]); if (task != null) { await _commandBus.Execute(new ErrorCommand { Id = task.Id, Message = $"扫描条码{scanBarcode}与任务条码{parameters[13..]}不一致" }); ; } } } } }