提交记录修改Core/Servicers/Instances/Data.cs+10 −28看文件
修改Core/Servicers/Interfaces/IData.cs+3 −10看文件
修改UI/ViewModels/DetailPageVM.cs+6 −4看文件
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | using Core.Librarys.SQLite; |
| 2 | 2 | using Core.Models; |
| 3 | 新增:using Core.Models.Config; | |
| 3 | 4 | using Core.Servicers.Interfaces; |
| 4 | 5 | using System; |
| 5 | 6 | using System.Collections.Generic; |
| @@ -11,10 +12,9 @@ namespace Core.Servicers.Instances | ||
| 11 | 12 | { |
| 12 | 13 | public class Data : IData |
| 13 | 14 | { |
| 14 | 删除: | |
| 15 | 15 | public void Set(string processName, string processDescription, string file, int seconds) |
| 16 | 16 | { |
| 17 | 删除: if (string.IsNullOrEmpty(processName) || string.IsNullOrEmpty(file) || seconds <= 0) | |
| 17 | 新增: if (string.IsNullOrEmpty(processName) || seconds <= 0) | |
| 18 | 18 | { |
| 19 | 19 | return; |
| 20 | 20 | } |
| @@ -22,7 +22,7 @@ namespace Core.Servicers.Instances | ||
| 22 | 22 | using (var db = new StatisticContext()) |
| 23 | 23 | { |
| 24 | 24 | var today = DateTime.Now.Date; |
| 25 | 删除: var res = db.DailyLog.SingleOrDefault(m => m.Date == today && m.ProcessName == processName && m.ProcessDescription == processDescription && m.File == file); | |
| 25 | 新增: var res = db.DailyLog.SingleOrDefault(m => m.Date == today && m.ProcessName == processName); | |
| 26 | 26 | if (res == null) |
| 27 | 27 | { |
| 28 | 28 | //数据库中没有时则创建 |
| @@ -48,7 +48,7 @@ namespace Core.Servicers.Instances | ||
| 48 | 48 | m => |
| 49 | 49 | m.DataTime == nowtime |
| 50 | 50 | && m.ProcessName == processName |
| 51 | 删除: && m.File == file); | |
| 51 | 新增: ); | |
| 52 | 52 | if (hourslog == null) |
| 53 | 53 | { |
| 54 | 54 | // 没有时创建 |
| @@ -85,7 +85,7 @@ namespace Core.Servicers.Instances | ||
| 85 | 85 | using (var db = new StatisticContext()) |
| 86 | 86 | { |
| 87 | 87 | var today = DateTime.Now.Date; |
| 88 | 删除: var res = db.DailyLog.SqlQuery("Select Sum(Time) as Time,ProcessName,File,ID,Date,ProcessDescription from DailyLogModels WHERE Date between '" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' AND '" + end.ToString("yyyy-MM-dd HH:mm:ss") + "' GROUP BY ProcessName,File ").ToList(); | |
| 88 | 新增: var res = db.DailyLog.SqlQuery("Select Sum(Time) as Time,ProcessName,File,ID,Date,ProcessDescription from DailyLogModels WHERE Date between '" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' AND '" + end.ToString("yyyy-MM-dd HH:mm:ss") + "' GROUP BY ProcessName ").ToList(); | |
| 89 | 89 | return res.ToList(); |
| 90 | 90 | } |
| 91 | 91 | } |
| @@ -162,7 +162,7 @@ namespace Core.Servicers.Instances | ||
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 删除: public List<DailyLogModel> GetProcessMonthLogList(string file, DateTime month) | |
| 165 | 新增: public List<DailyLogModel> GetProcessMonthLogList(string processName, DateTime month) | |
| 166 | 166 | { |
| 167 | 167 | using (var db = new StatisticContext()) |
| 168 | 168 | { |
| @@ -171,9 +171,9 @@ namespace Core.Servicers.Instances | ||
| 171 | 171 | m => |
| 172 | 172 | m.Date.Year == month.Year |
| 173 | 173 | && m.Date.Month == month.Month |
| 174 | 删除: //&& m.ProcessName == processName | |
| 174 | 新增: && m.ProcessName == processName | |
| 175 | 175 | //&& m.ProcessDescription == processDescription |
| 176 | 删除: && m.File == file | |
| 176 | 新增: //&& m.File == file | |
| 177 | 177 | ); |
| 178 | 178 | if (res != null) |
| 179 | 179 | { |
| @@ -183,26 +183,10 @@ namespace Core.Servicers.Instances | ||
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 删除: public DailyLogModel GetLast(string file) | |
| 187 | 删除: { | |
| 188 | 删除: using (var db = new StatisticContext()) | |
| 189 | 删除: { | |
| 190 | 186 | |
| 191 | 删除: var res = db.DailyLog.Where( | |
| 192 | 删除: m => | |
| 193 | 删除: m.File == file | |
| 194 | 删除: ).OrderByDescending(m => m.ID).Take(1); | |
| 195 | 删除: if (res != null) | |
| 196 | 删除: { | |
| 197 | 删除: return res.FirstOrDefault(); | |
| 198 | 删除: } | |
| 199 | 删除: return null; | |
| 200 | 删除: } | |
| 201 | 删除: } | |
| 202 | 删除: | |
| 203 | 删除: public void Clear(string processName, string file, DateTime month) | |
| 187 | 新增: public void Clear(string processName, DateTime month) | |
| 204 | 188 | { |
| 205 | 删除: if (string.IsNullOrEmpty(processName) || string.IsNullOrEmpty(file)) | |
| 189 | 新增: if (string.IsNullOrEmpty(processName)) | |
| 206 | 190 | { |
| 207 | 191 | return; |
| 208 | 192 | } |
| @@ -212,10 +196,8 @@ namespace Core.Servicers.Instances | ||
| 212 | 196 | db.DailyLog.RemoveRange( |
| 213 | 197 | db.DailyLog.Where(m => |
| 214 | 198 | m.ProcessName == processName |
| 215 | 删除: && m.File == file | |
| 216 | 199 | && m.Date.Year == month.Year |
| 217 | 200 | && m.Date.Month == month.Month)); |
| 218 | 删除: | |
| 219 | 201 | db.SaveChanges(); |
| 220 | 202 | } |
| 221 | 203 | } |
| @@ -51,24 +51,17 @@ namespace Core.Servicers.Interfaces | ||
| 51 | 51 | /// <summary> |
| 52 | 52 | /// 获取指定进程某个月的数据 |
| 53 | 53 | /// </summary> |
| 54 | 删除: /// <param name="file"></param> | |
| 54 | 新增: /// <param name="processName"></param> | |
| 55 | 55 | /// <param name="month"></param> |
| 56 | 56 | /// <returns></returns> |
| 57 | 删除: List<DailyLogModel> GetProcessMonthLogList(string file, DateTime month); | |
| 57 | 新增: List<DailyLogModel> GetProcessMonthLogList(string processName, DateTime month); | |
| 58 | 58 | |
| 59 | 删除: /// <summary> | |
| 60 | 删除: /// 获取一个进程最后一条记录 | |
| 61 | 删除: /// </summary> | |
| 62 | 删除: /// <param name="file"></param> | |
| 63 | 删除: /// <returns></returns> | |
| 64 | 删除: DailyLogModel GetLast(string file); | |
| 65 | 59 | |
| 66 | 60 | /// <summary> |
| 67 | 61 | /// 清空指定进程某月的数据 |
| 68 | 62 | /// </summary> |
| 69 | 63 | /// <param name="processName"></param> |
| 70 | 删除: /// <param name="file"></param> | |
| 71 | 删除: void Clear(string processName, string file, DateTime month); | |
| 64 | 新增: void Clear(string processName, DateTime month); | |
| 72 | 65 | |
| 73 | 66 | /// <summary> |
| 74 | 67 | /// 获取指定进程某天的数据 |
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | using Core.Librarys; |
| 2 | 新增:using Core.Models; | |
| 2 | 3 | using Core.Models.Config; |
| 3 | 4 | using Core.Servicers.Interfaces; |
| 4 | 5 | using System; |
| @@ -126,7 +127,7 @@ namespace UI.ViewModels | ||
| 126 | 127 | { |
| 127 | 128 | if (Process != null) |
| 128 | 129 | { |
| 129 | 删除: var info = data.GetLast(Process.PopupText); | |
| 130 | 新增: var info = Process.Data as DailyLogModel; | |
| 130 | 131 | if (info != null) |
| 131 | 132 | { |
| 132 | 133 | ProcessName = info.ProcessName; |
| @@ -186,8 +187,8 @@ namespace UI.ViewModels | ||
| 186 | 187 | { |
| 187 | 188 | if (Process != null) |
| 188 | 189 | { |
| 189 | 删除: | |
| 190 | 删除: var monthData = data.GetProcessMonthLogList(Process.PopupText, Date); | |
| 190 | 新增: var info = Process.Data as DailyLogModel; | |
| 191 | 新增: var monthData = data.GetProcessMonthLogList(info.ProcessName, Date); | |
| 191 | 192 | int monthTotal = monthData.Sum(m => m.Time); |
| 192 | 193 | Total = Timer.Fromat(monthTotal); |
| 193 | 194 | |
| @@ -232,7 +233,7 @@ namespace UI.ViewModels | ||
| 232 | 233 | if (Process != null) |
| 233 | 234 | { |
| 234 | 235 | main.Toast("正在处理"); |
| 235 | 删除: data.Clear(ProcessName, Process.PopupText, Date); | |
| 236 | 新增: data.Clear(ProcessName, Date); | |
| 236 | 237 | |
| 237 | 238 | await LoadData(); |
| 238 | 239 | await LoadInfo(); |
| @@ -250,6 +251,7 @@ namespace UI.ViewModels | ||
| 250 | 251 | foreach (var item in list) |
| 251 | 252 | { |
| 252 | 253 | var bindModel = new ChartsDataModel(); |
| 254 | 新增: bindModel.Data = item; | |
| 253 | 255 | bindModel.Name = string.IsNullOrEmpty(item.ProcessDescription) ? item.ProcessName : item.ProcessDescription; |
| 254 | 256 | bindModel.Value = item.Time; |
| 255 | 257 | bindModel.Tag = Timer.Fromat(item.Time); |

