From f49fa4b5027cfdc27b429985d023e8002abcca2e Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期三, 05 十一月 2025 23:54:12 +0800
Subject: [PATCH] 1
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/LogJob.cs | 44 ++++++++++++++++++++++++++++++++++++++------
1 files changed, 38 insertions(+), 6 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/LogJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/LogJob.cs"
index a6cad53..b851eda 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/LogJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/LogJob.cs"
@@ -34,12 +34,10 @@
{
try
{
- while (true)
- {
- WriteLog.GetLog("LogJob").Write($"鏃ュ織璁板綍锛歿DateTime.Now}", "LogJob");
- Run(5);
- Thread.Sleep(1000 * 60);
- }
+ WriteLog.GetLog("LogJob").Write($"鏃ュ織璁板綍锛歿DateTime.Now}", "LogJob");
+ Run(10);
+ Run2(10);
+ Thread.Sleep(1000 * 10);
}
catch { }
});
@@ -85,6 +83,40 @@
}
}
}
+
+ private static void Run2(int saveDays)
+ {
+ var logPath = System.Environment.CurrentDirectory + "/txt";
+ if (Directory.Exists(logPath))
+ {
+ var nowTime = DateTime.Now;
+ var dayDir = Directory.GetDirectories(logPath, "20*", System.IO.SearchOption.AllDirectories);
+
+ foreach (var dirpath in dayDir)
+ {
+ //鏂囦欢澶瑰悕
+ var dirName = Path.GetFileName(dirpath).Replace("_", "-");
+
+ DateTime targetDate = DateTime.ParseExact(dirName, "yyyyMMdd", null);
+ if ((nowTime - targetDate).TotalDays >= saveDays)
+ {
+
+ //鍒犻櫎鏂囦欢鍜屾枃浠跺す
+ try
+ {
+ var flies = Directory.GetFiles(dirpath);
+
+ foreach (var item in flies)
+ {
+ File.Delete(item);
+ }
+ Directory.Delete(dirpath);
+ }
+ catch { }
+ }
+ }
+ }
+ }
}
--
Gitblit v1.9.3