/// <summary> /// This method is called whenever an actor is activated. /// An actor is activated the first time any of its methods are invoked. /// </summary> protected override async Task OnActivateAsync() { ActorEventSource.Current.ActorMessage(this, "Actor activated."); var stateInfo = await GetVehicleDataFromStateAsync(); if (stateInfo == null) { var info = await this.vehiclesServiceProxy.GetVehicleByPlateAsync(this.Id.GetStringId(), default(CancellationToken)); VehicleData vehicleInfo = null; VehicleActorInterface.VehicleState vehicleState = VehicleActorInterface.VehicleState.NotAvailable; if (info != null) { vehicleInfo = VehicleData.FromServiceInterfacesInfo(info); vehicleState = info.State.ToActorInterfaceState(); } await SetVehicleDataIntoStateAsync(vehicleInfo); await SetVehicleStateIntoStateAsync(vehicleState); } }
private Task SetVehicleStateIntoStateAsync(VehicleActorInterface.VehicleState state, CancellationToken cancellationToken = default(CancellationToken)) { return(this.StateManager.SetStateAsync(StateKeyName, state, cancellationToken)); }