コード例 #1
0
ファイル: Repository.cs プロジェクト: Royih/BrewMatic.WebApp
 public void UpdateRuntimeValues(BrewMaticStatus status)
 {
     var r = GetRuntimeValues();
     r.ActualTemp1 = status.Temp1;
     r.ActualTemp2 = status.Temp2;
     r.Output1 = status.OutputValue1;
     r.Output4 = status.OutputValue4;
 }
コード例 #2
0
ファイル: Repository.cs プロジェクト: Royih/BrewMatic.WebApp
        public void LogValue(BrewMaticStatus currentStatus)
        {
            var lastLog = _db.ValueLogs.OrderByDescending(x => x.Id).FirstOrDefault();
            if (lastLog == null || DateTime.Now.Subtract(lastLog.TimeStamp).TotalSeconds > 15)
            {
                _db.ValueLogs.Add(new BrewValuesLog
                {
                    Temp1 = currentStatus.Temp1,
                    Temp2 = currentStatus.Temp2,
                    Output1 = currentStatus.OutputValue1,
                    Output2 = currentStatus.OutputValue2,
                    Output3 = currentStatus.OutputValue3,
                    Output4 = currentStatus.OutputValue4,
                    TimeStamp = DateTime.Now
                });
                var count = _db.SaveChanges();
                _logger.LogDebug("{0} records saved to database", count);
            }

        }