public async Task ReceiveReminderAsync(string reminderName, byte[] context, TimeSpan dueTime, TimeSpan period) { switch (reminderName) { case CustomerOrderReminderNames.FulfillOrderReminder: await this.FulfillOrderAsync(); RVSSalesActorStatus orderStatus = await this.GetOrderStatusAsync(); if (orderStatus == RVSSalesActorStatus.Shipped || orderStatus == RVSSalesActorStatus.Canceled) { //Remove fulfill order reminder so Actor can be gargabe collected. IActorReminder orderReminder = this.GetReminder(CustomerOrderReminderNames.FulfillOrderReminder); await this.UnregisterReminderAsync(orderReminder); } break; default: // We should never arrive here normally. The system won't call reminders that don't exist. // But for our own sake in case we add a new reminder somewhere and forget to handle it, this will remind us. throw new InvalidOperationException("Unknown reminder: " + reminderName); } }
/// <summary> /// Initializes CustomerOrderActor state. Because an order actor will only be activated /// once in this scenario and never used again, when we initiate the actor's state we /// change the order's status to "Confirmed," and do not need to check if the actor's /// state was already set to this. /// </summary> /// protected override async Task OnActivateAsync() { await InternalActivateAsync(this.ActorService.Context.CodePackageActivationContext, new ServiceProxyFactory()); RVSSalesActorStatus orderStatusResult = await this.GetOrderStatusAsync(); if (orderStatusResult == RVSSalesActorStatus.Unknown) { await this.StateManager.SetStateAsync <List <RVSSalesActorItem> >(OrderItemListPropertyName, new List <RVSSalesActorItem>()); await this.StateManager.SetStateAsync <long>(RequestIdPropertyName, 0); await this.SetOrderStatusAsync(RVSSalesActorStatus.New); } return; }
private async Task SetOrderStatusAsync(RVSSalesActorStatus orderStatus) { await this.StateManager.SetStateAsync <RVSSalesActorStatus>(OrderStatusPropertyName, orderStatus); }