DeliveryConfirmationsDialog: small fixes

This commit is contained in:
2023-10-19 22:35:31 +02:00
parent c190ce1474
commit 8ce4911317
3 changed files with 6 additions and 5 deletions

View File

@ -93,7 +93,7 @@ namespace Elwig.Dialogs {
""") """)
.ToListAsync(); .ToListAsync();
using var doc = Document.Merge(list.Select(m => new DeliveryConfirmation(Context, Year, m, deliveries.Where(d => d.Delivery.MgNr == m.MgNr)))); ; using var doc = Document.Merge(list.Select(m => new DeliveryConfirmation(Context, Year, m, deliveries.Where(d => d.Delivery.MgNr == m.MgNr).ToList()))); ;
await doc.Generate(new Progress<double>(v => { await doc.Generate(new Progress<double>(v => {
ProgressBar.Value = v; ProgressBar.Value = v;
})); }));

View File

@ -80,13 +80,14 @@ namespace Elwig.Documents {
if (this is MergedDocument m) { if (this is MergedDocument m) {
var pdf = new TempFile("pdf"); var pdf = new TempFile("pdf");
var tmpHtmls = new List<TempFile>(); var tmpHtmls = new List<TempFile>();
var n = 0; var n = m.Documents.Count();
int i = 0;
foreach (var doc in m.Documents) { foreach (var doc in m.Documents) {
var tmpHtml = new TempFile("html"); var tmpHtml = new TempFile("html");
await File.WriteAllTextAsync(tmpHtml.FilePath, await doc.Render(), Utils.UTF8); await File.WriteAllTextAsync(tmpHtml.FilePath, await doc.Render(), Utils.UTF8);
tmpHtmls.Add(tmpHtml); tmpHtmls.Add(tmpHtml);
n++; i++;
progress?.Report(50.0 * n / m.Documents.Count()); progress?.Report(50.0 * i / n);
} }
progress?.Report(50.0); progress?.Report(50.0);
await Pdf.Convert(tmpHtmls.Select(f => f.FilePath), pdf.FilePath, new Progress<double>(v => progress?.Report(50.0 + v / 2))); await Pdf.Convert(tmpHtmls.Select(f => f.FilePath), pdf.FilePath, new Progress<double>(v => progress?.Report(50.0 + v / 2)));

View File

@ -50,7 +50,7 @@ namespace Elwig.Documents {
progress?.Report(parts[0] / (double)parts[1]); progress?.Report(parts[0] / (double)parts[1]);
} else if (line.StartsWith("success:")) { } else if (line.StartsWith("success:")) {
var m = Regex.Match(line, @"\(([0-9, ]+)\)"); var m = Regex.Match(line, @"\(([0-9, ]+)\)");
return m.Groups[1].Value.Split(", ").Select(n => int.Parse(n)); return m.Groups[1].Value.Split(", ").Select(int.Parse);
} }
} }
} }