fix(files): report success cancellation and errors with safe next actions (U02)
This commit is contained in:
@@ -32,6 +32,8 @@ public partial class AccountDetail
|
||||
private string? confirmRestoreEntryTitle;
|
||||
|
||||
private string? savedPdfPath;
|
||||
private FileOperationResult? fileResult;
|
||||
private bool fileBusy;
|
||||
|
||||
private EntryDto? editingEntry;
|
||||
private EntryDto? editingTransferEntry;
|
||||
@@ -178,19 +180,39 @@ public partial class AccountDetail
|
||||
|
||||
private async Task HandleExport()
|
||||
{
|
||||
if (fileBusy) return;
|
||||
fileBusy = true;
|
||||
fileResult = null;
|
||||
try
|
||||
{
|
||||
var pdf = await PdfStatementService.GenerateStatementAsync(AccountId, selectedYear);
|
||||
var suffix = selectedYear.HasValue ? $"_{selectedYear.Value}" : "_Gesamt";
|
||||
savedPdfPath = await FileSaveService.SaveFileAsync(pdf, $"{account?.Name}{suffix}.pdf");
|
||||
fileResult = await FileSaveService.SaveFileAsync(pdf, $"{account?.Name}{suffix}.pdf");
|
||||
|
||||
savedPdfPath = fileResult.Status == FileOperationStatus.Success ? fileResult.Path : null;
|
||||
|
||||
}
|
||||
catch (Exception ex) { fileResult = FileOperationResult.Error(ex); }
|
||||
finally { fileBusy = false; }
|
||||
}
|
||||
|
||||
private async Task HandleOpenSavedPdf()
|
||||
{
|
||||
if (fileBusy) return;
|
||||
fileBusy = true;
|
||||
fileResult = null;
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(savedPdfPath))
|
||||
{
|
||||
await FileSaveService.OpenFileAsync(savedPdfPath);
|
||||
fileResult = await FileSaveService.OpenFileAsync(savedPdfPath);
|
||||
}
|
||||
|
||||
savedPdfPath = null;
|
||||
|
||||
}
|
||||
catch (Exception ex) { fileResult = FileOperationResult.Error(ex); }
|
||||
finally { fileBusy = false; }
|
||||
}
|
||||
|
||||
private void CancelOpenSavedPdf()
|
||||
|
||||
Reference in New Issue
Block a user