From 41cb2c2d931ee1ad303b8c74c22d600748c7af13 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Fri, 25 Apr 2025 11:39:59 +0200 Subject: [PATCH 1/3] fix(PDFBurnerParams): Verschieben in das Verzeichnis /FinalizeDocument --- EnvelopeGenerator.Common/EnvelopeGenerator.Common.vbproj | 2 +- .../Jobs/{ => FinalizeDocument}/PDFBurnerParams.vb | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename EnvelopeGenerator.Common/Jobs/{ => FinalizeDocument}/PDFBurnerParams.vb (100%) diff --git a/EnvelopeGenerator.Common/EnvelopeGenerator.Common.vbproj b/EnvelopeGenerator.Common/EnvelopeGenerator.Common.vbproj index 87c83103..6f69ba5b 100644 --- a/EnvelopeGenerator.Common/EnvelopeGenerator.Common.vbproj +++ b/EnvelopeGenerator.Common/EnvelopeGenerator.Common.vbproj @@ -281,7 +281,7 @@ - + diff --git a/EnvelopeGenerator.Common/Jobs/PDFBurnerParams.vb b/EnvelopeGenerator.Common/Jobs/FinalizeDocument/PDFBurnerParams.vb similarity index 100% rename from EnvelopeGenerator.Common/Jobs/PDFBurnerParams.vb rename to EnvelopeGenerator.Common/Jobs/FinalizeDocument/PDFBurnerParams.vb From 2966d644553a943961d9ddeacf470a60bf3200d8 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Fri, 25 Apr 2025 19:33:29 +0200 Subject: [PATCH 2/3] feat(terminal): ReadDocument-Befehl um PDF-Speicheroptionen erweitert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Optionen `save`, `dir` und `fileName` zum `ReadDocument`-Befehl hinzugefügt. Wenn `save` aktiviert ist, wird das PDF an dem angegebenen oder dem Standardpfad gespeichert. Ermöglicht dem Benutzer mehr Kontrolle über Speicherort und Dateinamen. --- .../Queries/Read/ReadDocumentResponse.cs | 17 +------------- .../Queries/Read/ReadDocumentResponseBase.cs | 22 +++++++++++++++++++ EnvelopeGenerator.Terminal/CommandManager.cs | 22 ++++++++++++++++--- 3 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponseBase.cs diff --git a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponse.cs b/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponse.cs index e5d1b287..3fc4d222 100644 --- a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponse.cs +++ b/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponse.cs @@ -3,23 +3,8 @@ /// /// Represents the response for reading a document. /// -public class ReadDocumentResponse +public class ReadDocumentResponse : ReadDocumentResponseBase { - /// - /// The unique identifier of the document. - /// - public int Guid { get; init; } - - /// - /// The identifier of the associated envelope. - /// - public int EnvelopeId { get; init; } - - /// - /// The date and time when the document was added. - /// - public DateTime AddedWhen { get; init; } - /// /// The binary data of the document, if available. /// diff --git a/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponseBase.cs b/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponseBase.cs new file mode 100644 index 00000000..afa13cb2 --- /dev/null +++ b/EnvelopeGenerator.Application/Documents/Queries/Read/ReadDocumentResponseBase.cs @@ -0,0 +1,22 @@ +namespace EnvelopeGenerator.Application.Documents.Queries.Read; + +/// +/// Represents the response for reading a document. +/// +public class ReadDocumentResponseBase +{ + /// + /// The unique identifier of the document. + /// + public int Guid { get; init; } + + /// + /// The identifier of the associated envelope. + /// + public int EnvelopeId { get; init; } + + /// + /// The date and time when the document was added. + /// + public DateTime AddedWhen { get; init; } +} diff --git a/EnvelopeGenerator.Terminal/CommandManager.cs b/EnvelopeGenerator.Terminal/CommandManager.cs index 3ba0f76a..a593df00 100644 --- a/EnvelopeGenerator.Terminal/CommandManager.cs +++ b/EnvelopeGenerator.Terminal/CommandManager.cs @@ -32,11 +32,27 @@ public class CommandManager [Subcommand] public IEnvelopeReceiverService EnvelopeReceiver => _envelopeReceiverService; - [Command] - public async Task ReadDocument(IConsole console, int? id = null, int? envelopeId = null) + [Command(ArgumentSeparatorStrategy = ArgumentSeparatorStrategy.EndOfOptions)] + public async Task ReadDocument(IConsole console, + [Option(Description = "ID of the document.")] int? id = null, + [Option(Description = "ID of the envelope containing the document.")] int? envelopeId = null, + [Option(Description = "Path to save the PDF")] bool save = false, + [Option(Description = "Directory to save the PDF")] string? dir = null, + [Option(Description = "Name of file to save the PDF")] string? fileName = null) { ReadDocumentQuery query = new(id, envelopeId); var document = await _mediator.Send(query); - console.WriteLine(JsonSerializer.Serialize(document, Options)); + console.WriteLine(JsonSerializer.Serialize(save ? document as ReadDocumentResponseBase : document, Options)); + + if (save) + { + dir ??= AppContext.BaseDirectory; + fileName ??= $"D{document?.Guid}E{document?.EnvelopeId}.pdf"; + + var path = Path.Combine(dir, fileName); + console.WriteLine("Save to " + path); + + File.WriteAllBytes(path, document?.ByteData ?? Array.Empty()); + } } } From 08e2e91e9a64be7f6865560baa4094834e2ad711 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Mon, 28 Apr 2025 09:16:24 +0200 Subject: [PATCH 3/3] feat(program): Konfiguration aus appsettings.json laden MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Die Anwendung lädt nun Konfigurationseinstellungen aus einer "appsettings.json"-Datei im Basisverzeichnis. Dies ermöglicht eine externe Konfiguration ohne Codeänderungen und unterstützt das Neuladen der Einstellungen zur Laufzeit bei Änderungen der Datei. --- EnvelopeGenerator.Terminal/Program.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/EnvelopeGenerator.Terminal/Program.cs b/EnvelopeGenerator.Terminal/Program.cs index 2aed708a..09f61cbd 100644 --- a/EnvelopeGenerator.Terminal/Program.cs +++ b/EnvelopeGenerator.Terminal/Program.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; namespace EnvelopeGenerator.Terminal; @@ -8,6 +9,10 @@ public class Program { var builder = Host.CreateApplicationBuilder(args); + builder.Configuration + .SetBasePath(AppContext.BaseDirectory) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); + var config = builder.Configuration; builder.Services.AddCommandManagerRunner(config);