山东雷驰
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.
 
 
 
 

60 lines
2.0 KiB

using AutoMapper;
using Kean.Domain.Task.Commands;
using Kean.Domain.Task.Events;
using Kean.Domain.Task.Repositories;
using Kean.Domain.Task.SharedServices.Proxies;
using Newtonsoft.Json;
using System;
using System.Threading;
namespace Kean.Domain.Task.CommandHandlers
{
/// <summary>
/// 任务取消命令处理程序
/// </summary>
public sealed class SetRollTaskCommandHandler : CommandHandler<SetRollTaskCommand>
{
private readonly ICommandBus _commandBus; // 命令总线
//private readonly IMapper _mapper; // 模型映射
private readonly ITaskRepository _taskRepository; // 任务仓库
//private readonly IWarehouseRepository _warehouseRepository; // 库房仓库
private readonly StockProxy _stockProxy; // 库房仓库
/// <summary>
/// 依赖注入
/// </summary>
public SetRollTaskCommandHandler(
ICommandBus commandBus,
//IMapper mapper,
StockProxy stockProxy,
//IWarehouseRepository warehouseRepository,
ITaskRepository taskRepository)
{
_commandBus = commandBus;
//_mapper = mapper;
_stockProxy = stockProxy;
//_warehouseRepository = warehouseRepository;
_taskRepository = taskRepository;
}
/// <summary>
/// 处理程序
/// </summary>
public override async System.Threading.Tasks.Task Handle(SetRollTaskCommand command, CancellationToken cancellationToken)
{
if (command.ValidationResult.IsValid)
{
var task = await _taskRepository.GetTask(command.Id);
if (task != null)
{
await _stockProxy.SetRollResult(task.Barcode, command.Code, command.Message, command.Operator);
}
}
else
{
await _commandBus.Notify(command.ValidationResult,
cancellationToken: cancellationToken);
}
}
}
}