diff --git a/DocumentOperator.Application/Common/DTOs/AttachmentInfo.cs b/DocumentOperator.Application/Common/DTOs/AttachmentInfo.cs new file mode 100644 index 0000000..afc9a21 --- /dev/null +++ b/DocumentOperator.Application/Common/DTOs/AttachmentInfo.cs @@ -0,0 +1,60 @@ +namespace DocumentOperator.Application.Common.DTOs; + +/// +/// Represents complete attachment information for a PDF document. +/// Immutable value object containing attachment presence flag, count, and detailed metadata. +/// +public sealed class AttachmentInfo +{ + /// + /// Gets a value indicating whether the PDF contains any attachments + /// + public bool HasAttachments { get; } + + /// + /// Gets the total number of attachments in the PDF + /// + public int AttachmentCount { get; } + + /// + /// Gets the collection of attachment metadata (file details) + /// + public IReadOnlyList Attachments { get; } + + /// + /// Initializes a new instance of the AttachmentInfo class. + /// + /// Whether PDF has attachments + /// Total number of attachments + /// List of attachment metadata (can be empty) + public AttachmentInfo(bool hasAttachments, int attachmentCount, IReadOnlyList attachments) + { + HasAttachments = hasAttachments; + AttachmentCount = attachmentCount; + Attachments = attachments ?? []; + + // Defensive Programming: Ensure count matches list length + if (Attachments.Count != attachmentCount) + { + throw new ArgumentException( + $"Attachment count mismatch: expected {attachmentCount}, got {Attachments.Count}", + nameof(attachments)); + } + } + + /// + /// Creates an AttachmentInfo instance for a PDF with no attachments. + /// + public static AttachmentInfo Empty => + new( + hasAttachments: false, + attachmentCount: 0, + attachments: []); + + public override string ToString() + { + return HasAttachments + ? $"PDF has {AttachmentCount} attachment(s): {string.Join(", ", Attachments.Select(a => a.FileName))}" + : "PDF has no attachments"; + } +} diff --git a/DocumentOperator.Application/Common/DTOs/AttachmentMetadata.cs b/DocumentOperator.Application/Common/DTOs/AttachmentMetadata.cs new file mode 100644 index 0000000..503c135 --- /dev/null +++ b/DocumentOperator.Application/Common/DTOs/AttachmentMetadata.cs @@ -0,0 +1,44 @@ +namespace DocumentOperator.Application.Common.DTOs; + +/// +/// Represents metadata of a single PDF attachment (embedded file). +/// Immutable value object containing file information without the actual binary data. +/// +/// +/// Initializes a new instance of the AttachmentMetadata class. +/// +/// Attachment file name +/// MIME type (e.g., "text/xml") +/// File size in bytes +public sealed class AttachmentMetadata(string fileName, string mimeType, long sizeBytes) +{ + /// + /// Gets the attachment file name (e.g., "invoice.xml", "document.pdf") + /// + public string FileName { get; } = fileName ?? string.Empty; + + /// + /// Gets the MIME type of the attachment (e.g., "text/xml", "application/pdf") + /// + public string MimeType { get; } = mimeType ?? "application/octet-stream"; // Default MIME type if unknown + + /// + /// Gets the attachment file size in bytes + /// + public long SizeBytes { get; } = sizeBytes; + + /// + /// Gets the attachment file size in kilobytes (computed property) + /// + public double SizeKB => SizeBytes / 1024.0; + + /// + /// Gets the attachment file size in megabytes (computed property) + /// + public double SizeMB => SizeBytes / 1024.0 / 1024.0; + + public override string ToString() + { + return $"{FileName} ({MimeType}, {SizeKB:F2} KB)"; + } +} diff --git a/DocumentOperator.Application/Common/DTOs/PdfAMetadata.cs b/DocumentOperator.Application/Common/DTOs/PdfAMetadata.cs new file mode 100644 index 0000000..6f7a7d6 --- /dev/null +++ b/DocumentOperator.Application/Common/DTOs/PdfAMetadata.cs @@ -0,0 +1,34 @@ +namespace DocumentOperator.Application.Common.DTOs; + +/// +/// PDF/A validation metadata including conformance level and validation errors/warnings +/// +public sealed class PdfAMetadata( + bool isValid, + string pdfVersion, + int pageCount, + long fileSizeBytes, + bool encrypted, + string? pdfaVersion, + bool pdfaCompliant, + IReadOnlyList errors, + IReadOnlyList warnings) +{ + public bool IsValid { get; } = isValid; + public string PdfVersion { get; } = pdfVersion; + public int PageCount { get; } = pageCount; + public long FileSizeBytes { get; } = fileSizeBytes; + public bool Encrypted { get; } = encrypted; + public string? PdfAVersion { get; } = pdfaVersion; + public bool PdfACompliant { get; } = pdfaCompliant; + public IReadOnlyList Errors { get; } = errors; + public IReadOnlyList Warnings { get; } = warnings; + + // Computed property + public double FileSizeMB => FileSizeBytes / 1024.0 / 1024.0; + + public override string ToString() + { + return $"PDF/A: {PdfAVersion ?? "None"}, {PageCount} pages, {FileSizeMB:F2} MB, Compliant: {PdfACompliant}"; + } +} diff --git a/DocumentOperator.Application/Common/DTOs/PdfMetadata.cs b/DocumentOperator.Application/Common/DTOs/PdfMetadata.cs new file mode 100644 index 0000000..b9a93e5 --- /dev/null +++ b/DocumentOperator.Application/Common/DTOs/PdfMetadata.cs @@ -0,0 +1,23 @@ +namespace DocumentOperator.Application.Common.DTOs; + +public sealed class PdfMetadata( + int pageCount, + long fileSizeBytes, + string pdfVersion, + bool hasAttachments, + int attachmentCount) +{ + public int PageCount { get; } = pageCount; + public long FileSizeBytes { get; } = fileSizeBytes; + public string PdfVersion { get; } = pdfVersion; + public bool HasAttachments { get; } = hasAttachments; + public int AttachmentCount { get; } = attachmentCount; + + // Computed Property (berechnet aus FileSizeBytes) + public double FileSizeMB => FileSizeBytes / 1024.0 / 1024.0; + + public override string ToString() + { + return $"PDF: {PageCount} pages, {FileSizeMB:F2} MB, Version {PdfVersion}, Attachments: {AttachmentCount}"; + } +} \ No newline at end of file diff --git a/DocumentOperator.Domain/Models/ValueObjects/PdfAMetadata.cs b/DocumentOperator.Domain/Models/ValueObjects/PdfAMetadata.cs deleted file mode 100644 index 9399f24..0000000 --- a/DocumentOperator.Domain/Models/ValueObjects/PdfAMetadata.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace DocumentOperator.Domain.Models.ValueObjects; - -/// -/// PDF/A validation metadata including conformance level and validation errors/warnings -/// -public sealed class PdfAMetadata -{ - public bool IsValid { get; } - public string PdfVersion { get; } - public int PageCount { get; } - public long FileSizeBytes { get; } - public bool Encrypted { get; } - public string? PdfAVersion { get; } - public bool PdfACompliant { get; } - public IReadOnlyList Errors { get; } - public IReadOnlyList Warnings { get; } - - // Computed property - public double FileSizeMB => FileSizeBytes / 1024.0 / 1024.0; - - public PdfAMetadata( - bool isValid, - string pdfVersion, - int pageCount, - long fileSizeBytes, - bool encrypted, - string? pdfaVersion, - bool pdfaCompliant, - IReadOnlyList errors, - IReadOnlyList warnings) - { - IsValid = isValid; - PdfVersion = pdfVersion; - PageCount = pageCount; - FileSizeBytes = fileSizeBytes; - Encrypted = encrypted; - PdfAVersion = pdfaVersion; - PdfACompliant = pdfaCompliant; - Errors = errors; - Warnings = warnings; - } - - public override string ToString() - { - return $"PDF/A: {PdfAVersion ?? "None"}, {PageCount} pages, {FileSizeMB:F2} MB, Compliant: {PdfACompliant}"; - } -} diff --git a/DocumentOperator.Domain/Models/ValueObjects/PdfMetadata.cs b/DocumentOperator.Domain/Models/ValueObjects/PdfMetadata.cs deleted file mode 100644 index be530a8..0000000 --- a/DocumentOperator.Domain/Models/ValueObjects/PdfMetadata.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace DocumentOperator.Domain.Models.ValueObjects; - -public sealed class PdfMetadata -{ - public int PageCount { get; } - public long FileSizeBytes { get; } - public string PdfVersion { get; } - public bool HasAttachments { get; } - public int AttachmentCount { get; } - - // Computed Property (berechnet aus FileSizeBytes) - public double FileSizeMB => FileSizeBytes / 1024.0 / 1024.0; - - public PdfMetadata( - int pageCount, - long fileSizeBytes, - string pdfVersion, - bool hasAttachments, - int attachmentCount) - { - PageCount = pageCount; - FileSizeBytes = fileSizeBytes; - PdfVersion = pdfVersion; - HasAttachments = hasAttachments; - AttachmentCount = attachmentCount; - } - - public override string ToString() - { - return $"PDF: {PageCount} pages, {FileSizeMB:F2} MB, Version {PdfVersion}, Attachments: {AttachmentCount}"; - } -} \ No newline at end of file