分析模块重新调整

This commit is contained in:
2026-03-26 06:50:22 +08:00
parent 8cd16929a3
commit 8c105c5068
62 changed files with 447 additions and 949 deletions

View File

@@ -317,5 +317,43 @@ namespace CaeKnowledge
}
public static Type ObjectIdType => typeof(ObjectId);
// Luke 2026-3-25
public static void SaveDatabase(string fullPath, List<ProcessingJob> jobs)
{
try
{
using (var db = new LiteDatabase(fullPath))
{
var col = db.GetCollection<ProcessingJob>("jobs");
col.DeleteAll();
col.InsertBulk(jobs);
}
}
catch (Exception ex)
{
ExceptionTools.Show(ex);
}
}
public static List<ProcessingJob> LoadDatabase(string fullPath)
{
try
{
using (var db = new LiteDatabase(fullPath))
{
var col = db.GetCollection<ProcessingJob>("jobs");
// Fetch all documents in the collection and return as a list
return col.FindAll().ToList();
}
}
catch (Exception ex)
{
// Handle exceptions (e.g., log or display an error)
// Console.Error.WriteLine($"Error loading data from LiteDB: {ex.Message}");
// Return an empty list on error
return new List<ProcessingJob>();
}
}
}
}