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() + 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(), + 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()