diff --git a/Core/Servicers/Instances/Data.cs b/Core/Servicers/Instances/Data.cs index 4f3315bbfc29e66c9dc326496018ff55a0f6bbdd..14f93d962f18c47feaa42bb01c3ab4e97bda5271 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 a9ebc037137b51f927a90060b38f681617a25984..7521aaf302232a293cabb0fbd9705111f3a9d366 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); } }