Exemplo n.º 1
0
        public async Task <IHttpActionResult> PostTicketOrdersSimulation([FromBody] TicketOrderSimulationRequest request)
        {
            var error   = "";
            var handler = HandlersFactory.GetProfilerHandler(TheSettingService, TheLoggerService);

            handler.Start(LOG_TAG, "PostOrder", GetServiceProperties());

            try
            {
                TicketOrderSimulationRequest.Validate(request);

                IExternalizationService extService = ServiceFactory.GetInstance().GetExternalizationService(TheSettingService, TheLoggerService);
                await extService.Simulate(request);

                return(Ok("Running"));
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(BadRequest(ex.Message));
            }
            finally
            {
                handler.Stop(error);
            }
        }
Exemplo n.º 2
0
        /// <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()
        {
            this.ActorLocationService   = ServiceFactory.GetInstance().GetActorLocationService();
            this.SettingService         = ServiceFactory.GetInstance().GetSettingService();
            this.LoggerService          = ServiceFactory.GetInstance().GetLoggerService();
            this.DataStoreService       = ServiceFactory.GetInstance().GetDataStoreService(this.SettingService, this.LoggerService);
            this.HealthReporterService  = ServiceFactory.GetInstance().GetHealtheReporterService(this.SettingService, this.LoggerService, ActorService.Context.PartitionId, ActorService.Context.ReplicaId, ActorService.Context.NodeContext.NodeName, ActorService.Context.ServiceName.ToString());
            this.ExternalizationService = ServiceFactory.GetInstance().GetExternalizationService(this.SettingService, this.LoggerService);

            var error   = "";
            var message = "";
            var handler = HandlersFactory.GetProfilerHandler(SettingService, LoggerService);

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

            try
            {
                EventActorState state = await GetEntityStateAsync();

                if (state == null)
                {
                    await Reload();
                }

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

                message = string.Format("Event Actor {0} activated", this.Id.GetStringId());
                handler.Info(message);

                handler.Info("Starting a reminder to schedule state backups every " + SettingService.GetActorBackupReminderPeriodicInMinutes() + "mins");
                await this.RegisterReminderAsync(
                    BackupReminder,
                    null,
                    TimeSpan.FromMinutes(SettingService.GetActorBackupReminderDueInMinutes()),           // Fire initially 5 minutes from now
                    TimeSpan.FromMinutes(SettingService.GetActorBackupReminderPeriodicInMinutes()));     // Every 60 minutes periodic firing
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                handler.Stop(error);
                if (!string.IsNullOrEmpty(error))
                {
                    this.HealthReporterService.SendReportForService(HealthState.Error, error);
                }
            }
        }