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

using AutoMapper;
using Kean.Domain.Task.Commands;
using Kean.Domain.Task.Enums;
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 SetPriorityCommandHandler : CommandHandler<SetPriorityCommand>
{
private readonly ICommandBus _commandBus; // 命令总线
private readonly ITaskRepository _taskRepository; // 任务仓库
private readonly WcsProxy _wcsProxy;
/// <summary>
/// 依赖注入
/// </summary>
public SetPriorityCommandHandler(
ICommandBus commandBus,
ITaskRepository taskRepository,
WcsProxy wcsProxy)
{
_commandBus = commandBus;
_taskRepository = taskRepository;
_wcsProxy = wcsProxy;
}
/// <summary>
/// 处理程序
/// </summary>
public override async System.Threading.Tasks.Task Handle(SetPriorityCommand command, CancellationToken cancellationToken)
{
if (command.ValidationResult.IsValid)
{
await _wcsProxy.SetPriority(command.Id, 10);
await _taskRepository.SetPriority(command.Id, 10);
}
else
{
await _commandBus.Notify(command.ValidationResult,
cancellationToken: cancellationToken);
}
}
}
}