public override async Task <object> GetValue(int count) { string query = $"/query?q=SELECT \"currentValue\" FROM sensors_{SensorType} " + $"WHERE postgre_id=\'{PostgreSQLId}\' " + $"ORDER BY \"time\" DESC " + $"LIMIT {count}"; string json = await influxDbClient.GetAsync(query); List <List <object> > resultCollection = InfluxDbJsonSerializer.Deserialize(json); if (resultCollection?.Count() > --count) { TimeStamp = DateTime.Parse(resultCollection[count][0].ToString()).ToUniversalTime(); JsonElement stateJson = (JsonElement)resultCollection[count][1]; bool state = JsonSerializer.Deserialize <bool>(stateJson.GetRawText()); AlertState = Handle(state); return(state); } else { return(null); } }
public override async Task <object> GetValue(int count) { string query = $"/query?q=SELECT \"latitude\",\"longitude\" FROM sensors_{SensorType} " + $"WHERE postgre_id=\'{PostgreSQLId}\' " + $"ORDER BY \"time\" DESC " + $"LIMIT {count}"; string json = await influxDbClient.GetAsync(query); List <List <object> > resultCollection = InfluxDbJsonSerializer.Deserialize(json); if (resultCollection?.Count() > --count) { TimeStamp = DateTime.Parse(resultCollection[count][0].ToString()).ToUniversalTime(); JsonElement latJson = (JsonElement)resultCollection[count][1]; JsonElement lonJson = (JsonElement)resultCollection[count][2]; double latitude = JsonSerializer.Deserialize <double>(latJson.GetRawText()); double longitude = JsonSerializer.Deserialize <double>(lonJson.GetRawText()); double[] location = new double[] { latitude, longitude }; AlertState = Handle(location); return(location); } else { return(null); } }