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/DataCaptureHandlerV2/DeleteDataHandler.cs |    2 +
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/AccessInterfaceLogForRequest.cs          |   73 ++++++++++++++++++++++++++++++++++++
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/iWare_SCADA_Model.csproj                            |    1 
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/ClearDataHandler.cs                 |   28 ++++++++++++++
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/DbModel.cs                               |    4 -
 5 files changed, 105 insertions(+), 3 deletions(-)

diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DeleteDataHandler.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DeleteDataHandler.cs
index 8cf6b36..477627c 100644
--- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DeleteDataHandler.cs
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DeleteDataHandler.cs
@@ -74,6 +74,8 @@
 
                         ClearDataHandler.Delete_WorkPieceLog(7);
 
+                        ClearDataHandler.Delete_AccessInterfaceLogForRequest(7);
+
                         Log4NetHelper.WriteInfoLog(logType, $"瀹氭椂鍒犻櫎琛ㄦ暟鎹垚鍔燂細");
                     }
                     catch (Exception ex)
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
diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/AccessInterfaceLogForRequest.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/AccessInterfaceLogForRequest.cs
new file mode 100644
index 0000000..e27687c
--- /dev/null
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/AccessInterfaceLogForRequest.cs
@@ -0,0 +1,73 @@
+namespace iWare_SCADA_Model
+{
+    using System;
+    using System.Collections.Generic;
+    using System.ComponentModel.DataAnnotations;
+    using System.ComponentModel.DataAnnotations.Schema;
+    using System.Data.Entity.Spatial;
+
+    [Table("AccessInterfaceLogForRequest")]
+    public partial class AccessInterfaceLogForRequest
+    {
+        [Key]
+        [Column(Order = 0)]
+        [DatabaseGenerated(DatabaseGeneratedOption.None)]
+        public long Id { get; set; }
+
+        [Key]
+        [Column(Order = 1)]
+        [DatabaseGenerated(DatabaseGeneratedOption.None)]
+        public int Action { get; set; }
+
+        [StringLength(200)]
+        public string OperateAddress { get; set; }
+
+        [StringLength(200)]
+        public string OperateUserId { get; set; }
+
+        [StringLength(200)]
+        public string OperateUserName { get; set; }
+
+        [StringLength(50)]
+        public string IPAddress { get; set; }
+
+        [StringLength(200)]
+        public string Param1 { get; set; }
+
+        [StringLength(200)]
+        public string Param2 { get; set; }
+
+        [StringLength(200)]
+        public string Param3 { get; set; }
+
+        public string ParaJSON { get; set; }
+
+        public string ResultJson { get; set; }
+
+        public string Keys { get; set; }
+
+        public DateTimeOffset? CreatedTime { get; set; }
+
+        public DateTimeOffset? UpdatedTime { get; set; }
+
+        public long? CreatedUserId { get; set; }
+
+        [StringLength(50)]
+        public string CreatedUserName { get; set; }
+
+        public long? UpdatedUserId { get; set; }
+
+        [StringLength(50)]
+        public string UpdatedUserName { get; set; }
+
+        [Key]
+        [Column(Order = 2)]
+        public bool IsDeleted { get; set; }
+
+        [StringLength(255)]
+        public string WorkPieceID { get; set; }
+
+        [StringLength(255)]
+        public string WorkingProcedureCurrent { get; set; }
+    }
+}
diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/DbModel.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/DbModel.cs
index 977cac8..419bd7f 100644
--- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/DbModel.cs
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/DbModel.cs
@@ -1,8 +1,5 @@
 using iWare_SCADA_Model.TableModel;
-using System;
-using System.ComponentModel.DataAnnotations.Schema;
 using System.Data.Entity;
-using System.Linq;
 
 namespace iWare_SCADA_Model
 {
@@ -13,6 +10,7 @@
         {
         }
 
+        public virtual DbSet<AccessInterfaceLogForRequest> AccessInterfaceLogForRequest { get; set; }
         public virtual DbSet<DataCaptureColumnConfig> DataCaptureColumnConfig { get; set; }
         public virtual DbSet<DataCaptureConfig> DataCaptureConfig { get; set; }
         public virtual DbSet<EquipmentBaseInfo> EquipmentBaseInfo { get; set; }
diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/iWare_SCADA_Model.csproj b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/iWare_SCADA_Model.csproj
index a3b21b6..156303a 100644
--- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/iWare_SCADA_Model.csproj
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/iWare_SCADA_Model.csproj
@@ -99,6 +99,7 @@
     <Compile Include="TableModel\WorkPieceLog.cs" />
     <Compile Include="TableModel\WorkPieceProcess.cs" />
     <Compile Include="TableModel\ThreadStatusMonitor.cs" />
+    <Compile Include="TableModel\AccessInterfaceLogForRequest.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="App.Config" />

--
Gitblit v1.9.3