|
@@ -19,7 +19,7 @@ namespace UniformMaterialManagementSystem.Utils
|
|
private const string Password = "88384e6a-07e0-47e9-8214-4470a16e78da";
|
|
private const string Password = "88384e6a-07e0-47e9-8214-4470a16e78da";
|
|
private static readonly string SourcePath = $"{DataBasePath}\\UniformMaterialManagementSystem.db";
|
|
private static readonly string SourcePath = $"{DataBasePath}\\UniformMaterialManagementSystem.db";
|
|
|
|
|
|
- public static async Task ExportData()
|
|
|
|
|
|
+ public static async Task<bool> ExportData()
|
|
{
|
|
{
|
|
// 创建 SaveFileDialog 实例
|
|
// 创建 SaveFileDialog 实例
|
|
var saveFileDialog = new SaveFileDialog
|
|
var saveFileDialog = new SaveFileDialog
|
|
@@ -31,26 +31,16 @@ namespace UniformMaterialManagementSystem.Utils
|
|
FileName = "被装数据包" // 设置默认文件名
|
|
FileName = "被装数据包" // 设置默认文件名
|
|
};
|
|
};
|
|
|
|
|
|
- var targetPath = string.Empty;
|
|
|
|
// 显示对话框并检查用户是否选择了文件
|
|
// 显示对话框并检查用户是否选择了文件
|
|
- if (saveFileDialog.ShowDialog() == true)
|
|
|
|
- {
|
|
|
|
- // 获取选中的文件路径
|
|
|
|
- targetPath = saveFileDialog.FileName;
|
|
|
|
- }
|
|
|
|
|
|
+ if (saveFileDialog.ShowDialog() == false)
|
|
|
|
+ return false;
|
|
|
|
|
|
- // 手动合并数据库
|
|
|
|
- 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();
|
|
|
|
|
|
+ // 获取选中的文件路径
|
|
|
|
+ var targetPath = saveFileDialog.FileName;
|
|
|
|
|
|
EncryptFile(SourcePath, targetPath);
|
|
EncryptFile(SourcePath, targetPath);
|
|
|
|
+
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
public static async void ExportTable<T>(IEnumerable<T> sourceData, string tableName, bool isExecMigrate = false) where T : class?
|
|
public static async void ExportTable<T>(IEnumerable<T> sourceData, string tableName, bool isExecMigrate = false) where T : class?
|
|
@@ -119,6 +109,7 @@ namespace UniformMaterialManagementSystem.Utils
|
|
}
|
|
}
|
|
|
|
|
|
connection.Close();
|
|
connection.Close();
|
|
|
|
+ SqliteConnection.ClearAllPools();
|
|
}
|
|
}
|
|
|
|
|
|
public static string ImportData()
|
|
public static string ImportData()
|
|
@@ -134,11 +125,11 @@ namespace UniformMaterialManagementSystem.Utils
|
|
var sourcePath = string.Empty;
|
|
var sourcePath = string.Empty;
|
|
|
|
|
|
// 显示对话框并检查用户是否选择了文件
|
|
// 显示对话框并检查用户是否选择了文件
|
|
- if (openFileDialog.ShowDialog() == true)
|
|
|
|
- {
|
|
|
|
- // 获取选中的文件路径
|
|
|
|
- sourcePath = openFileDialog.FileName;
|
|
|
|
- }
|
|
|
|
|
|
+ if (openFileDialog.ShowDialog() == false)
|
|
|
|
+ return sourcePath;
|
|
|
|
+
|
|
|
|
+ // 获取选中的文件路径
|
|
|
|
+ sourcePath = openFileDialog.FileName;
|
|
|
|
|
|
CreateExportFolder();
|
|
CreateExportFolder();
|
|
|
|
|
|
@@ -202,6 +193,7 @@ namespace UniformMaterialManagementSystem.Utils
|
|
}
|
|
}
|
|
|
|
|
|
connection.Close();
|
|
connection.Close();
|
|
|
|
+ SqliteConnection.ClearAllPools();
|
|
}
|
|
}
|
|
|
|
|
|
public static async Task<IEnumerable<T>> QueryAll<T>(string path, Func<IQueryable<T>, IQueryable<T>>? includeFunc = null) where T : class
|
|
public static async Task<IEnumerable<T>> QueryAll<T>(string path, Func<IQueryable<T>, IQueryable<T>>? includeFunc = null) where T : class
|