You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
3 months ago
|
using Kean.Domain.Task.Commands;
|
||
|
using Kean.Domain.Task.Repositories;
|
||
|
|
||
|
namespace Kean.Domain.Task.SharedServices
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 任务取消
|
||
|
/// </summary>
|
||
|
public sealed class Error
|
||
|
{
|
||
|
private readonly ICommandBus _commandBus;
|
||
|
private readonly ITaskRepository _taskRepository; // 任务仓库
|
||
|
|
||
|
/// <summary>
|
||
|
/// 依赖注入
|
||
|
/// </summary>
|
||
|
public Error(ICommandBus commandBus,
|
||
|
ITaskRepository taskRepository)
|
||
|
{
|
||
|
_commandBus = commandBus;
|
||
|
_taskRepository = taskRepository;
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 处理程序
|
||
|
/// </summary>
|
||
|
/// <param name="id">标识</param>
|
||
|
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..]}不一致"
|
||
|
});
|
||
|
;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|