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 { /// /// 控制交互颗粒 /// internal class WcsGrain : Grain, IWcsGrain { private readonly ICommandBus _bus; // 命令总线 private readonly INotification _notifications; // 总线通知 /// /// 依赖注入 /// 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 SyncOutput(SyncOutputCommand command) { DeactivateOnIdle(); await _bus.Execute(command); return _notifications.FirstOrDefault(); } /* * 实现 Kean.Application.Command.Interfaces.IWcsService.SyncStation 方法 */ public async Task SyncStation(SyncStationCommand command) { DeactivateOnIdle(); await _bus.Execute(command); return _notifications.FirstOrDefault(); } } }