feat(AddReportBehavior): add conditional history creation based on Debug flag in AddReportBehavior
This commit is contained in:
parent
35b7b1a080
commit
e6285f13f7
@ -32,6 +32,7 @@ public class AddReportBehavior : IPipelineBehavior<BurnPdfCommand, byte[]>
|
|||||||
var docResult = await next(cancel);
|
var docResult = await next(cancel);
|
||||||
var base64 = Convert.ToBase64String(docResult);
|
var base64 = Convert.ToBase64String(docResult);
|
||||||
|
|
||||||
|
if (!request.Debug)
|
||||||
await _sender.Send(new CreateHistoryCommand()
|
await _sender.Send(new CreateHistoryCommand()
|
||||||
{
|
{
|
||||||
EnvelopeId = request.EnvelopeId,
|
EnvelopeId = request.EnvelopeId,
|
||||||
|
|||||||
@ -9,6 +9,7 @@ using EnvelopeGenerator.Domain.Entities;
|
|||||||
using GdPicture14;
|
using GdPicture14;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@ -18,7 +19,10 @@ namespace EnvelopeGenerator.Application.Pdf;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public record BurnPdfCommand(int? EnvelopeId = null, string? EnvelopeUuid = null) : IRequest<byte[]>;
|
public record BurnPdfCommand(int? EnvelopeId = null, string? EnvelopeUuid = null) : IRequest<byte[]>
|
||||||
|
{
|
||||||
|
internal bool Debug { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@ -61,6 +65,8 @@ public class BurnPdfCommandHandler : IRequestHandler<BurnPdfCommand, byte[]>
|
|||||||
|
|
||||||
private readonly IRepository<Domain.Entities.DocumentStatus> _docStatusRepo;
|
private readonly IRepository<Domain.Entities.DocumentStatus> _docStatusRepo;
|
||||||
|
|
||||||
|
private readonly IConfiguration _config;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -69,13 +75,15 @@ public class BurnPdfCommandHandler : IRequestHandler<BurnPdfCommand, byte[]>
|
|||||||
/// <param name="logger"></param>
|
/// <param name="logger"></param>
|
||||||
/// <param name="envRepo"></param>
|
/// <param name="envRepo"></param>
|
||||||
/// <param name="docStatusRepo"></param>
|
/// <param name="docStatusRepo"></param>
|
||||||
public BurnPdfCommandHandler(IOptions<PDFBurnerParams> pdfBurnerParams, AnnotationManager manager, ILogger<BurnPdfCommandHandler> logger, IRepository<Envelope> envRepo, IRepository<Domain.Entities.DocumentStatus> docStatusRepo)
|
/// <param name="config"></param>
|
||||||
|
public BurnPdfCommandHandler(IOptions<PDFBurnerParams> pdfBurnerParams, AnnotationManager manager, ILogger<BurnPdfCommandHandler> logger, IRepository<Envelope> envRepo, IRepository<Domain.Entities.DocumentStatus> docStatusRepo, IConfiguration config)
|
||||||
{
|
{
|
||||||
_options = pdfBurnerParams.Value;
|
_options = pdfBurnerParams.Value;
|
||||||
_manager = manager;
|
_manager = manager;
|
||||||
_docStatusRepo = docStatusRepo;
|
_docStatusRepo = docStatusRepo;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_envRepo = envRepo;
|
_envRepo = envRepo;
|
||||||
|
_config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -88,6 +96,7 @@ public class BurnPdfCommandHandler : IRequestHandler<BurnPdfCommand, byte[]>
|
|||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
public async Task<byte[]> Handle(BurnPdfCommand request, CancellationToken cancel)
|
public async Task<byte[]> Handle(BurnPdfCommand request, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
|
request.Debug = _config.GetValue<bool>("Debug");
|
||||||
var envQuery =
|
var envQuery =
|
||||||
request.EnvelopeId is not null ? _envRepo.Where(env => env.Id == request.EnvelopeId) :
|
request.EnvelopeId is not null ? _envRepo.Where(env => env.Id == request.EnvelopeId) :
|
||||||
request.EnvelopeUuid is not null ? _envRepo.Where(env => env.Uuid == request.EnvelopeUuid) :
|
request.EnvelopeUuid is not null ? _envRepo.Where(env => env.Uuid == request.EnvelopeUuid) :
|
||||||
|
|||||||
@ -4,5 +4,6 @@
|
|||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"Debug": true
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user