Services: Add Utils.RunForeground() to factor Task.Run and try-catch-Blocks out
Test / Run tests (push) Successful in 2m2s
Test / Run tests (push) Successful in 2m2s
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user