示例#1
0
        public async Task Notify(Event @event)
        {
            Log("Received a new event");
            var result = _statusEngine.Calculate(State.Colour, @event.Data);

            if (result == State.Colour)
            {
                Log("Nothing has changed. Ignoring");
                return;
            }

            Log($"Event class colour has changed to {result}!");
            var newEvent = new EventClassChangedStatus
            {
                Event            = @event,
                EventClassStatus = new EventClassSummary
                {
                    Name   = this.GetPrimaryKeyString().Name(),
                    Colour = result
                }
            };

            RaiseEvent(newEvent);
            var parentPath = this.GetPrimaryKeyString().ParentPath();
            var assetGrain = _client.GetGrain <IAssetGrain>(parentPath);
            await assetGrain.Notify(newEvent);

            Log("Asset notified");
            await ConfirmEvents();

            Log("Done");
        }
示例#2
0
        public async Task Notify(EventClassChangedStatus @event)
        {
            Log("Received notification: Event class colour has changed!");

            var currentStatus = GetSummary(State);

            RaiseEvent(@event);
            var newStatus = GetSummary(TentativeState);

            if (currentStatus.Colour == newStatus.Colour)
            {
                Log("Asset state did not change");
            }
            else
            {
                Log($"Asset colour has changed to {newStatus.Colour}!");
                var parentPath      = this.GetPrimaryKeyString().ParentPath();
                var assetClassGrain = _client.GetGrain <IOwnerGrain>(parentPath);
                await assetClassGrain.Notify(new AssetChangedStatus
                {
                    Asset = newStatus
                });

                Log("Owner notified");
            }

            await ConfirmEvents();
        }
示例#3
0
 public EventClass Apply(EventClassChangedStatus @event)
 {
     LatestEvent = @event.Event;
     Colour      = @event.EventClassStatus.Colour;
     return(this);
 }
示例#4
0
 public Asset Apply(EventClassChangedStatus @event)
 {
     EventClasses[@event.EventClassStatus.Name] = @event.EventClassStatus;
     return(this);
 }