Ejemplo n.º 1
0
        public async Task Handle(Measurement @event)
        {
            var chargingInfoTask = _chargingService.GetChargingInfoForConsumerAsync(@event.DeviceId);
            var pricingInfoTask  = _pricingService.GetPricingInfoAsync();
            await Task.WhenAll(chargingInfoTask, pricingInfoTask);

            var chargingInfo = await chargingInfoTask;
            var pricingInfo  = await pricingInfoTask;
            var price        = CalculatePrice(pricingInfo.Price, chargingInfo);

            var accountingMessage = AccountancyRelay.Create(price, @event.HouseId, pricingInfo, chargingInfo);

            _eventBus.Publish(accountingMessage);
        }
        public async Task Handle(Measurement @event)
        {
            var chargingInfoTask = _chargingService.GetChargingInfoForConsumerAsync(@event.DeviceId);
            var pricingInfoTask  = _pricingService.GetPricingInfoAsync();
            await Task.WhenAll(chargingInfoTask, pricingInfoTask).ConfigureAwait(false);

            var chargingInfo = await chargingInfoTask.ConfigureAwait(false);

            var pricingInfo = await pricingInfoTask.ConfigureAwait(false);

            var price = CalculatePrice(pricingInfo.Price, chargingInfo);

            var accountingMessage = AccountancyRelay.Create(price, @event.HouseId, pricingInfo, chargingInfo);

            _log.Debug($"Event had house id: {@event.HouseId}, value: {@event.Value}, timestamp: {@event.Timestamp}, deviceId: {@event.DeviceId}");
            _eventBus.Publish(accountingMessage);
        }