Ejemplo n.º 1
0
        public async Task Reload()
        {
            var error   = "";
            var handler = HandlersFactory.GetProfilerHandler(SettingService, LoggerService);

            handler.Start(LOG_TAG, "Reload", GetActorProperties());

            try
            {
                // Given the actor id (which is the event id), re-load the event stats
                TicketEventStats stats = await DataStoreService.GetEventStats(this.Id.GetStringId());

                var state = new EventActorState(stats);

                // Make sure the state is saved
                await SetEntityStateAsync(state);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                handler.Stop(error);
                if (!string.IsNullOrEmpty(error))
                {
                    this.HealthReporterService.SendReportForService(HealthState.Error, GetHealthErrorMessage("GetStats", error));
                }
            }
        }
 public EventActorState(TicketEventStats stats)
 {
     Tickets          = stats.Tickets;
     RequestedTickets = stats.RequestedTickets;
     FailedTickets    = stats.FailedTickets;
     CancelledTickets = stats.CancelledTickets;
     Orders           = new List <TicketOrder>(); // Yes ..we lose the historical orders!
 }
Ejemplo n.º 3
0
        public async Task <TicketEventStats> GetStats()
        {
            var error   = "";
            var handler = HandlersFactory.GetProfilerHandler(SettingService, LoggerService);

            handler.Start(LOG_TAG, "GetStats", GetActorProperties());
            var stats = new TicketEventStats();

            try
            {
                var state = await this.StateManager.GetStateAsync <EventActorState>(ActorStatePropertyName);

                stats = new TicketEventStats()
                {
                    Tickets          = state.Tickets,
                    RequestedTickets = state.RequestedTickets,
                    FailedTickets    = state.FailedTickets,
                    CancelledTickets = state.CancelledTickets,
                    Orders           = state.Orders.Count
                };
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                handler.Stop(error);
                if (!string.IsNullOrEmpty(error))
                {
                    this.HealthReporterService.SendReportForService(HealthState.Error, GetHealthErrorMessage("GetStats", error));
                }
            }

            return(stats);
        }