Esempio n. 1
0
 public List <Location> GetLocations()
 {
     using (var context = new DRUSContext())
     {
         return(context.Locations.ToList());
     }
 }
Esempio n. 2
0
 public List <Measurer> GetClients()
 {
     using (var context = new DRUSContext())
     {
         return(context.Measurers.ToList());
     }
 }
Esempio n. 3
0
        public List <Measurement> GetMeasurementDate(Guid MeasurerId, DateTime fromm, DateTime to)
        {
            using (var context = new DRUSContext())
            {
                var res =
                    from m in context.Measurements
                    where m.Measurer.Id == MeasurerId && m.Time <to && m.Time> fromm
                    select m;

                return(res.ToList());
            }
        }
Esempio n. 4
0
        public Measurer RegisterMeasurer()
        {
            Measurer measurer = new Measurer();
            Random   rand     = new Random();

            using (var context = new DRUSContext())
            {
                // Dodeli mu random lokaciju
                int loc       = rand.Next(context.Locations.Count());
                var locations = context.Locations.ToArray();
                measurer.LocationId = locations.ElementAt(loc).Id;
                measurer.Name       = rand.Next().ToString();
                Measurer m = context.Measurers.Add(measurer);
                context.SaveChanges();
                return(m);
            }
        }
Esempio n. 5
0
        public void AddMeasurement(Measurement measurement)
        {
            using (var context = new DRUSContext())
            {
                context.Measurements.Add(measurement);
                context.SaveChanges();
            }

            /*
             * if (observers.ContainsKey(measurement.Measurer.Id))
             *  foreach (var observerForClient in observers[measurement.Measurer.Id])
             *  {
             *
             *          try
             *          {
             *              observerForClient.BroadcastToObserver(measurement);
             *          }
             *          catch (Exception ex)
             *          {
             *              observers[measurement.Measurer.Id].Remove(observerForClient);
             *          }
             *  }*/
        }
Esempio n. 6
0
        public List <Measurement> GetLocationValue(Guid LocationId, bool graterThen, double value)
        {
            using (var context = new DRUSContext())
            {
                if (graterThen == true)
                {
                    var res =
                        from m in context.Measurements
                        where m.Measurer.LocationId == LocationId && (m.Temperature > value || m.Humidity > value)
                        select m;

                    return(res.ToList());
                }
                else
                {
                    var res =
                        from m in context.Measurements
                        where m.Measurer.LocationId == LocationId && (m.Temperature < value || m.Humidity < value)
                        select m;

                    return(res.ToList());
                }
            }
        }