public RevenueForecastService(IDatabaseAccessService databaseAccessService,
                               IModelMessagingService modelMessagingService, IMapper mapper, IForecastCachingService cachingService, IRabbitMqConfiguration rabbitMqConfiguration)
 {
     _databaseAccessService = databaseAccessService;
     _modelMessagingService = modelMessagingService;
     _mapper                = mapper;
     _cachingService        = cachingService;
     _rabbitMqConfiguration = rabbitMqConfiguration;
 }
        private async void ModelResponseProcessor(IModelMessagingService sender, object message)
        {
            var forecastFromModel = JsonConvert.DeserializeObject <ForecastFromModel>((string)message);
            var forecast          = await _databaseAccessService.UpdateForecastAsync(forecastFromModel);

            await _cachingService.AddForecastToCacheAsync(forecast);

            Console.WriteLine(message);
            sender.Dispose();
        }
Beispiel #3
0
        private async void ProcessModelResponse(IModelMessagingService sender, object message)
        {
            ITraceWriter traceWriter        = new MemoryTraceWriter();
            var          analyticsFromModel = JsonConvert.DeserializeObject <StaticInfo>((string)message, new JsonSerializerSettings {
                TraceWriter = traceWriter
            });

            foreach (GenreInfo genreInfo in analyticsFromModel.GenresInfo)
            {
                var regionsInfo = JsonConvert.SerializeObject(genreInfo.RegionsInfo);
                await _redisAccessService.SetAsync(genreInfo.Genre, regionsInfo);
            }
        }
Beispiel #4
0
 public StaticAnalyticsService(IRabbitMqConfiguration rabbitMqConfiguration, IModelMessagingService messagingService, IRedisAccessService redisAccessService)
 {
     _rabbitMqConfiguration = rabbitMqConfiguration;
     _messagingService      = messagingService;
     _redisAccessService    = redisAccessService;
 }