Updated project and solution files to rename and restructure `DocumentOperator` to `DocumentService`. Modified project references in `DocumentService.API.csproj`, `DocumentService.Application.csproj`, and `DocumentService.Infrastructure.csproj` to reflect the new naming convention. Updated `DocumentService.sln` to remove old project references, add new ones, and adjust configuration and nested project mappings accordingly. This change aligns the project structure with the new naming convention.
45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
using AutoMapper;
|
|
using DocumentService.Application.Common.DTOs;
|
|
using DocumentService.Application.Common.Interfaces;
|
|
using MediatR;
|
|
|
|
namespace DocumentService.Application.SwissQrCode.Queries;
|
|
|
|
/// <summary>
|
|
/// Query for extracting Swiss QR Code from PDF (Stream-based)
|
|
/// </summary>
|
|
public record ExtractSwissQrCodeQuery : IRequest<SwissQrCodeExtractionResult>
|
|
{
|
|
/// <summary>
|
|
/// PDF as stream (caller is responsible for disposal)
|
|
/// </summary>
|
|
public required Stream PdfStream { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handler for ExtractSwissQrCodeQuery
|
|
/// Orchestrates Swiss QR Code extraction using ISwissQrCodeProcessor and AutoMapper
|
|
/// </summary>
|
|
public class ExtractSwissQrCodeQueryHandler(ISwissQrCodeProcessor qrCodeProcessor, IMapper mapper)
|
|
: IRequestHandler<ExtractSwissQrCodeQuery, SwissQrCodeExtractionResult>
|
|
{
|
|
/// <summary>
|
|
/// Extracts and parses Swiss QR Code from the PDF (default: scans all pages starting with last)
|
|
/// Returns both parsed Bill DTO and raw QR text lines
|
|
/// </summary>
|
|
public async Task<SwissQrCodeExtractionResult> Handle(ExtractSwissQrCodeQuery request, CancellationToken cancellationToken)
|
|
{
|
|
// Extract: returns (Bill, RawLines) - pass stream directly
|
|
var (bill, rawLines) = await qrCodeProcessor.ExtractSwissQrCodeAsync(request.PdfStream, pageNumbers: null, cancellationToken);
|
|
|
|
// Map Codecrete Bill to DTO using AutoMapper
|
|
var billDto = mapper.Map<SwissQrBillDto>(bill);
|
|
|
|
// Return references (passed through) + Bill DTO + raw lines
|
|
return new SwissQrCodeExtractionResult(
|
|
Bill: billDto,
|
|
RawLines: rawLines
|
|
);
|
|
}
|
|
}
|