45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using MediatR;
|
|
using EnvelopeGenerator.Application.Histories.Commands;
|
|
using EnvelopeGenerator.Domain.Constants;
|
|
|
|
namespace EnvelopeGenerator.Application.Pdf.Behaviors;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class AddReportBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
|
|
{
|
|
private readonly ISender _sender;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
public AddReportBehavior(ISender sender)
|
|
{
|
|
_sender = sender;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="next"></param>
|
|
/// <param name="cancel"></param>
|
|
/// <returns></returns>
|
|
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()
|
|
{
|
|
EnvelopeId = request.EnvelopeId,
|
|
UserReference = "System",
|
|
Status = EnvelopeStatus.EnvelopeReportCreated,
|
|
}, cancel);
|
|
|
|
return docResult;
|
|
}
|
|
} |