Refactor signature caching and navigation logic

Replaced the previous signature persistence mechanism with
`IMemoryCache` for temporary storage of captured signatures
using a unique `Guid` key and a 1-minute TTL. Added logging
to track cached signatures and their associated envelope keys.

Removed the logic for rebuilding and displaying reports with
overlaid signatures. Instead, implemented navigation to a
new signed page (`/envelope/{EnvelopeKey}/signed`) with the
signature ID passed as a query parameter.
This commit is contained in:
2026-07-01 01:41:19 +02:00
parent 49ec9fbead
commit df154d83cc

View File

@@ -10,12 +10,14 @@
@using DevExpress.Blazor
@using System.Drawing
@using System.Security.Claims
@using Microsoft.Extensions.Caching.Memory
@inject NavigationManager Navigation
@inject IJSRuntime JSRuntime
@inject EnvelopeGenerator.Server.Client.Services.AuthService AuthService
@inject EnvelopeGenerator.Server.Services.EnvelopeReceiverAuthorizationService ReceiverAuthorizationService
@inject EnvelopeGenerator.Server.Services.EnvelopeReceiverPageDataService PageDataService
@inject AppVersionService AppVersion
@inject IMemoryCache MemoryCache
@inject ILogger<EnvelopeReceiverReportPage> Logger
@implements IDisposable
@@ -678,32 +680,19 @@
};
_signaturePopupVisible = false;
// Persist to cache (fire-and-forget)
if (_receiverUser is not null)
{
_ = Task.Run(async () =>
{
try { await PageDataService.SaveCachedSignatureAsync(_receiverUser, _capturedSignature); }
catch { /* non-critical */ }
});
}
// Store signature in IMemoryCache with a Guid key (1 minute TTL)
var sid = Guid.NewGuid().ToString("N");
MemoryCache.Set(
sid,
_capturedSignature,
TimeSpan.FromMinutes(1));
// Rebuild the report with signatures overlaid
if (_pdfBytes is not null)
{
var newReport = BuildReport(_pdfBytes, _signatures, _capturedSignature);
Logger.LogInformation(
"Signature cached with sid={Sid} for envelope {EnvelopeKey}", sid, EnvelopeKey);
if (_reportViewer is not null)
{
await _reportViewer.OpenReportAsync(newReport);
// Dispose previous report after opening new one
_report?.Dispose();
}
_report = newReport;
}
await InvokeAsync(StateHasChanged);
// Navigate to signed page
Navigation.NavigateTo(
$"/envelope/{Uri.EscapeDataString(EnvelopeKey!)}/signed?sid={sid}");
}
async Task<string?> GetActiveSignatureDataUrlAsync()