From eed621673c3efec0a6e9e4c25b3e4d65200ff60e Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周二, 02 7月 2024 15:18:56 +0800
Subject: [PATCH] 3

---
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare.config                      |   34 ++++++
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/Enums.cs                                            |    4 
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/LogTextHelper.cs                    |   16 +++
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DeleteDataHandler.cs |  144 ++++++++++++++++++++++++++++
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare - 复制用.config                |   20 ++--
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_DataCaptureV3/FormMain.cs                                 |   25 +++--
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj        |    1 
 7 files changed, 224 insertions(+), 20 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
new file mode 100644
index 0000000..8259691
--- /dev/null
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/DataCaptureHandlerV2/DeleteDataHandler.cs
@@ -0,0 +1,144 @@
+锘縰sing iWare_SCADA_BusinessLogical.BLL;
+using iWare_SCADA_BusinessLogical.Utils;
+using iWare_SCADA_Model;
+using iWare_SCADA_Model.MiddleModel;
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.Data.Entity.Core.Common.CommandTrees;
+using System.Data.Entity.Validation;
+using System.Data.SqlTypes;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Web.UI.WebControls;
+using System.Windows.Forms;
+
+namespace iWare_SCADA_BusinessLogical
+{
+    /// <summary>
+    /// 瀹氭椂鍒犻櫎鏁版嵁
+    /// </summary>
+    public class DeleteDataHandler : DataCaptureHandler
+    {
+        public static readonly DeleteDataHandler Instance = new DeleteDataHandler();
+
+        public static readonly LogType logType = LogType.DeleteData;
+
+        public DeleteDataHandler()
+        {
+        }
+
+        public override string WorkingProcedure
+        {
+            get { return _dataCaptureConfig.WorkingProcedure; }
+        }
+
+        public override string DataCapturePointCode
+        {
+            get { return _dataCaptureConfig.DataCapturePointCode; }
+        }
+        public override string DataCapturePointCname
+        {
+            get { return _dataCaptureConfig.DataCapturePointCname; }
+        }
+
+
+        public override void RefreshDataList(List<DataCaptureConfig> dataCaptureConfig)
+        {
+        }
+
+        public override void DataCaptureStart()
+        {
+            while (true)
+            {
+                try
+                {
+                    try
+                    {
+                        LogTextHelper.BatchDeleteLog();
+                    }
+                    catch (Exception ex)
+                    {
+                        Log4NetHelper.WriteErrorLog(logType, $"瀹氭椂鍒犻櫎鏃ュ織鏁版嵁寮傚父锛�", ex);
+                    }
+
+
+                    //澶勭悊OP60鐨勬暟鎹�
+                    try
+                    {
+                        LogTextHelper.BatchDeleteLog(@"Q:\Measuring_Data_df_Copy", 20);
+                    }
+                    catch (Exception ex)
+                    {
+                        Log4NetHelper.WriteErrorLog(logType, $"澶勭悊OP60鐨勬暟鎹�(Q:\\Measuring_Data_df_Copy)-瀹氭椂鍒犻櫎鏁版嵁寮傚父锛�", ex);
+                    }
+
+                    try
+                    {
+                        LogTextHelper.BatchDeleteLog(@"Q:\Measuring_Data_dfq", 20);
+                    }
+                    catch (Exception ex)
+                    {
+                        Log4NetHelper.WriteErrorLog(logType, $"澶勭悊OP60鐨勬暟鎹�(Q:\\Measuring_Data_dfq)-瀹氭椂鍒犻櫎鏁版嵁寮傚父锛�", ex);
+                    }
+
+
+                    //澶勭悊OP80鐨勬暟鎹�
+                    try
+                    {
+                        LogTextHelper.BatchDeleteLog(@"X:\CA4GC20TD_COPY", 20);
+                    }
+                    catch (Exception ex)
+                    {
+                        Log4NetHelper.WriteErrorLog(logType, $"澶勭悊OP80鐨勬暟鎹�(X:\\CA4GC20TD_COPY)-瀹氭椂鍒犻櫎鏁版嵁寮傚父锛�", ex);
+                    }
+
+                    try
+                    {
+                        LogTextHelper.BatchDeleteLog(@"X:\CA4GC20TD_Error", 60);
+                    }
+                    catch (Exception ex)
+                    {
+                        Log4NetHelper.WriteErrorLog(logType, $"澶勭悊OP80鐨勬暟鎹�(X:\\CA4GC20TD_Error)-瀹氭椂鍒犻櫎鏁版嵁寮傚父锛�", ex);
+                    }
+
+                    try
+                    {
+                        LogTextHelper.BatchDeleteLog(@"X:\CA4GC20TD_NoNum", 60);
+                    }
+                    catch (Exception ex)
+                    {
+                        Log4NetHelper.WriteErrorLog(logType, $"澶勭悊OP80鐨勬暟鎹�(X:\\CA4GC20TD_NoNum)-瀹氭椂鍒犻櫎鏁版嵁寮傚父锛�", ex);
+                    }
+
+
+
+                    try
+                    {
+                        //澶勭悊OP20鐨勬暟鎹�
+                        LogTextHelper.BatchDeleteLog(@"W:\", 20);
+                    }
+                    catch (Exception ex)
+                    {
+                        Log4NetHelper.WriteErrorLog(logType, $"澶勭悊OP20鐨勬暟鎹�-瀹氭椂鍒犻櫎鏁版嵁寮傚父锛�", ex);
+                    }
+
+
+                    Thread.Sleep(8 * 60 * 60 * 1000);//姣忓ぉ8灏忔椂涓�娆� 
+                }
+                catch (Exception ex)
+                {
+                    Log4NetHelper.WriteErrorLog(logType, $"瀹氭椂鍒犻櫎鏁版嵁寮傚父锛�", ex);
+                }
+                finally
+                {
+                }
+            }
+        }
+
+    }
+}
diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/LogTextHelper.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/LogTextHelper.cs
index 3db6aee..8023044 100644
--- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/LogTextHelper.cs
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/LogTextHelper.cs
@@ -13,6 +13,7 @@
         /// </summary>
         public static void BatchDeleteLog()
         {
+
             List<string> deleteFolder = new System.Collections.Generic.List<string>();
             string folderPath = @"d:\\Log";
             FolderHelper.ListDirectory(folderPath, 0, ref deleteFolder);
@@ -24,6 +25,21 @@
         }
 
         /// <summary>
+        /// 鎵规鍒犻櫎鏃ュ織鏂囦欢
+        /// </summary>
+        public static void BatchDeleteLog(string folderPath, int days)
+        {
+
+            List<string> deleteFolder = new System.Collections.Generic.List<string>();
+            FolderHelper.ListDirectory(folderPath, 0, ref deleteFolder);
+
+            foreach (var item in deleteFolder)
+            {
+                FileHelper.DeleteOldFiles(item, days);//鍒犻櫎涓�涓湀鐨勬暟鎹�
+            }
+        }
+
+        /// <summary>
         /// 寰�鏃ュ織閲岃拷鍔犲唴瀹�
         /// </summary>
         /// <param name="folder">鏃ュ織鐩綍</param>
diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj
index 03ff630..d945e64 100644
--- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj
@@ -83,6 +83,7 @@
     <Compile Include="BLL\SystemValue.cs" />
     <Compile Include="BLL\WorkPieceInfoManager.cs" />
     <Compile Include="BLL\WorkPieceLogManager.cs" />
+    <Compile Include="DataCaptureHandlerV2\DeleteDataHandler.cs" />
     <Compile Include="DataCaptureHandlerV2\OP80QualityDataHandler.cs" />
     <Compile Include="DataCaptureHandlerV2\DataCaptureHandler_01.cs" />
     <Compile Include="DataCaptureHandlerV2\DataCaptureHandler_OP3002.cs" />
diff --git "a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare - \345\244\215\345\210\266\347\224\250.config" "b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare - \345\244\215\345\210\266\347\224\250.config"
index 9d2ac5d..71f10d2 100644
--- "a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare - \345\244\215\345\210\266\347\224\250.config"
+++ "b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare - \345\244\215\345\210\266\347\224\250.config"
@@ -5,9 +5,9 @@
   <appSettings>
   </appSettings>
   <log4net>
-    <!--  OP80璐ㄩ噺閲囬泦绾跨▼銆愪俊鎭�戞棩蹇�-->
-    <appender name="PLCOP80_QC_Info" type="log4net.Appender.RollingFileAppender">
-      <file value="D:\\Log\\SCADALog\\PLCOP80_QC_Info\\" />
+    <!--  瀹氭湡鍒犻櫎鏁版嵁绾跨▼銆愪俊鎭�戞棩蹇�-->
+    <appender name="DeleteData_Info" type="log4net.Appender.RollingFileAppender">
+      <file value="D:\\Log\\SCADALog\\DeleteData_Info\\" />
       <appendToFile value="true" />
       <rollingStyle value="Date" />
       <staticLogFileName value="false" />
@@ -17,13 +17,13 @@
         <param name="ConversionPattern" value="%n娑堟伅鏃堕棿锛�%d [%t] %n娑堟伅绾у埆锛�%-5p %n娑� 鎭� 绫伙細%c [%x] %n%m %n "/>
       </layout>
       <filter type="log4net.Filter.LoggerMatchFilter">
-        <loggerToMatch value="PLCOP80_QC_Info" />
+        <loggerToMatch value="DeleteData_Info" />
       </filter>
       <filter type="log4net.Filter.DenyAllFilter" />
     </appender>
-    <!--OP80璐ㄩ噺閲囬泦绾跨▼銆愰敊璇�戞棩蹇�-->
-    <appender name="PLCOP80_QC_Error" type="log4net.Appender.RollingFileAppender">
-      <file value="D:\\Log\\SCADALog\\PLCOP80_QC_Error\\" />
+    <!--瀹氭湡鍒犻櫎鏁版嵁绾跨▼銆愰敊璇�戞棩蹇�-->
+    <appender name="DeleteData_Error" type="log4net.Appender.RollingFileAppender">
+      <file value="D:\\Log\\SCADALog\\DeleteData_Error\\" />
       <appendToFile value="true" />
       <rollingStyle value="Date" />
       <staticLogFileName value="false" />
@@ -33,14 +33,14 @@
         <param name="ConversionPattern" value="%n寮傚父鏃堕棿锛�%d [%t] %n寮傚父绾у埆锛�%-5p %n寮� 甯� 绫伙細%c [%x] %n%m %n "/>
       </layout>
       <filter type="log4net.Filter.LoggerMatchFilter">
-        <loggerToMatch value="PLCOP80_QC_Error" />
+        <loggerToMatch value="DeleteData_Error" />
       </filter>
       <filter type="log4net.Filter.DenyAllFilter" />
     </appender>
     <root>
       <level value="ALL"/>
-      <appender-ref ref="PLCOP80_QC_Info"/>
-      <appender-ref ref="PLCOP80_QC_Error"/>
+      <appender-ref ref="DeleteData_Info"/>
+      <appender-ref ref="DeleteData_Error"/>
     </root>
   </log4net>
 </configuration>
\ No newline at end of file
diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare.config b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare.config
index ac7cce6..23df449 100644
--- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare.config
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/log4net_iWare.config
@@ -5,6 +5,38 @@
   <appSettings>
   </appSettings>
   <log4net>
+    <!--  瀹氭湡鍒犻櫎鏁版嵁绾跨▼銆愪俊鎭�戞棩蹇�-->
+    <appender name="DeleteData_Info" type="log4net.Appender.RollingFileAppender">
+      <file value="D:\\Log\\SCADALog\\DeleteData_Info\\" />
+      <appendToFile value="true" />
+      <rollingStyle value="Date" />
+      <staticLogFileName value="false" />
+      <datePattern value="yyyy-MM-dd.LOG" />
+      <layout type="log4net.Layout.PatternLayout">
+        <!--杈撳嚭鏍煎紡-->
+        <param name="ConversionPattern" value="%n娑堟伅鏃堕棿锛�%d [%t] %n娑堟伅绾у埆锛�%-5p %n娑� 鎭� 绫伙細%c [%x] %n%m %n "/>
+      </layout>
+      <filter type="log4net.Filter.LoggerMatchFilter">
+        <loggerToMatch value="DeleteData_Info" />
+      </filter>
+      <filter type="log4net.Filter.DenyAllFilter" />
+    </appender>
+    <!--瀹氭湡鍒犻櫎鏁版嵁绾跨▼銆愰敊璇�戞棩蹇�-->
+    <appender name="DeleteData_Error" type="log4net.Appender.RollingFileAppender">
+      <file value="D:\\Log\\SCADALog\\DeleteData_Error\\" />
+      <appendToFile value="true" />
+      <rollingStyle value="Date" />
+      <staticLogFileName value="false" />
+      <datePattern value="yyyy-MM-dd.LOG" />
+      <layout type="log4net.Layout.PatternLayout">
+        <!--杈撳嚭鏍煎紡-->
+        <param name="ConversionPattern" value="%n寮傚父鏃堕棿锛�%d [%t] %n寮傚父绾у埆锛�%-5p %n寮� 甯� 绫伙細%c [%x] %n%m %n "/>
+      </layout>
+      <filter type="log4net.Filter.LoggerMatchFilter">
+        <loggerToMatch value="DeleteData_Error" />
+      </filter>
+      <filter type="log4net.Filter.DenyAllFilter" />
+    </appender>
     <!--  OP80璐ㄩ噺閲囬泦绾跨▼銆愪俊鎭�戞棩蹇�-->
     <appender name="PLCOP80_QC_Info" type="log4net.Appender.RollingFileAppender">
       <file value="D:\\Log\\SCADALog\\PLCOP80_QC_Info\\" />
@@ -493,6 +525,8 @@
     </appender>
     <root>
       <level value="ALL"/>
+      <appender-ref ref="DeleteData_Info"/>
+      <appender-ref ref="DeleteData_Error"/>
       <appender-ref ref="PLCOP80_QC_Info"/>
       <appender-ref ref="PLCOP80_QC_Error"/>
       <appender-ref ref="FormMain_Info"/>
diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_DataCaptureV3/FormMain.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_DataCaptureV3/FormMain.cs
index 639e6e0..f2ccc8c 100644
--- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_DataCaptureV3/FormMain.cs
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_DataCaptureV3/FormMain.cs
@@ -1533,6 +1533,11 @@
                 //OP80鐨勮幏鍙栬川閲忔暟鎹� 銆怑ditby shaocx,2024-06-15銆�
                 OP80QualityDataHandler op80QualityDataHandler = new OP80QualityDataHandler();
                 _dataCaptureHandler.Add(op80QualityDataHandler);
+
+                //瀹氭湡鍒犻櫎鏁版嵁 銆怑ditby shaocx,2024-06-15銆�
+                DeleteDataHandler _deleteDataHandler = new DeleteDataHandler();
+                _dataCaptureHandler.Add(_deleteDataHandler);
+
                 #endregion
 
                 try
@@ -1842,20 +1847,20 @@
                     switch (config.DataCapturePointCode)
                     {
                         case "OP3002CH3":
-                        //case "OP3002CH4":
-                        //case "OP3002CH5":
-                        //case "OP3002CH6":
+                            //case "OP3002CH4":
+                            //case "OP3002CH5":
+                            //case "OP3002CH6":
                             DataCaptureHandler_02 dc02 = new DataCaptureHandler_02();
                             dc02._dataCaptureConfig = config;
                             _dataCaptureHandler.Add(dc02);
                             break;
-                        //case "OP2002A":
-                        //    //case "OP2002B":
-                        //    //case "OP2002C":
-                        //    DataCaptureHandler_02 dc02 = new DataCaptureHandler_02();
-                        //    dc02._dataCaptureConfig = config;
-                        //    _dataCaptureHandler.Add(dc02);
-                        //    break;
+                            //case "OP2002A":
+                            //    //case "OP2002B":
+                            //    //case "OP2002C":
+                            //    DataCaptureHandler_02 dc02 = new DataCaptureHandler_02();
+                            //    dc02._dataCaptureConfig = config;
+                            //    _dataCaptureHandler.Add(dc02);
+                            //    break;
                             //case "OP6002":
                             //    DataCaptureHandler_OP6002.Instance._dataCaptureConfig = config;
                             //    _dataCaptureHandler.Add(DataCaptureHandler_OP6002.Instance);
diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/Enums.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/Enums.cs
index 6918457..cf5eca5 100644
--- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/Enums.cs
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/Enums.cs
@@ -212,6 +212,10 @@
         #endregion
 
 
+        /// <summary>
+        /// 瀹氭椂鍒犻櫎鏁版嵁
+        /// </summary>
+        DeleteData = 500,
 
 
     }

--
Gitblit v1.9.3