//public List<int> GetTankMeasuresUniqueIDs() //{ // try // { // return tankMeasuresCollection.Distinct<int>("tankID", new BsonDocument()).ToList().OrderBy(x => x).ToList(); // } // catch (Exception e) // { // return new List<int>(); // } //} public List <TankMeasure> GetLatestTankMeasures(int amount) { try { return(tankMeasuresCollection.Aggregate().SortByDescending((a) => a["date"]).Limit(amount) .ToList().Select(x => TankMeasure.Parse(x)).ToList()); } catch (Exception e) { return(null); } }
public List <TankMeasure> GetLatestTankMeasuresByTime(int hours) { try { return(tankMeasuresCollection.Aggregate().SortByDescending((a) => a["date"]).ToList() .FindAll(x => (getTime() - DateTime.Parse(x["date"].AsString)).TotalHours <= hours) .ToList().Select(x => TankMeasure.Parse(x)).ToList()); } catch (Exception e) { return(null); } }
private void ReadDataTankMeasures(int amount) { for (int i = 0; i < amount; i++) { if (!tankMeasuresFile.EndOfStream) { waitingTankMeasures.Add(TankMeasure.Parse(tankMeasuresFile.ReadLine())); } else { return; } } }
public static TankMeasure Parse(BsonDocument doc) { var result = new TankMeasure(); result.date = DateTime.Parse(doc["date"].AsString); result.locationID = doc["locationID"].AsInt32; result.meterID = doc["meterID"].AsInt32; result.tankID = doc["tankID"].AsInt32; result.fuelHeight = (float)doc["fuelHeight"].AsDouble; result.fuelCapacity = (float)doc["fuelCapacity"].AsDouble; result.fuelTemperature = (float)doc["fuelTemperature"].AsDouble; result.waterHeight = (float)doc["waterHeight"].AsDouble; result.waterCapacity = (float)doc["waterCapacity"].AsDouble; return(result); }
public TankMeasure GetLatestTankMeasure(int tankID) { try { BsonDocument filter = new BsonDocument() { { "tankID", tankID } }; Task <BsonDocument> result = tankMeasuresCollection.Find(filter).SortByDescending((a) => a["date"]).FirstAsync(); return(TankMeasure.Parse(result.Result)); } catch (Exception e) { return(null); } }
public static TankMeasure Parse(string item) { var splited = item.Split(';'); var result = new TankMeasure(); result.date = DateTime.Parse(splited[0]); result.locationID = Utilities.ParseToInt(splited[1]); result.meterID = Utilities.ParseToInt(splited[2]); result.tankID = Utilities.ParseToInt(splited[3]); result.fuelHeight = Utilities.ParseToInt(splited[4]); result.fuelCapacity = Utilities.ParseToFloat(splited[5]); result.fuelTemperature = Utilities.ParseToFloat(splited[6]); result.waterHeight = Utilities.ParseToFloat(splited[7]); result.waterCapacity = Utilities.ParseToFloat(splited[8]); return(result); }
public static BsonDocument Parse(TankMeasure data) { var result = new BsonDocument() { { "id", Guid.NewGuid().ToString("N") }, { "date", data.date.ToString() }, { "locationID", data.locationID }, { "meterID", data.meterID }, { "tankID", data.tankID }, { "fuelHeight", data.fuelHeight }, { "fuelCapacity", data.fuelCapacity }, { "fuelTemperature", data.fuelTemperature }, { "waterHeight", data.waterHeight }, { "waterCapacity", data.waterCapacity }, }; return(result); }
//--Public_Interface_Save------------------------------------// public async void AddTankMeasure(TankMeasure data) { await tankMeasuresCollection.InsertOneAsync(TankMeasure.Parse(data)); }