- Inject IRepository<Signature> for accessing signature and annotation data - Implement BurnAnnotsToPDF method to process annotations from DB or JSON - Add BurnElementAnnotsToPDF and BurnInstantJSONAnnotsToPDF stubs - Integrate EF Core Include for loading related entities
91 lines
2.6 KiB
C#
91 lines
2.6 KiB
C#
using DigitalData.Core.Abstraction.Application.Repository;
|
|
using DigitalData.Core.Abstractions;
|
|
using EnvelopeGenerator.Application.Common.Configurations;
|
|
using EnvelopeGenerator.Domain.Entities;
|
|
using GdPicture14;
|
|
using MediatR;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace EnvelopeGenerator.Application.Pdf;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class BurnPdfCommand : IRequest
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class BurnPdfCommandHandler : IRequestHandler<BurnPdfCommand>
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private readonly PDFBurnerParams _pdfBurnerParams;
|
|
|
|
private readonly AnnotationManager _manager;
|
|
|
|
private readonly IRepository<Signature> _signRepo;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="pdfBurnerParams"></param>
|
|
/// <param name="manager"></param>
|
|
/// <param name="signRepo"></param>
|
|
public BurnPdfCommandHandler(PDFBurnerParams pdfBurnerParams, AnnotationManager manager, IRepository<Signature> signRepo)
|
|
{
|
|
_pdfBurnerParams = pdfBurnerParams;
|
|
_manager = manager;
|
|
_signRepo = signRepo;
|
|
}
|
|
|
|
public byte[] BurnAnnotsToPDF(byte[] pSourceBuffer, List<string> pInstantJSONList, int envelopeId)
|
|
{
|
|
// read the elements of envelope with their annotations
|
|
var elements = _signRepo
|
|
.Where(sig => sig.Document.EnvelopeId == envelopeId)
|
|
.Include(sig => sig.Annotations)
|
|
.ToList();
|
|
|
|
return elements.Any()
|
|
? BurnElementAnnotsToPDF(pSourceBuffer, elements)
|
|
: BurnInstantJSONAnnotsToPDF(pSourceBuffer, pInstantJSONList);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="pSourceBuffer"></param>
|
|
/// <param name="elements"></param>
|
|
/// <returns></returns>
|
|
public byte[] BurnElementAnnotsToPDF(byte[] pSourceBuffer, List<Signature> elements)
|
|
{
|
|
return Enumerable.Empty<byte>().ToArray();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="pSourceBuffer"></param>
|
|
/// <param name="pInstantJSONList"></param>
|
|
/// <returns></returns>
|
|
public byte[] BurnInstantJSONAnnotsToPDF(byte[] pSourceBuffer, List<string> pInstantJSONList)
|
|
{
|
|
return Enumerable.Empty<byte>().ToArray();
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public Task Handle(BurnPdfCommand request, CancellationToken cancellationToken)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
} |