Exemplo n.º 1
0
        public async Task RefreshStationData(ClientDto clientDto)
        {
            var sensorsDataQuery = new SensorsDataQuery()
            {
                StationId = clientDto.StationId,
                Range     = RangeOfData.DAY
            };

            var sensorsDailyData = await _unitOfWork.SensorRepository.GetSensorsData(sensorsDataQuery);

            await _hubContext.Clients.Client(clientDto.ConnectionId).SendAsync("RefreshedAirData", sensorsDailyData);


            var stationState = await _unitOfWork.StationRepository.GetStationState(clientDto.StationId);

            await _hubContext.Clients.Client(clientDto.ConnectionId).SendAsync("RefreshedAirQuality", stationState);
        }
Exemplo n.º 2
0
        public async Task <ICollection <SensorDataDTO> > GetSensorsData(SensorsDataQuery query)
        {
            var sensorsData = _mapper.Map <ICollection <SensorDataDTO> >(await GetSensors(query.StationId));

            foreach (var sensorData in sensorsData)
            {
                var values = await _clientContext.GetMeasures(sensorData.Id);

                sensorData.Values = new List <MeasureDTO>();
                if (query.Range == RangeOfData.LATEST)
                {
                    sensorData.Values.Add(values.FirstOrDefault());
                }
                else
                {
                    sensorData.Values = values;
                }
            }

            var sensorsDataDTO = sensorsData.Where(s => s.Values.Count() > 0).ToList();

            return(sensorsDataDTO);
        }
Exemplo n.º 3
0
        public async Task <ICollection <SensorDataDTO> > GetAirData([FromQuery] SensorsDataQuery query)
        {
            var sensorsData = await _unitOfWork.SensorRepository.GetSensorsData(query);

            return(await Task.FromResult(sensorsData));
        }