2 Комити bb6a5b2f87 ... e22e499169

Аутор SHA1 Порука Датум
  宝臣 王 e22e499169 添加手动合并数据库 пре 3 месеци
  宝臣 王 8517307860 添加手动合并数据库 пре 3 месеци

+ 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);
         }
 

+ 2 - 2
UniformMaterialManagementSystem/ViewModels/ContractPageViewModel.cs

@@ -575,7 +575,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         /// 导出数据包
         /// </summary>
         [RelayCommand]
-        private void ExportDataPacket()
+        private async Task ExportDataPacket()
         {
             if (UnExportContracts.Count == 0) return;
 
@@ -647,7 +647,7 @@ namespace UniformMaterialManagementSystem.ViewModels
             }
 
             //对导出数据进行加密,用户选择保存位置
-            DataBaseUtil.ExportData();
+           await DataBaseUtil.ExportData();
         }
 
         /// <summary>