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

62 lines
1.5 KiB

using Kean.Domain.Task.Commands;
using Kean.Domain.Task.Repositories;
namespace Kean.Domain.Task.SharedServices
{
/// <summary>
/// 任务取消
/// </summary>
public sealed class SetTaskState
{
private readonly ICommandBus _commandBus;
private readonly ITaskRepository _taskRepository; // 任务仓库
/// <summary>
/// 依赖注入
/// </summary>
public SetTaskState(ICommandBus commandBus,
ITaskRepository taskRepository)
{
_commandBus = commandBus;
_taskRepository = taskRepository;
}
/// <summary>
/// 处理程序
/// </summary>
/// <param name="id">标识</param>
public async System.Threading.Tasks.Task Handler(int taskId, string barcode, string taskState,
string message,string type)
{
if (taskId > 0)
{
}
else
{
try
{
var task = await _taskRepository.GetTaskByBarcode(barcode);
if (task != null )
{
taskId = task.Id;
}
}
catch
{
}
}
await _commandBus.Execute(new SetTaskStateCommand
{
Id = taskId,
State = taskState,
Message = message,
Type = type
});
}
}
}