Refactor and rename to DocumentService
Renamed namespaces and projects from DocumentOperator to DocumentService, updating all references accordingly. Refactored PdfSignatureAppearanceDto and related enums to use properties with init accessors for improved clarity. Removed and re-added IPkcs11SelfTestStatusProvider with updated namespace. Simplified dependency injection by removing DocumentOperatorApplication registration. Updated appsettings.json with a specific AssetsRootPath. Incremented version numbers in project files for a new release. Introduced PdfSignatureClient and IPdfSignatureClient for PDF digital-signing operations. Updated project files to use newer Microsoft.Extensions package versions. Removed all DocumentOperator references, completing the transition to DocumentService. Added new DTOs and enums for PDF signature options and appearance.
This commit is contained in:
22
DocumentService.Application/SignPdf/SignPdfCommand.cs
Normal file
22
DocumentService.Application/SignPdf/SignPdfCommand.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using DocumentService.Application.Common.DTOs;
|
||||
using DocumentService.Application.Common.Interfaces;
|
||||
using MediatR;
|
||||
|
||||
namespace DocumentService.Application.SignPdf;
|
||||
|
||||
public sealed record SignPdfCommand : IRequest<byte[]>
|
||||
{
|
||||
public required Stream InputPdf { get; init; }
|
||||
public required PdfSignOptionsDto Options { get; init; }
|
||||
public Stream? SignatureImage { get; init; }
|
||||
}
|
||||
|
||||
public sealed class SignPdfCommandHandler(IPdfDigitalSignatureService signer) : IRequestHandler<SignPdfCommand, byte[]>
|
||||
{
|
||||
public async Task<byte[]> Handle(SignPdfCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
using var output = new MemoryStream();
|
||||
await signer.SignPdfAsync(command.InputPdf, output, command.Options, command.SignatureImage, cancellationToken);
|
||||
return output.ToArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user