From bb0197e6ba82ae7805cdc8f06a693753bcf36e31 Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 29 Oct 2025 17:40:42 +0100 Subject: [PATCH] refactor: wrap repository access in a DI scope in PDFBurner - Updated `BurnAnnotsToPDF` to create a scope using `Factory.Shared.ScopeFactory.CreateScope()` before accessing the `Signature` repository. - Ensures proper disposal of services and improves dependency injection usage. - No functional changes to PDF burning logic. --- .../Jobs/FinalizeDocument/PDFBurner.vb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb index f6379ef9..b3329496 100644 --- a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb +++ b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb @@ -36,15 +36,17 @@ Namespace Jobs.FinalizeDocument #Region "Burn PDF" Public Function BurnAnnotsToPDF(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() - - Return If(elements.Any(), + Using scope = Factory.Shared.ScopeFactory.CreateScope() + Dim sigRepo = scope.ServiceProvider.Repository(Of Signature)() + Dim elements = sigRepo _ + .Where(Function(sig) sig.Document.EnvelopeId = envelopeId) _ + .Include(Function(sig) sig.Annotations) _ + .ToList() + + Return If(elements.Any(), BurnElementAnnotsToPDF(pSourceBuffer, elements), BurnInstantJSONAnnotsToPDF(pSourceBuffer, pInstantJSONList)) + End Using End Function Public Function BurnElementAnnotsToPDF(pSourceBuffer As Byte(), elements As List(Of Signature)) As Byte()