refactor: simplify AddReportBehavior by making DoCreateReport static and reordering base64 conversion

This commit is contained in:
Developer 02 2025-11-11 22:57:50 +01:00
parent e1aa7fe650
commit ff60cd7ef8

View File

@ -39,7 +39,6 @@ public class AddReportBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
public async Task<byte[]> Handle(BurnPdfCommand request, RequestHandlerDelegate<byte[]> next, CancellationToken cancel)
{
var docResult = await next(cancel);
var base64 = Convert.ToBase64String(docResult);
if (!request.Debug)
await _sender.Send(new CreateHistoryCommand()
@ -51,6 +50,8 @@ public class AddReportBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
docResult = await CreateReport(request.Envelope!, cancel);
var base64 = Convert.ToBase64String(docResult);
return docResult;
}
@ -70,12 +71,12 @@ public class AddReportBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
throw new CreateReportException("No report data found!");
}
var oBuffer = DoCreateReport(oItems);
var oBuffer = AddReportBehavior.DoCreateReport(oItems);
return oBuffer;
}
private byte[] DoCreateReport(IEnumerable<EnvelopeReport> oItems)
private static byte[] DoCreateReport(IEnumerable<EnvelopeReport> oItems)
{
var oSource = new ReportSource { Items = oItems };
var oReport = new rptEnvelopeHistory