Compare commits

...

9 Commits

Author SHA1 Message Date
Developer 02
08e2e91e9a feat(program): Konfiguration aus appsettings.json laden
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.
2025-04-28 09:16:24 +02:00
Developer 02
2966d64455 feat(terminal): ReadDocument-Befehl um PDF-Speicheroptionen erweitert
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.
2025-04-25 19:33:29 +02:00
Developer 02
186f3c3319 Merge branch 'master' of http://git.dd:3000/AppStd/EnvelopeGenerator 2025-04-24 12:01:55 +02:00
Developer 02
276adda516 unnötige Protokollierung entfernt 2025-04-24 11:48:54 +02:00
Developer 02
ac0ae10fab unnötige Protokollierung entfernt 2025-04-24 11:47:11 +02:00
Developer01
3713669ec5 Merge 2025-04-24 11:45:38 +02:00
Developer 02
7f0131fc2d refactor(FinalizeDocumentJob): Update für detaillierte Protokollierung 2025-04-24 11:44:29 +02:00
Developer01
d9deb589d1 MS AdminTab 2025-04-24 11:43:55 +02:00
Developer 02
bf5faf53bd refactor(frmFinalizePDF): Aktualisieren von Button1_Click zum Öffnen von PDF nach dem Brennvorgang 2025-04-24 11:37:46 +02:00
14 changed files with 206 additions and 95 deletions

View File

@@ -3,23 +3,8 @@
/// <summary>
/// Represents the response for reading a document.
/// </summary>
public class ReadDocumentResponse
public class ReadDocumentResponse : ReadDocumentResponseBase
{
/// <summary>
/// The unique identifier of the document.
/// </summary>
public int Guid { get; init; }
/// <summary>
/// The identifier of the associated envelope.
/// </summary>
public int EnvelopeId { get; init; }
/// <summary>
/// The date and time when the document was added.
/// </summary>
public DateTime AddedWhen { get; init; }
/// <summary>
/// The binary data of the document, if available.
/// </summary>

View File

@@ -0,0 +1,22 @@
namespace EnvelopeGenerator.Application.Documents.Queries.Read;
/// <summary>
/// Represents the response for reading a document.
/// </summary>
public class ReadDocumentResponseBase
{
/// <summary>
/// The unique identifier of the document.
/// </summary>
public int Guid { get; init; }
/// <summary>
/// The identifier of the associated envelope.
/// </summary>
public int EnvelopeId { get; init; }
/// <summary>
/// The date and time when the document was added.
/// </summary>
public DateTime AddedWhen { get; init; }
}

View File

@@ -77,6 +77,8 @@ Public Class frmFinalizePDF
Dim oNewPath = Path.Combine(desktopPath, $"E{txtEnvelope.Text}R{txtReceiver.Text}.burned.pdf")
File.WriteAllBytes(oNewPath, oNewBuffer)
Process.Start(oNewPath)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try

View File

@@ -170,7 +170,7 @@ Namespace Jobs
Throw New ApplicationException("Envelope could not be finalized")
End If
Catch ex As Exception
Logger.Warn($"Unhandled exception while working envelope [{oId}] - [{ex.Message}]")
Logger.Warn(ex, $"Unhandled exception while working envelope [{oId}]")
End Try
@@ -378,12 +378,10 @@ Namespace Jobs
Try
oInputDocumentBuffer = File.ReadAllBytes(oInputPath)
Catch ex As Exception
Logger.Error(ex)
Throw New BurnAnnotationException("Source document could not be read from disk!", ex)
End Try
End If
Return PDFBurner.BurnInstantJSONAnnotationsToPDF(oInputDocumentBuffer, oAnnotations)
End Function

View File

@@ -31,45 +31,38 @@ Namespace Jobs.FinalizeDocument
Public Function BurnInstantJSONAnnotationsToPDF(pSourceBuffer As Byte(), pInstantJSONList As List(Of String)) As Byte()
Dim oResult As GdPictureStatus
Using oSourceStream As New MemoryStream(pSourceBuffer)
' Open PDF
oResult = Manager.InitFromStream(oSourceStream)
If oResult <> GdPictureStatus.OK Then
Throw New BurnAnnotationException($"Could not open document for burning: [{oResult}]")
End If
Try
Using oSourceStream As New MemoryStream(pSourceBuffer)
' Open PDF
oResult = Manager.InitFromStream(oSourceStream)
' Add annotation to PDF
For Each oJSON In pInstantJSONList
If AddInstantJSONAnnotationToPDF(oJSON) = False Then
Logger.Warn($"Error in AddInstantJSONAnnotationToPDF - oJson: ")
Logger.Warn(oJSON)
Throw New BurnAnnotationException($"Adding Annotation failed")
End If
Next
oResult = Manager.BurnAnnotationsToPage(RemoveInitialAnnots:=True, VectorMode:=True)
If oResult <> GdPictureStatus.OK Then
Throw New BurnAnnotationException($"Could not burn annotations to file: [{oResult}]")
End If
'Save PDF
Using oNewStream As New MemoryStream()
oResult = Manager.SaveDocumentToPDF(oNewStream)
If oResult <> GdPictureStatus.OK Then
Throw New BurnAnnotationException($"Could not open document for burning: [{oResult}]")
Throw New BurnAnnotationException($"Could not save document to stream: [{oResult}]")
End If
' Add annotation to PDF
For Each oJSON In pInstantJSONList
If AddInstantJSONAnnotationToPDF(oJSON) = False Then
Logger.Warn($"Error in AddInstantJSONAnnotationToPDF - oJson: ")
Logger.Warn(oJSON)
Throw New BurnAnnotationException($"Adding Annotation failed")
End If
Next
oResult = Manager.BurnAnnotationsToPage(RemoveInitialAnnots:=True, VectorMode:=True)
If oResult <> GdPictureStatus.OK Then
Throw New BurnAnnotationException($"Could not burn annotations to file: [{oResult}]")
End If
Manager.Close()
'Save PDF
Using oNewStream As New MemoryStream()
oResult = Manager.SaveDocumentToPDF(oNewStream)
If oResult <> GdPictureStatus.OK Then
Throw New BurnAnnotationException($"Could not save document to stream: [{oResult}]")
End If
Manager.Close()
Return oNewStream.ToArray()
End Using
Return oNewStream.ToArray()
End Using
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
End Using
End Function
Private Function AddInstantJSONAnnotationToPDF(pInstantJSON As String) As Boolean

View File

@@ -24,4 +24,6 @@ Module ModuleSettings
Public USER_GHOST_MODE_ACTIVE As Boolean = False
Public MyUserModel As UserModel
Public MyState As State
Public CurrentEnvelopID As Integer = 0
Public CurrentEnvelopetitle As String = ""
End Module

View File

@@ -688,7 +688,7 @@ Partial Class frmMain
'SplitContainerControl2.Panel2
'
resources.ApplyResources(Me.SplitContainerControl2.Panel2, "SplitContainerControl2.Panel2")
Me.SplitContainerControl2.SplitterPosition = 584
Me.SplitContainerControl2.SplitterPosition = 819
'
'GridControlData
'

View File

@@ -1139,7 +1139,7 @@
<value>0, 0</value>
</data>
<data name="GridControlData.Size" type="System.Drawing.Size, System.Drawing">
<value>584, 390</value>
<value>819, 390</value>
</data>
<data name="GridControlData.TabIndex" type="System.Int32, mscorlib">
<value>1</value>

View File

@@ -183,7 +183,11 @@ Public Class frmMain
Private Sub btnDeleteEnvelope_ItemClick_1(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDeleteEnvelope.ItemClick
Try
Dim oSelectedRows = ViewEnvelopes.GetSelectedRows()
Dim oEnvelope As Envelope = DirectCast(ViewEnvelopes.GetRow(oSelectedRows.First), Envelope)
If oSelectedRows.Count > 0 Then
CurrentEnvelopID = oEnvelope.Id
CurrentEnvelopetitle = oEnvelope.Title
Dim ofrmAbort As New frmRueckruf
frmRueckruf.ShowDialog()
If frmRueckruf.Continue_Reject = True Then
@@ -203,36 +207,44 @@ Public Class frmMain
End Sub
Private Sub XtraTabControl1_SelectedPageChanged(sender As Object, e As DevExpress.XtraTab.TabPageChangedEventArgs) Handles XtraTabControlMain.SelectedPageChanged
RibbonPageGroupFunctions.Enabled = True
RibbonPageEnvelopeActions.Enabled = True
Select Case XtraTabControlMain.SelectedTabPageIndex
Case 1
btnEditEnvelope.Enabled = False
btnDeleteEnvelope.Enabled = False
btnContactReceiver.Enabled = False
btnShowDocument.Enabled = False
bbtnitm_ResendInvitation.Enabled = False
bbtnitmInfoMail.Enabled = False
bbtnitmEB.Enabled = True
LoadEnvelopeData()
Case 0
If ViewEnvelopes.RowCount = 0 Then
RibbonPageGroupFunctions.Enabled = False
End If
btnEditEnvelope.Enabled = True
btnDeleteEnvelope.Enabled = True
btnContactReceiver.Enabled = True
btnShowDocument.Enabled = True
bbtnitm_ResendInvitation.Enabled = True
bbtnitmInfoMail.Enabled = True
bbtnitmEB.Enabled = False
LoadEnvelopeData()
txtEnvelopeIdLabel.Caption = "No Envelope selected"
Dim oHandle = SplashScreenManager.ShowOverlayForm(Me)
Try
RibbonPageGroupFunctions.Enabled = True
RibbonPageEnvelopeActions.Enabled = True
Select Case XtraTabControlMain.SelectedTabPageIndex
Case 1
btnEditEnvelope.Enabled = False
btnDeleteEnvelope.Enabled = False
btnContactReceiver.Enabled = False
btnShowDocument.Enabled = False
bbtnitm_ResendInvitation.Enabled = False
bbtnitmInfoMail.Enabled = False
bbtnitmEB.Enabled = True
LoadEnvelopeData()
Case 0
If ViewEnvelopes.RowCount = 0 Then
RibbonPageGroupFunctions.Enabled = False
End If
btnEditEnvelope.Enabled = True
btnDeleteEnvelope.Enabled = True
btnContactReceiver.Enabled = True
btnShowDocument.Enabled = True
bbtnitm_ResendInvitation.Enabled = True
bbtnitmInfoMail.Enabled = True
bbtnitmEB.Enabled = False
LoadEnvelopeData()
txtEnvelopeIdLabel.Caption = "No Envelope selected"
Case 2
RibbonPageGroupFunctions.Enabled = False
RibbonPageEnvelopeActions.Enabled = False
End Select
Catch ex As Exception
Logger.Error(ex)
Finally
SplashScreenManager.CloseOverlayForm(oHandle)
End Try
Case 2
RibbonPageGroupFunctions.Enabled = False
RibbonPageEnvelopeActions.Enabled = False
End Select
End Sub
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
@@ -621,7 +633,9 @@ Public Class frmMain
If SQL_REP_ENV_USER_TM <> String.Empty Then
Result_Execute(SQL_REP_ENV_USER_TM)
Else
GridControlData.DataSource = Nothing
GridViewData.Columns.Clear()
End If
End Sub
@@ -652,7 +666,9 @@ Public Class frmMain
Try
Dim oDT As DataTable = DB_DD_ECM.GetDatatable(mySQL)
If Not IsNothing(oDT) Then
If GridViewData.Columns.Count > 0 Then
GridViewData.Columns.Clear()
End If
GridControlData.DataSource = oDT
Else
GridControlData.DataSource = Nothing
@@ -734,4 +750,20 @@ Public Class frmMain
Public Shared Sub Save_Logfiles()
End Sub
Private Sub btnEvvallUs_thismonth_Click(sender As Object, e As EventArgs) Handles btnEvvallUs_thismonth.Click
If SQL_REP_ENV_ALL_USER_MONTH <> String.Empty Then
Result_Execute(SQL_REP_ENV_ALL_USER_MONTH)
Else
GridControlData.DataSource = Nothing
End If
End Sub
Private Sub btnEvvallUs_lastmonth_Click(sender As Object, e As EventArgs) Handles btnEvvallUs_lastmonth.Click
If SQL_REP_ENV_ALL_USER_LAST_MONTH <> String.Empty Then
Result_Execute(SQL_REP_ENV_ALL_USER_LAST_MONTH)
Else
GridControlData.DataSource = Nothing
End If
End Sub
End Class

View File

@@ -30,13 +30,17 @@ Partial Class frmRueckruf
Me.StatusStrip1 = New System.Windows.Forms.StatusStrip()
Me.tsstatus = New System.Windows.Forms.ToolStripStatusLabel()
Me.SimpleButton1 = New DevExpress.XtraEditors.SimpleButton()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.lblID = New System.Windows.Forms.Label()
Me.lblTitle = New System.Windows.Forms.Label()
Me.StatusStrip1.SuspendLayout()
Me.SuspendLayout()
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(22, 20)
Me.Label2.Location = New System.Drawing.Point(28, 36)
Me.Label2.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(380, 16)
@@ -46,7 +50,7 @@ Partial Class frmRueckruf
'txtReason
'
Me.txtReason.AcceptsReturn = True
Me.txtReason.Location = New System.Drawing.Point(25, 40)
Me.txtReason.Location = New System.Drawing.Point(31, 56)
Me.txtReason.Margin = New System.Windows.Forms.Padding(4)
Me.txtReason.Multiline = True
Me.txtReason.Name = "txtReason"
@@ -66,7 +70,7 @@ Partial Class frmRueckruf
'
Me.btnCancel.Image = CType(resources.GetObject("btnCancel.Image"), System.Drawing.Image)
Me.btnCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
Me.btnCancel.Location = New System.Drawing.Point(251, 134)
Me.btnCancel.Location = New System.Drawing.Point(260, 150)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(203, 44)
Me.btnCancel.TabIndex = 4
@@ -76,7 +80,7 @@ Partial Class frmRueckruf
'StatusStrip1
'
Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.tsstatus})
Me.StatusStrip1.Location = New System.Drawing.Point(0, 185)
Me.StatusStrip1.Location = New System.Drawing.Point(0, 211)
Me.StatusStrip1.Name = "StatusStrip1"
Me.StatusStrip1.Size = New System.Drawing.Size(488, 22)
Me.StatusStrip1.TabIndex = 5
@@ -90,17 +94,59 @@ Partial Class frmRueckruf
'SimpleButton1
'
Me.SimpleButton1.ImageOptions.SvgImage = CType(resources.GetObject("SimpleButton1.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage)
Me.SimpleButton1.Location = New System.Drawing.Point(25, 134)
Me.SimpleButton1.Location = New System.Drawing.Point(31, 150)
Me.SimpleButton1.Name = "SimpleButton1"
Me.SimpleButton1.Size = New System.Drawing.Size(220, 44)
Me.SimpleButton1.TabIndex = 6
Me.SimpleButton1.Text = "Umschlag zurückrufen"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(28, 9)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(80, 16)
Me.Label3.TabIndex = 7
Me.Label3.Text = "Envelope-ID:"
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(158, 9)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(93, 16)
Me.Label4.TabIndex = 8
Me.Label4.Text = "Envelope-Titel:"
'
'lblID
'
Me.lblID.AutoSize = True
Me.lblID.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblID.Location = New System.Drawing.Point(108, 9)
Me.lblID.Name = "lblID"
Me.lblID.Size = New System.Drawing.Size(49, 16)
Me.lblID.TabIndex = 9
Me.lblID.Text = "Label5"
'
'lblTitle
'
Me.lblTitle.AutoSize = True
Me.lblTitle.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblTitle.Location = New System.Drawing.Point(257, 9)
Me.lblTitle.Name = "lblTitle"
Me.lblTitle.Size = New System.Drawing.Size(49, 16)
Me.lblTitle.TabIndex = 10
Me.lblTitle.Text = "Label5"
'
'frmRueckruf
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 16.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(488, 207)
Me.ClientSize = New System.Drawing.Size(488, 233)
Me.Controls.Add(Me.lblTitle)
Me.Controls.Add(Me.lblID)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.SimpleButton1)
Me.Controls.Add(Me.StatusStrip1)
Me.Controls.Add(Me.btnCancel)
@@ -129,4 +175,8 @@ Partial Class frmRueckruf
Friend WithEvents StatusStrip1 As StatusStrip
Friend WithEvents tsstatus As ToolStripStatusLabel
Friend WithEvents SimpleButton1 As DevExpress.XtraEditors.SimpleButton
Friend WithEvents Label3 As Label
Friend WithEvents Label4 As Label
Friend WithEvents lblID As Label
Friend WithEvents lblTitle As Label
End Class

View File

@@ -121,7 +121,7 @@
<data name="btnCancel.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wQAADsEBuJFr7QAAAUlJREFUOE+lU6GOg1AQ5BP6Cf2E+4QLnqQWV4EHjUJhGzxJJbICDxpFQvCHg4DA
wAAADsABataJCQAAAUlJREFUOE+lU6GOg1AQ5BP6Cf2E+4QLnqQWV4EHjUJhGzxJJbICDxpFQvCHg4DA
Yd/tLPvK4wJ34iaZ9GVndxh4WwtYluVCfBIVcSYGLPwA1SPp0bxpIaiqSjmOw2zbdhMJdL4S6yzLlG3b
qigK6JHI3FCmacoi6HmeGscRSZAswDmOY9bQR7WXjK5AExJoAzBJEjTOXdexIWowoVpNvMjoChQg5Hm+
M8HT8Eo4G6muMrbHmQkIk2ma8PRPaT8G3Ikc1TSAKdWf0nYMGT5M4Lrun/E/iDM+nDlofgPf9/kDysgG

View File

@@ -22,6 +22,8 @@ Public Class frmRueckruf
txtReason.Text = ""
tsstatus.Text = ""
Continue_Reject = False
lblID.Text = CurrentEnvelopID.ToString
lblTitle.Text = CurrentEnvelopetitle
End Sub
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click
@@ -50,4 +52,8 @@ Public Class frmRueckruf
tsstatus.Text = "Please add a reason for aborting - " & Now
End If
End Sub
Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
End Sub
End Class

View File

@@ -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<byte>());
}
}
}

View File

@@ -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);