Add TriggerFinalizationWorkerBehavior to pipeline
Updated IEnvelopeFinalizationTrigger to support CancellationToken in TriggerAsync for improved cancellation handling. Introduced TriggerFinalizationWorkerBehavior to trigger finalization in the SigningCommand pipeline. Updated DependencyInjection to include the new behavior. Refactored EnvelopeFinalizationTrigger to align with interface changes and removed unused using directives.
This commit is contained in:
@@ -9,5 +9,5 @@ public interface IEnvelopeFinalizationTrigger
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task TriggerAsync();
|
Task TriggerAsync(CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ public static class DependencyInjection
|
|||||||
|
|
||||||
// 5. SendSignedMailBehavior - Sends notification email (executes LAST)
|
// 5. SendSignedMailBehavior - Sends notification email (executes LAST)
|
||||||
cfg.AddBehavior<IPipelineBehavior<SigningCommand, Unit>, SendSignedMailBehavior>();
|
cfg.AddBehavior<IPipelineBehavior<SigningCommand, Unit>, SendSignedMailBehavior>();
|
||||||
|
|
||||||
|
// 6. TriggerFinalizationWorkerBehavior - Triggers the finalization worker (executes LAST)
|
||||||
|
cfg.AddBehavior<IPipelineBehavior<SigningCommand, Unit>, TriggerFinalizationWorkerBehavior>();
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
|
services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Interfaces;
|
||||||
|
using EnvelopeGenerator.Application.DocReceiverElements.Commands;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.DocReceiverElements.Behaviors;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class TriggerFinalizationWorkerBehavior(IEnvelopeFinalizationTrigger? Trigger = null) : IPipelineBehavior<SigningCommand, Unit>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="next"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
|
public async Task<Unit> Handle(SigningCommand request, RequestHandlerDelegate<Unit> next, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if(Trigger != null)
|
||||||
|
await Trigger.TriggerAsync(cancellationToken);
|
||||||
|
|
||||||
|
return await next(cancellationToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using EnvelopeGenerator.Application.Common.Interfaces;
|
using EnvelopeGenerator.Application.Common.Interfaces;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Server.BackgroundServices;
|
namespace EnvelopeGenerator.Server.BackgroundServices;
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ public sealed class EnvelopeFinalizationTrigger : IEnvelopeFinalizationTrigger
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task TriggerAsync()
|
public Task TriggerAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
Trigger();
|
Trigger();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|||||||
Reference in New Issue
Block a user