Procházet zdrojové kódy

添加手动合并数据库

宝臣 王 před 3 měsíci
rodič
revize
8517307860

+ 12 - 1
UniformMaterialManagementSystem/Utils/DataBaseUtil.cs

@@ -19,7 +19,7 @@ namespace UniformMaterialManagementSystem.Utils
         private const string Password = "88384e6a-07e0-47e9-8214-4470a16e78da";
         private static readonly string SourcePath = $"{DataBasePath}\\UniformMaterialManagementSystem.db";
 
-        public static void ExportData()
+        public static async Task ExportData()
         {
             // 创建 SaveFileDialog 实例
             var saveFileDialog = new SaveFileDialog
@@ -39,6 +39,17 @@ namespace UniformMaterialManagementSystem.Utils
                 targetPath = saveFileDialog.FileName;
             }
 
+            // 手动合并数据库
+            await using var connection = new SqliteConnection($"Data Source={SourcePath}");
+            connection.Open();
+            
+            await using (var command = connection.CreateCommand())
+            {
+                command.CommandText = "PRAGMA wal_checkpoint(FULL);";
+                command.ExecuteNonQuery();
+            }
+            connection.Close();
+
             EncryptFile(SourcePath, targetPath);
         }