From b62cca5961064ffb98e203974d5bcb7a3b43e903 Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 23 Oct 2025 12:14:35 +0200 Subject: [PATCH] feat(pdf-burner): integrate repository to fetch envelope annotations - Added repository access to retrieve signatures and their annotations for a given envelope. - Updated `BurnInstantJSONAnnotationsToPDF` to accept `envelopeId` and load elements from the database. - Updated imports to include `DigitalData.Core.Abstractions` and Entity Framework references. --- EnvelopeGenerator.BBTests/frmFinalizePDF.vb | 14 +++++++++----- .../Jobs/FinalizeDocument/FinalizeDocumentJob.vb | 3 +-- .../Jobs/FinalizeDocument/PDFBurner.vb | 14 +++++++++++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/EnvelopeGenerator.BBTests/frmFinalizePDF.vb b/EnvelopeGenerator.BBTests/frmFinalizePDF.vb index 157638cf..35615cc5 100644 --- a/EnvelopeGenerator.BBTests/frmFinalizePDF.vb +++ b/EnvelopeGenerator.BBTests/frmFinalizePDF.vb @@ -5,10 +5,10 @@ Imports EnvelopeGenerator.CommonServices.Jobs Imports EnvelopeGenerator.CommonServices.Jobs.FinalizeDocument Imports GdPicture14 Imports Newtonsoft.Json.Linq -Imports DigitalData.Core.Abstraction.Application Imports EnvelopeGenerator.Infrastructure Imports Microsoft.EntityFrameworkCore Imports System.Text +Imports DigitalData.Core.Abstractions Public Class frmFinalizePDF Private Const CONNECTIONSTRING = "Server=sDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=+bk8oAbbQP1AzoHtvZUbd+Mbok2f8Fl4miEx1qssJ5yEaEWoQJ9prg4L14fURpPnqi1WMNs9fE4=;" @@ -24,7 +24,10 @@ Public Class frmFinalizePDF Private Sub frmFinalizePDF_Load(sender As Object, e As EventArgs) Handles MyBase.Load LogConfig = New LogConfig(LogConfig.PathType.CustomPath, Application.StartupPath) - Database = New MSSQLServer(LogConfig, MSSQLServer.DecryptConnectionString(CONNECTIONSTRING)) + + Dim dCnnStr As String = MSSQLServer.DecryptConnectionString(CONNECTIONSTRING) + + Database = New MSSQLServer(LogConfig, dCnnStr) #Disable Warning BC40000 ' Type or member is obsolete Factory.Shared.AddEnvelopeGeneratorInfrastructureServices( @@ -40,7 +43,7 @@ Public Class frmFinalizePDF End Sub) opt.AddDbContext( Sub(options) - options.UseSqlServer(CONNECTIONSTRING) _ + options.UseSqlServer(dCnnStr) _ .EnableSensitiveDataLogging() _ .EnableDetailedErrors() End Sub) @@ -96,8 +99,9 @@ Public Class frmFinalizePDF Select(Function(r As DataRow) r.Item("VALUE").ToString()). ToList() - Dim oBuffer As Byte() = ReadEnvelope(CInt(txtEnvelope.Text)) - Dim oNewBuffer = PDFBurner.BurnInstantJSONAnnotationsToPDF(oBuffer, oJsonList) + Dim envelopeId As Integer = CInt(txtEnvelope.Text) + Dim oBuffer As Byte() = ReadEnvelope(envelopeId) + Dim oNewBuffer = PDFBurner.BurnInstantJSONAnnotationsToPDF(oBuffer, oJsonList, envelopeId) Dim desktopPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) Dim oNewPath = Path.Combine(desktopPath, $"E{txtEnvelope.Text}R{txtReceiver.Text}.burned.pdf") diff --git a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/FinalizeDocumentJob.vb b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/FinalizeDocumentJob.vb index 05e6715e..f70d09e0 100644 --- a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/FinalizeDocumentJob.vb +++ b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/FinalizeDocumentJob.vb @@ -404,7 +404,6 @@ Namespace Jobs ParentFolderUID = pEnvelopeData.EnvelopeUUID End If - Logger.Info("ParentFolderUID: [{0}]", ParentFolderUID) Dim oInputDocumentBuffer As Byte() If Not IsNothing(pEnvelopeData.DocAsByte) Then @@ -417,7 +416,7 @@ Namespace Jobs End Try End If - Return PDFBurner.BurnInstantJSONAnnotationsToPDF(oInputDocumentBuffer, oAnnotations) + Return PDFBurner.BurnInstantJSONAnnotationsToPDF(oInputDocumentBuffer, oAnnotations, pEnvelopeData.EnvelopeId) End Function Private Function GetEnvelopeData(pEnvelopeId As Integer) As EnvelopeData diff --git a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb index f17c5791..57ec40a0 100644 --- a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb +++ b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb @@ -2,10 +2,14 @@ Imports System.Drawing Imports System.IO Imports DevExpress.DataProcessing +Imports DigitalData.Core.Abstraction.Application.Repository +Imports DigitalData.Core.Abstractions Imports DigitalData.Modules.Base Imports DigitalData.Modules.Logging Imports EnvelopeGenerator.CommonServices.Jobs.FinalizeDocument.FinalizeDocumentExceptions +Imports EnvelopeGenerator.Domain.Entities Imports GdPicture14 +Imports Microsoft.EntityFrameworkCore Imports Newtonsoft.Json Namespace Jobs.FinalizeDocument @@ -31,7 +35,15 @@ Namespace Jobs.FinalizeDocument _pdfBurnerParams = pdfBurnerParams End Sub - Public Function BurnInstantJSONAnnotationsToPDF(pSourceBuffer As Byte(), pInstantJSONList As List(Of String)) As Byte() + Public Function BurnInstantJSONAnnotationsToPDF(pSourceBuffer As Byte(), pInstantJSONList As List(Of String), envelopeId As Integer) As Byte() + + 'read the elements of envelope with their annotations + Dim sigRepo = Factory.Shared.Repository(Of Signature)() + Dim elements = sigRepo _ + .Where(Function(sig) sig.Document.EnvelopeId = envelopeId) _ + .Include(Function(sig) sig.Annotations) _ + .ToList() + Dim oResult As GdPictureStatus Using oSourceStream As New MemoryStream(pSourceBuffer) ' Open PDF