Ejemplo n.º 1
0
 public List <NozzleMeasure> GetLatestNozzleMeasures(int amount)
 {
     try
     {
         return(nozzleMeasuresCollection.Aggregate().SortByDescending((a) => a["date"]).Limit(amount)
                .ToList().Select(x => NozzleMeasure.Parse(x)).ToList());
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Ejemplo n.º 2
0
 public List <NozzleMeasure> GetLatestNozzleMeasuresByTime(int hours)
 {
     try
     {
         return(nozzleMeasuresCollection.Aggregate().SortByDescending((a) => a["date"]).ToList()
                .FindAll(x => (getTime() - DateTime.Parse(x["date"].AsString)).TotalHours <= hours)
                .ToList().Select(x => NozzleMeasure.Parse(x)).ToList());
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Ejemplo n.º 3
0
        public static NozzleMeasure Parse(BsonDocument doc)
        {
            var result = new NozzleMeasure();

            result.date         = DateTime.Parse(doc["date"].AsString);
            result.locationID   = doc["locationID"].AsInt32;
            result.nozzleID     = doc["nozzleID"].AsInt32;
            result.tankID       = doc["tankID"].AsInt32;
            result.literCounter = (float)doc["literCounter"].AsDouble;
            result.totalCounter = (float)doc["totalCounter"].AsDouble;
            result.status       = doc["status"].AsInt32;
            return(result);
        }
Ejemplo n.º 4
0
        public static NozzleMeasure Parse(string item)
        {
            var splited = item.Split(';');
            var result  = new NozzleMeasure();

            result.date         = DateTime.Parse(splited[0]);
            result.locationID   = Utilities.ParseToInt(splited[1]);
            result.nozzleID     = Utilities.ParseToInt(splited[2]);
            result.tankID       = Utilities.ParseToInt(splited[3]);
            result.literCounter = Utilities.ParseToFloat(splited[4]);
            result.totalCounter = Utilities.ParseToFloat(splited[5]);
            result.status       = Utilities.ParseToInt(splited[6]);
            return(result);
        }
Ejemplo n.º 5
0
 private void ReadDataNozzleMeasures(int amount)
 {
     for (int i = 0; i < amount; i++)
     {
         if (!nozzleMeasuresFile.EndOfStream)
         {
             waitingNozzleMeasures.Add(NozzleMeasure.Parse(nozzleMeasuresFile.ReadLine()));
         }
         else
         {
             return;
         }
     }
 }
Ejemplo n.º 6
0
 public NozzleMeasure GetLatestNozzleMeasure(int nozzleID)
 {
     try
     {
         BsonDocument filter = new BsonDocument()
         {
             { "nozzleID", nozzleID }
         };
         Task <BsonDocument> result = nozzleMeasuresCollection.Find(filter).SortByDescending((a) => a["date"]).FirstAsync();
         return(NozzleMeasure.Parse(result.Result));
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Ejemplo n.º 7
0
        public static BsonDocument Parse(NozzleMeasure data)
        {
            var result = new BsonDocument()
            {
                { "id", Guid.NewGuid().ToString("N") },
                { "date", data.date.ToString() },
                { "locationID", data.locationID },
                { "nozzleID", data.nozzleID },
                { "tankID", data.tankID },
                { "literCounter", data.literCounter },
                { "totalCounter", data.totalCounter },
                { "status", data.status },
            };

            return(result);
        }
Ejemplo n.º 8
0
 public async void AddNozzleMeasure(NozzleMeasure data)
 {
     await nozzleMeasuresCollection.InsertOneAsync(NozzleMeasure.Parse(data));
 }