finalize
This commit is contained in:
parent
dbeabab832
commit
951c9d9122
@ -28,6 +28,8 @@ Namespace Jobs
|
||||
Private Database As MSSQLServer
|
||||
Private Config As DbConfig
|
||||
|
||||
Private ActionService As ActionService
|
||||
|
||||
Private PDFBurner As PDFBurner
|
||||
|
||||
Private Class EnvelopeData
|
||||
@ -43,6 +45,9 @@ Namespace Jobs
|
||||
Logger = LogConfig.GetLogger()
|
||||
|
||||
Try
|
||||
InitializeModels()
|
||||
InitializeServices()
|
||||
|
||||
Logger.Debug("Loading GdViewer..")
|
||||
GdViewer = New GdViewer()
|
||||
LicenseManager.RegisterKEY(oGdPictureKey)
|
||||
@ -78,17 +83,33 @@ Namespace Jobs
|
||||
|
||||
If oEnvelopeData Is Nothing Then
|
||||
Logger.Warn("EnvelopeData could not be loaded for Envelope [{0}]!", oId)
|
||||
Throw New ArgumentNullException("EnvelopeData")
|
||||
End If
|
||||
|
||||
'GenerateFinalPDF(oEnvelopeData)
|
||||
'Dim oReport As Byte() = Await GenerateReportPdf(oId)
|
||||
'MergeDocuments()
|
||||
If GenerateFinalPDF(oEnvelopeData) = False Then
|
||||
Logger.Warn("Document could not be finalized!")
|
||||
Throw New ApplicationException("Document could not be finalized")
|
||||
End If
|
||||
|
||||
Logger.Info("Envelope finialized!")
|
||||
' Dim oReport As Byte() = Await GenerateReportPdf(oId)
|
||||
' MergeDocuments()
|
||||
|
||||
Dim oEnvelope = EnvelopeModel.GetById(oId)
|
||||
If oEnvelope Is Nothing Then
|
||||
Logger.Warn("Envelope could not loaded!")
|
||||
Throw New ApplicationException("Envelope could not loaded!")
|
||||
End If
|
||||
|
||||
If ActionService.FinalizeEnvelope(oEnvelope) = False Then
|
||||
Logger.Warn("Envelope could not be finalized!")
|
||||
Throw New ApplicationException("Envelope could not be finalized")
|
||||
End If
|
||||
|
||||
Logger.Info("Envelope finalized!")
|
||||
|
||||
Next
|
||||
|
||||
Logger.Debug("Completed job {0}", JobId)
|
||||
Logger.Info("Completed job {0} successfully!", JobId)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Certificate Document job failed!")
|
||||
@ -119,7 +140,6 @@ Namespace Jobs
|
||||
End Using
|
||||
End Using
|
||||
End Using
|
||||
|
||||
End Function
|
||||
|
||||
Private Function GenerateFinalPDF(pData As EnvelopeData) As Boolean
|
||||
@ -213,6 +233,10 @@ Namespace Jobs
|
||||
}
|
||||
End Function
|
||||
|
||||
Private Sub InitializeServices()
|
||||
Dim oState = GetState()
|
||||
ActionService = New ActionService(oState)
|
||||
End Sub
|
||||
|
||||
Private Sub InitializeModels()
|
||||
Dim oState = GetState()
|
||||
|
||||
@ -60,9 +60,9 @@ Public Class EnvelopeModel
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetById(pEnvelopeId As String) As Envelope
|
||||
Public Function GetById(pEnvelopeId As Integer) As Envelope
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_ENVELOPE] WHERE GUID = '{pEnvelopeId}'"
|
||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_ENVELOPE] WHERE GUID = {pEnvelopeId}"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
|
||||
Return ToEnvelope(oTable)
|
||||
|
||||
@ -26,6 +26,19 @@ Public Class HistoryModel
|
||||
ToList()
|
||||
End Function
|
||||
|
||||
Public Function HasReceiverSigned(pEnvelopeId As Integer, pReceiverId As Integer) As Boolean
|
||||
Dim oEnvelopeSigned As Integer = Constants.EnvelopeStatus.DocumentSigned
|
||||
Dim oSql = $"SELECT COUNT(T.GUID)
|
||||
FROM TBSIG_ENVELOPE_HISTORY T
|
||||
JOIN TBSIG_RECEIVER T2 ON T.USER_REFERENCE = T2.EMAIL_ADDRESS
|
||||
WHERE T.STATUS = {oEnvelopeSigned} AND
|
||||
T.ENVELOPE_ID = {pEnvelopeId} AND
|
||||
T2.GUID = {pReceiverId}"
|
||||
Dim oRowCount As Integer = Database.GetScalarValue(oSql)
|
||||
|
||||
Return oRowCount > 0
|
||||
End Function
|
||||
|
||||
Public Function Insert(pHistory As EnvelopeHistoryEntry) As Boolean
|
||||
Try
|
||||
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE_HISTORY] "
|
||||
|
||||
@ -70,6 +70,12 @@ Public Class ActionService
|
||||
Return EmailService.SendSignedEmail(pEnvelope, pReceiver)
|
||||
End Function
|
||||
|
||||
Public Function FinalizeEnvelope(pEnvelope As Envelope) As Boolean
|
||||
If HistoryService.SetEnvelopeStatus(pEnvelope, Constants.EnvelopeStatus.EnvelopeArchived, "System") = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Loading…
x
Reference in New Issue
Block a user