分析模块重新调整
This commit is contained in:
@@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user