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

3 months ago
using Kean.Application.Command.Interfaces;
using Kean.Application.Command.ViewModels;
using Kean.Domain;
using Kean.Domain.Wcs.Commands;
using Orleans;
using System.Linq;
using System.Threading.Tasks;
namespace Kean.Application.Command.Implements
{
/// <summary>
/// 控制交互颗粒
/// </summary>
internal class WcsGrain : Grain, IWcsGrain
{
private readonly ICommandBus _bus; // 命令总线
private readonly INotification _notifications; // 总线通知
/// <summary>
/// 依赖注入
/// </summary>
public WcsGrain(
ICommandBus bus,
INotification notifications)
{
_bus = bus;
_notifications = notifications;
}
/*
* Kean.Application.Command.Interfaces.IWcsService.AcceptInput
*/
public async Task<(AcceptInputCommand Fallback, Failure Failure)> AcceptInput(AcceptInputCommand command)
{
DeactivateOnIdle();
await _bus.Execute(command);
return (command.Fallback, _notifications.FirstOrDefault());
}
/*
* Kean.Application.Command.Interfaces.IWcsService.SyncOutput
*/
public async Task<Failure> SyncOutput(SyncOutputCommand command)
{
DeactivateOnIdle();
await _bus.Execute(command);
return _notifications.FirstOrDefault();
}
/*
* Kean.Application.Command.Interfaces.IWcsService.SyncStation
*/
public async Task<Failure> SyncStation(SyncStationCommand command)
{
DeactivateOnIdle();
await _bus.Execute(command);
return _notifications.FirstOrDefault();
}
}
}