refactor(frmFinalizePDF): Aktualisiert, um die Datei aus der DB zu lesen

This commit is contained in:
Developer 02
2025-03-26 13:55:24 +01:00
parent 88c2721ba5
commit 6083eea496

View File

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