Services: Add Utils.RunForeground() to factor Task.Run and try-catch-Blocks out
Test / Run tests (push) Successful in 2m2s

This commit is contained in:
2026-06-30 02:27:57 +02:00
parent 69efca1cc3
commit beacba6bd9
6 changed files with 188 additions and 291 deletions
+8 -21
View File
@@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore;
using Elwig.Documents;
using Elwig.Helpers.Export;
using Elwig.Models.Dtos;
using System.Windows.Input;
using System.Windows;
using System;
using LinqKit;
@@ -262,30 +261,18 @@ namespace Elwig.Services {
if (mode == ExportMode.SaveList) {
var filename = InteractionService.SaveFile(DeliveryAncmtList.Name, DeliveryAncmtList.Name, "ods");
if (filename != null) {
Mouse.OverrideCursor = Cursors.Wait;
await Task.Run(async () => {
try {
var data = await DeliveryAncmtListData.FromQuery(query, filterNames);
using var ods = new OdsFile(filename);
await ods.AddTable(data);
} catch (Exception exc) {
InteractionService.ShowException(exc);
}
await Utils.RunForeground(async () => {
var data = await DeliveryAncmtListData.FromQuery(query, filterNames);
using var ods = new OdsFile(filename);
await ods.AddTable(data);
});
Mouse.OverrideCursor = null;
}
} else {
Mouse.OverrideCursor = Cursors.Wait;
await Task.Run(async () => {
try {
var data = await DeliveryAncmtListData.FromQuery(query, filterNames);
using var doc = new DeliveryAncmtList(string.Join(" / ", filterNames), data);
await Utils.ExportDocument(doc, mode);
} catch (Exception exc) {
InteractionService.ShowException(exc);
}
await Utils.RunForeground(async () => {
var data = await DeliveryAncmtListData.FromQuery(query, filterNames);
using var doc = new DeliveryAncmtList(string.Join(" / ", filterNames), data);
await Utils.ExportDocument(doc, mode);
});
Mouse.OverrideCursor = null;
}
}