From e81c782b3e7a632ffb8e32be56fce931a8c89ae6 Mon Sep 17 00:00:00 2001
From: xiazhengtongxue <133085197+xiazhengtongxue@users.noreply.github.com>
Date: 星期一, 09 二月 2026 08:55:42 +0800
Subject: [PATCH] 修复bug
---
项目代码/WCSServices/WIDESEAWCS_SystemServices/Sys_LogService.cs | 41 ++++-------------------------------------
1 files changed, 4 insertions(+), 37 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_SystemServices/Sys_LogService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_SystemServices/Sys_LogService.cs"
index c3e3d19..9097c5d 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_SystemServices/Sys_LogService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_SystemServices/Sys_LogService.cs"
@@ -154,7 +154,7 @@
private const double FragmentationThreshold = 30.0; // 30%纰庣墖鐜囬槇鍊�
private const int MaintenanceIntervalDays = 15; // 15澶╂墽琛屼竴娆�
private const int BackupRetentionDays = 30; // 澶囦唤淇濈暀30澶�
- private const string BackupBasePath = @"D:\DatabaseBackups"; // 澶囦唤鏂囦欢瀛樺偍鐩綍
+ private static readonly string BackupBasePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DatabaseBackups"); // 澶囦唤鏂囦欢瀛樺偍鐩綍
private const bool UseBackupCompression = true; // 鏄惁浣跨敤澶囦唤鍘嬬缉
private const bool VerifyBackup = true; // 鏄惁楠岃瘉澶囦唤
private const int MaxBackupRetryCount = 3; // 鏈�澶ч噸璇曟鏁�
@@ -237,7 +237,7 @@
connection.Open();
// 1. 澶囦唤鏁版嵁搴�
- BackupDatabase();
+ //BackupDatabase();
// 2. 妫�鏌ユ暟鎹簱鏂囦欢澶у皬
CheckDatabaseFileSize(connection);
@@ -249,7 +249,7 @@
UpdateStatistics(connection);
// 5. 娓呯悊鏃у浠�
- CleanupOldBackups();
+ //CleanupOldBackups();
// 鏇存柊鏈�鍚庢鏌ユ棩鏈�
lock (_fileSizeLock)
@@ -307,14 +307,6 @@
fileCount = Convert.ToInt32(reader["FileCount"]);
}
}
-
-
- // 妫�鏌ョ鐩樼┖闂存槸鍚﹁冻澶�
- if (!CheckDiskSpace(backupFilePath, totalSizeMB))
- {
- throw new Exception("纾佺洏绌洪棿涓嶈冻锛屾棤娉曟墽琛屽浠�");
- }
-
// 鏋勫缓澶囦唤SQL璇彞
var backupSql = BuildBackupSql(backupFilePath);
@@ -337,30 +329,6 @@
Console.WriteLine($"鏁版嵁搴撳浠藉け璐�: {ex.Message}");
throw new Exception($"鏁版嵁搴撳浠藉け璐�: {ex.Message}", ex);
}
- }
- }
-
- private bool CheckDiskSpace(string backupFilePath, double estimatedBackupSizeMB)
- {
- try
- {
- var driveInfo = new DriveInfo(Path.GetPathRoot(backupFilePath));
- var freeSpaceMB = driveInfo.AvailableFreeSpace / (1024 * 1024);
-
- // 闇�瑕佽嚦灏�1.5鍊嶇殑绌洪棿鏉ョ‘淇濆浠介『鍒╄繘琛�
- var requiredSpaceMB = estimatedBackupSizeMB * 1.5;
-
- if (freeSpaceMB < requiredSpaceMB)
- {
- return false;
- }
-
- return true;
- }
- catch (Exception ex)
- {
- Console.WriteLine($"妫�鏌ョ鐩樼┖闂存椂鍑洪敊: {ex.Message}");
- return false;
}
}
@@ -507,9 +475,8 @@
{
return false;
}
-
// 妫�鏌ユ椂闂存槸鍚︽槸1鐐瑰乏鍙筹紙鍏佽1:00-1:59锛�
- if (now.Hour != 1)
+ if (now.Hour != 1 && now.Hour != 2)
{
return false;
}
--
Gitblit v1.9.3