コード例 #1
0
        public void Persist(LogpFile log)
        {
            var firstItem = log.Items.OrderBy(x => x.TimeStamp()).First();
            var lastItem  = log.Items.OrderByDescending(x => x.TimeStamp()).First();

            var logger = DemandLogger(log.Header.SerialNumber, log.Header.LoggerName);

            var existing = Query.All <MeasurementDownload>()
                           .Any(x => x.Logger.SerialNumber == log.Header.SerialNumber && x.StartTime.Date == firstItem.TimeStamp().Date);

            if (existing)
            {
                throw new InvalidOperationException($"Data for logger {log.Header.SerialNumber} already imported for {firstItem.TimeStamp().Date}");
            }

            var startTime    = firstItem.TimeStamp();
            var endTime      = lastItem.TimeStamp();
            var downloadTime = endTime;
            var dl           = new MeasurementDownload(logger, downloadTime, startTime, endTime);

            foreach (var li in log.Items)
            {
                var mi = new Measurement(dl, li.TimeStamp(), Convert.ToDecimal(li.Temperature));
            }
        }
コード例 #2
0
 public Measurement(MeasurementDownload download, DateTime timestamp, decimal temperature)
 {
     Download    = download;
     Timestamp   = timestamp;
     Temperature = temperature;
 }