From 6083eea496ebfebeef07907e68cd46093db3b43b Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 26 Mar 2025 13:55:24 +0100 Subject: [PATCH] refactor(frmFinalizePDF): Aktualisiert, um die Datei aus der DB zu lesen --- EnvelopeGenerator.Test/frmFinalizePDF.vb | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/EnvelopeGenerator.Test/frmFinalizePDF.vb b/EnvelopeGenerator.Test/frmFinalizePDF.vb index 300f6513..e9240913 100644 --- a/EnvelopeGenerator.Test/frmFinalizePDF.vb +++ b/EnvelopeGenerator.Test/frmFinalizePDF.vb @@ -48,20 +48,33 @@ Public Class frmFinalizePDF End Function + Private Function ReadEnvelope(ByVal pEnvID As Integer) As Byte() + Dim strSql As String = "Select [BYTE_DATA] from [TBSIG_ENVELOPE_DOCUMENT] WHERE ENVELOPE_ID = " & pEnvID + Dim obyteDB = Database.GetScalarValue(strSql) + If Not IsDBNull(obyteDB) Then + Dim fileData As Byte() = DirectCast(Database.GetScalarValue(strSql), Byte()) + If fileData IsNot Nothing Then + Return fileData + End If + End If + + Throw New InvalidOperationException($"Byte data is null. Envelope ID: {pEnvID}") + + End Function + Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try - Dim oDocumentPath = LoadEnvelopeDocument() - Dim oFileInfo = New FileInfo(oDocumentPath) Dim oTable = LoadAnnotationDataForEnvelope() Dim oJsonList = oTable.Rows. Cast(Of DataRow). Select(Function(r As DataRow) r.Item("VALUE").ToString()). ToList() - Dim oBuffer As Byte() = File.ReadAllBytes(oDocumentPath) + Dim oBuffer As Byte() = ReadEnvelope(CInt(txtEnvelope.Text)) Dim oNewBuffer = PDFBurner.BurnInstantJSONAnnotationsToPDF(oBuffer, oJsonList) - Dim oNewPath = Path.Combine(oFileInfo.Directory.FullName, $"{oFileInfo.Name}.burned.pdf") + Dim desktopPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + Dim oNewPath = Path.Combine(desktopPath, $"E{txtEnvelope.Text}R{txtReceiver.Text}.burned.pdf") File.WriteAllBytes(oNewPath, oNewBuffer) Catch ex As Exception