From 80776f1c7ea3428e71c50e6382844c2320732314 Mon Sep 17 00:00:00 2001 From: SoulStar Date: Fri, 2 Aug 2024 11:16:50 +0800 Subject: [PATCH] =?UTF-8?q?chnage=20-=20=E6=97=B6=E9=97=B4=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SynPlc/Worker.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SynPlc/Worker.cs b/SynPlc/Worker.cs index dcee1e6..3cb041a 100644 --- a/SynPlc/Worker.cs +++ b/SynPlc/Worker.cs @@ -46,13 +46,15 @@ public class Worker : BackgroundService // var operateResult = await S7.ConnectServerAsync(); // if (!operateResult.IsSuccess) XTrace.WriteLine("连接失败"); + DateTime timeNow = DateTime.Now; + var list = await dbClient.Queryable().ToListAsync(stoppingToken); foreach (var e in list) { var a = await S7.ReadBoolAsync(e.Point); if (a.IsSuccess) { - e.UpdateTime = DateTime.Now; + e.UpdateTime = timeNow; e.PValue = a.Content; await dbClient.Updateable(e).UpdateColumns(x => new { x.UpdateTime, x.PValue }) .ExecuteCommandAsync(stoppingToken); @@ -76,7 +78,7 @@ public class Worker : BackgroundService { ID = Guid.NewGuid().ToString(), PID = e.ID, - CreateTime = DateTime.Now, + CreateTime = timeNow, Data = Math.Round(Convert.ToDecimal(a.Content), 2) }; XTrace.WriteLine("Point:{0}, Value:{1}", e.Point, listd.Data);