Exemple #1
0
        private void PersistAll(string stationId, Dictionary <string, List <SensorState> > perSensorState)
        {
            var tasks =
                perSensorState.Select(
                    stationSensor => statePersister.Persist(stationId, stationSensor.Key, stationSensor.Value)).ToArray();

            Task.WaitAll(tasks);
        }
        public async Task ProcessMessage(StreamSensorAverage message)
        {
            if (string.IsNullOrWhiteSpace(message?.StationId) || string.IsNullOrWhiteSpace(message.SensorId))
            {
                return;
            }
            var stationId = message.StationId;
            var sensorId  = message.SensorId;

            /*
             * NOTE: el stream-analytics usa el 'time' que eventualmente recibe y lo convierte a UTC para su procesamiento y, en output tambien restituye UTC.
             * ya que los sensores están en Argentina cambiamos el Timestamp a la hora local.
             */
            var time = TimeZoneInfo.ConvertTime(message.Time, argentineZoneInfo);
            await statePersister.Persist(stationId, sensorId, time, message.State);

            await hourlyEnqueuer.Enqueue(new StationSensorHourlyStateChanged { StationId = stationId, SensorId = sensorId, Day = time.DateTime });
        }