correct app close

fix publishing
This commit is contained in:
Alex Bezdieniezhnykh
2025-03-03 19:37:07 +02:00
parent f108cca5f5
commit a493606f64
6 changed files with 43 additions and 21 deletions
+9 -2
View File
@@ -18,6 +18,7 @@ public interface IDbFactory
Task Run(Func<AnnotationsDb, Task> func);
void SaveToDisk();
Task DeleteAnnotations(List<Annotation> annotations, CancellationToken cancellationToken = default);
Task DeleteAnnotations(List<string> annotationNames, CancellationToken cancellationToken = default);
}
public class DbFactory : IDbFactory
@@ -100,10 +101,16 @@ public class DbFactory : IDbFactory
public async Task DeleteAnnotations(List<Annotation> annotations, CancellationToken cancellationToken = default)
{
var names = annotations.Select(x => x.Name).ToList();
await DeleteAnnotations(names, cancellationToken);
}
public async Task DeleteAnnotations(List<string> annotationNames, CancellationToken cancellationToken = default)
{
await Run(async db =>
{
await db.Detections.DeleteAsync(x => names.Contains(x.AnnotationName), token: cancellationToken);
await db.Annotations.DeleteAsync(x => names.Contains(x.Name), token: cancellationToken);
var detDeleted = await db.Detections.DeleteAsync(x => annotationNames.Contains(x.AnnotationName), token: cancellationToken);
var annDeleted = await db.Annotations.DeleteAsync(x => annotationNames.Contains(x.Name), token: cancellationToken);
Console.WriteLine($"Deleted {detDeleted} detections, {annDeleted} annotations");
});
SaveToDisk();
}