From a3df5d33e5ae76e3e24c29d21751a79390cbf644 Mon Sep 17 00:00:00 2001 From: noberumotto Date: Sun, 26 Dec 2021 06:36:29 +0800 Subject: [PATCH] =?UTF-8?q?=E2=80=9CIData=E2=80=9D=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E8=BF=9B=E7=A8=8B=E6=9F=90=E6=9C=88=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E3=80=81=E8=8E=B7=E5=8F=96=E8=BF=9B=E7=A8=8B=E6=9F=90?= =?UTF-8?q?=E6=97=A5=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/Servicers/Instances/Data.cs | 39 ++++++++++++++++++++++++++++++ Core/Servicers/Interfaces/IData.cs | 14 +++++++++++ 2 files changed, 53 insertions(+) diff --git a/Core/Servicers/Instances/Data.cs b/Core/Servicers/Instances/Data.cs index 4f3315b..14f93d9 100644 --- a/Core/Servicers/Instances/Data.cs +++ b/Core/Servicers/Instances/Data.cs @@ -160,5 +160,44 @@ namespace Core.Servicers.Instances return null; } } + + public void Clear(string processName, string file, DateTime month) + { + if (string.IsNullOrEmpty(processName) || string.IsNullOrEmpty(file)) + { + return; + } + using (var db = new StatisticContext()) + { + + db.DailyLog.RemoveRange( + db.DailyLog.Where(m => + m.ProcessName == processName + && m.File == file + && m.Date.Year == month.Year + && m.Date.Month == month.Month)); + + db.SaveChanges(); + } + } + + public DailyLogModel GetProcess(string processName, DateTime day) + { + using (var db = new StatisticContext()) + { + + + var res = db.DailyLog.Where(m => + m.ProcessName == processName + && m.Date.Year == day.Year + && m.Date.Month == day.Month + && m.Date.Day == day.Day); + if (res != null) + { + return res.FirstOrDefault(); + } + return null; + } + } } } diff --git a/Core/Servicers/Interfaces/IData.cs b/Core/Servicers/Interfaces/IData.cs index a9ebc03..7521aaf 100644 --- a/Core/Servicers/Interfaces/IData.cs +++ b/Core/Servicers/Interfaces/IData.cs @@ -63,5 +63,19 @@ namespace Core.Servicers.Interfaces /// DailyLogModel GetLast(string file); + /// + /// 清空指定进程某月的数据 + /// + /// + /// + void Clear(string processName, string file, DateTime month); + + /// + /// 获取指定进程某天的数据 + /// + /// + /// + /// + DailyLogModel GetProcess(string processName, DateTime day); } } -- GitLab