Example #1
0
        public bool InsertMeasurementsIntoDb(List <MeasurementUnit> measurements)
        {
            bool success = true;

            try
            {
                foreach (var item in measurements)
                {
                    HistoryMeasurement h = new HistoryMeasurement
                    {
                        Gid              = item.Gid,
                        MeasurementTime  = item.TimeStamp,
                        MeasurementValue = item.CurrentValue
                    };
                    DbManager.Instance.AddHistoryMeasurement(h);
                }
                DbManager.Instance.SaveChanges();
            }
            catch (Exception e)
            {
                success = false;
                string message = string.Format("Failed to insert new Measurement into database. {0}", e.Message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
                Console.WriteLine(message);
            }

            return(success);
        }
Example #2
0
 public void AddHistoryMeasurement(HistoryMeasurement hm)
 {
     emsContext.HistoryMeasurements.Add(hm);
 }