public async Task Execute(IJobExecutionContext context) { var actorMessageContext = context.GetDataContext <ActorMessageContext>(); if (actorMessageContext.Condition != null) { var validationResult = await actorMessageContext.Condition.Validate().ConfigureAwait(false); if (!validationResult) { return; } } foreach (var cmd in actorMessageContext.Commands) { _actorMessageBroker.Send(cmd, actorMessageContext.Actor); } if (actorMessageContext.FinishCommands?.Count > 0) { var time = context.FireTimeUtc.Add(actorMessageContext.FinishCommandTime.GetValueOrDefault()); var finishContext = ActorMessageContext.Create(actorMessageContext.Actor, actorMessageContext.Condition, actorMessageContext.FinishCommands.ToArray()); await _actorMessageBroker.SendAtTime(finishContext, time, actorMessageContext.Token); } }
public static ActorMessageContext Create(PID actor, IValidable condition, params Command[] commands) { var context = new ActorMessageContext { Actor = actor, Condition = condition }; context.Commands.AddRange(commands); return(context); }
public static ActorMessageContext Create(PID actor, Command command) { var context = new ActorMessageContext { Actor = actor }; context.Commands.Add(command); return(context); }