Introduced `InMemoryReportStorageWebExtension` to manage reports in memory, enabling dynamic report storage and retrieval. Updated `ReportViewer.razor` to conditionally render the `DxReportViewer` component and initialize reports asynchronously. Configured dependency injection in `Program.cs` to register `InMemoryReportStorageWebExtension` as a singleton and integrated it with `CustomReportProvider`. Registered `EnvelopeGenerator.ReceiverUI.PredefinedReports.Report` as a trusted class for deserialization. Enhanced `CustomReportProvider` to fetch reports from memory or generate them dynamically using `ReportsFactory`. Added necessary `using` directives and ensured proper report lifecycle management.
21 lines
760 B
C#
21 lines
760 B
C#
using DevExpress.XtraReports.UI;
|
|
using DevExpress.XtraReports.Services;
|
|
using EnvelopeGenerator.ReceiverUI.PredefinedReports;
|
|
|
|
namespace EnvelopeGenerator.ReceiverUI.Services
|
|
{
|
|
public class CustomReportProvider : IReportProviderAsync {
|
|
private readonly InMemoryReportStorageWebExtension reportStorage;
|
|
|
|
public CustomReportProvider(InMemoryReportStorageWebExtension reportStorage) {
|
|
this.reportStorage = reportStorage;
|
|
}
|
|
|
|
public Task<XtraReport> GetReportAsync(string id, ReportProviderContext context) {
|
|
if(reportStorage.TryGetReport(id, out var savedReport))
|
|
return Task.FromResult(savedReport);
|
|
|
|
return Task.FromResult(ReportsFactory.GetReport(id));
|
|
}
|
|
}
|
|
} |