Add pipeline behaviors for signing process
Introduced four new pipeline behaviors (`AnnotationBehavior`, `DocStatusBehavior`, `HistoryBehavior`, and `SendSignedMailBehavior`) to modularize the signing process. These behaviors handle annotation persistence, document status creation, history recording, and signed mail notifications, respectively. - `AnnotationBehavior`: Saves annotations using `IRepository`. - `DocStatusBehavior`: Creates document status via `ISender`. - `HistoryBehavior`: Records signing history and validates receiver information. - `SendSignedMailBehavior`: Sends signed mail notifications using email templates and dynamic placeholder replacement. Added error handling for missing data in `HistoryBehavior` and `SendSignedMailBehavior`. Updated the signing pipeline to execute these behaviors sequentially, ensuring a structured and extensible workflow.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Application.Common.Dto;
|
||||
using EnvelopeGenerator.Application.Signature.Commands;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Signature.Behaviors;
|
||||
|
||||
/// <summary>
|
||||
/// Pipeline behavior that saves annotations.
|
||||
/// Executes first in the signing process.
|
||||
/// </summary>
|
||||
public class AnnotationBehavior : IPipelineBehavior<SignCommand, Unit>
|
||||
{
|
||||
private readonly IRepository<ElementAnnotation> _repo;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repository"></param>
|
||||
public AnnotationBehavior(IRepository<ElementAnnotation> repository)
|
||||
{
|
||||
_repo = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="next"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Unit> Handle(SignCommand request, RequestHandlerDelegate<Unit> next, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.PsPdfKitAnnotation is PsPdfKitAnnotation annot)
|
||||
await _repo.CreateAsync(annot.Structured, cancellationToken);
|
||||
|
||||
return await next();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user