From 19c66ffe3a8d2a2e784ba54cefc6f2566135bafa Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周五, 06 9月 2024 13:49:06 +0800 Subject: [PATCH] 清除数据 --- DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/ClearDataHandler.cs | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/ClearDataHandler.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/ClearDataHandler.cs index 88bf30f..ea64e1d 100644 --- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/ClearDataHandler.cs +++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/ClearDataHandler.cs @@ -64,5 +64,33 @@ } + + /// <summary> + /// 绉婚櫎XX澶╁墠鐨� WorkPieceLog 鏁版嵁 + /// </summary> + /// <param name="edm"></param> + public static void Delete_AccessInterfaceLogForRequest(int days) + { + try + { + using (DbModel edm = new DbModel()) + { + var queryTime = DateTime.Now.AddDays(-days); + + var removeList = edm.AccessInterfaceLogForRequest.Where(x => x.CreatedTime <= queryTime).ToList(); + if (removeList != null && removeList.Count > 0) + { + edm.AccessInterfaceLogForRequest.RemoveRange(removeList); + } + edm.SaveChanges(); + } + } + catch (Exception ex) + { + Log4NetHelper.WriteErrorLog(LogType.DeleteData, "绉婚櫎XX澶╁墠鐨� AccessInterfaceLogForRequest 鏁版嵁 鍑虹幇寮傚父", ex); + } + } + + } } \ No newline at end of file -- Gitblit v1.9.3