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.
This commit is contained in:
tekh 2025-10-29 17:40:42 +01:00
parent ec2935b524
commit bb0197e6ba

View File

@ -36,7 +36,8 @@ 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)()
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) _
@ -45,6 +46,7 @@ Namespace Jobs.FinalizeDocument
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()