diff --git a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/FinalizeDocumentJob.vb b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/FinalizeDocumentJob.vb index cfd2af5e..c921b4df 100644 --- a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/FinalizeDocumentJob.vb +++ b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/FinalizeDocumentJob.vb @@ -230,6 +230,29 @@ Namespace Jobs Return Task.FromResult(True) 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) Dim SqlCom As SqlCommand Dim imageData As Byte() @@ -418,7 +441,18 @@ Namespace Jobs End Try 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 Private Function GetEnvelopeData(pEnvelopeId As Integer) As EnvelopeData