Refactor envelope and annotation data retrieval logic
Add private helper functions ReadEnvelope and LoadAnnotationDataForEnvelope to centralize retrieval of envelope byte data and annotation JSON from the database. Update PDF annotation burning logic to use these helpers, improving code reuse and testability.
This commit is contained in:
@@ -230,6 +230,29 @@ Namespace Jobs
|
|||||||
|
|
||||||
Return Task.FromResult(True)
|
Return Task.FromResult(True)
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
#Region "From BBTests"
|
||||||
|
Private Function ReadEnvelope(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 Function LoadAnnotationDataForEnvelope(pEnvID As Integer) As DataTable
|
||||||
|
Dim oSql = $"SELECT VALUE FROM [TBSIG_DOCUMENT_STATUS] WHERE ENVELOPE_ID = {pEnvID}"
|
||||||
|
Return Database.GetDatatable(oSql)
|
||||||
|
|
||||||
|
End Function
|
||||||
|
#End Region
|
||||||
|
|
||||||
Private Sub Update_File_DB(pFilePath As String, pEnvelopeID As Long)
|
Private Sub Update_File_DB(pFilePath As String, pEnvelopeID As Long)
|
||||||
Dim SqlCom As SqlCommand
|
Dim SqlCom As SqlCommand
|
||||||
Dim imageData As Byte()
|
Dim imageData As Byte()
|
||||||
@@ -418,7 +441,18 @@ Namespace Jobs
|
|||||||
End Try
|
End Try
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Return PDFBurner.BurnAnnotsToPDF(oInputDocumentBuffer, oAnnotations, pEnvelopeData.EnvelopeId)
|
#Region "From BBTests"
|
||||||
|
Dim oTable = LoadAnnotationDataForEnvelope(pEnvelopeId)
|
||||||
|
Dim oJsonList = oTable.Rows.
|
||||||
|
Cast(Of DataRow).
|
||||||
|
Select(Function(r As DataRow) r.Item("VALUE").ToString()).
|
||||||
|
ToList()
|
||||||
|
|
||||||
|
Dim oBuffer As Byte() = ReadEnvelope(pEnvelopeId)
|
||||||
|
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
Return PDFBurner.BurnAnnotsToPDF(oBuffer, oJsonList, pEnvelopeId)
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Function GetEnvelopeData(pEnvelopeId As Integer) As EnvelopeData
|
Private Function GetEnvelopeData(pEnvelopeId As Integer) As EnvelopeData
|
||||||
|
|||||||
Reference in New Issue
Block a user