scheduler
This commit is contained in:
@@ -15,36 +15,63 @@ Public Class ActionService
|
||||
|
||||
EmailService = New EmailService(pState)
|
||||
HistoryService = New HistoryService(pState)
|
||||
|
||||
ReceiverModel = New ReceiverModel(pState)
|
||||
End Sub
|
||||
|
||||
Public Function SendEnvelope(pEnvelope As Envelope) As Boolean
|
||||
If HistoryService.SetEnvelopeStatus(pEnvelope, Constants.EnvelopeStatus.EnvelopeQueued, pEnvelope.User.Email) = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim oSendResult = pEnvelope.Receivers.
|
||||
Select(Function(r) EmailService.SendDocumentReceivedEmail(pEnvelope, r)).
|
||||
All(Function(r) r = True)
|
||||
|
||||
If oSendResult = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Function DeleteEnvelope(pEnvelope As Envelope) As Boolean
|
||||
HistoryService.SetEnvelopeStatus(pEnvelope, Constants.EnvelopeStatus.EnvelopeDeleted, pEnvelope.User.Email)
|
||||
If HistoryService.SetEnvelopeStatus(pEnvelope, Constants.EnvelopeStatus.EnvelopeDeleted, pEnvelope.User.Email) = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim oSendResult = pEnvelope.Receivers.
|
||||
Select(Function(r) EmailService.SendEnvelopeDeletedEmail(pEnvelope, r)).
|
||||
All(Function(r) r = True)
|
||||
|
||||
If oSendResult = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
For Each oReceiver As EnvelopeReceiver In pEnvelope.Receivers
|
||||
EmailService.SendEnvelopeDeletedEmail(oReceiver.Id, pEnvelope.Id)
|
||||
EmailService.SendEnvelopeDeletedEmail(pEnvelope, oReceiver)
|
||||
Next
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Function OpenEnvelope(pEnvelope As Envelope, pReceiverId As Integer) As Boolean
|
||||
Dim oReceiver As EnvelopeReceiver = ReceiverModel.GetById(pReceiverId)
|
||||
Dim oUserReference = oReceiver.Email
|
||||
Public Function OpenEnvelope(pEnvelope As Envelope, pReceiver As EnvelopeReceiver) As Boolean
|
||||
Dim oUserReference = pReceiver.Email
|
||||
|
||||
Return HistoryService.SetEnvelopeStatus(pEnvelope, Constants.EnvelopeStatus.DocumentOpened, oUserReference)
|
||||
If HistoryService.SetEnvelopeStatus(pEnvelope, Constants.EnvelopeStatus.DocumentOpened, oUserReference) = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Function SignEnvelope(pEnvelope As Envelope, pReceiverId As Integer) As Boolean
|
||||
Dim oReceiver As EnvelopeReceiver = ReceiverModel.GetById(pReceiverId)
|
||||
Dim oUserReference = oReceiver.Email
|
||||
Public Function SignEnvelope(pEnvelope As Envelope, pReceiver As EnvelopeReceiver) As Boolean
|
||||
Dim oUserReference = pReceiver.Email
|
||||
|
||||
If HistoryService.SetEnvelopeStatus(pEnvelope, Constants.EnvelopeStatus.DocumentSigned, oUserReference) = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return EmailService.SendSignedEmail(oReceiver.Id, pEnvelope.Id)
|
||||
Return EmailService.SendSignedEmail(pEnvelope, pReceiver)
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
@@ -23,11 +23,8 @@ Public Class EmailService
|
||||
EmailTemplate = New EmailTemplate()
|
||||
End Sub
|
||||
|
||||
Public Function SendEnvelopeDeletedEmail(pReceiverId As Integer, pEnvelopeId As Integer) As Boolean
|
||||
Dim oEnvelope = EnvelopeModel.GetById(pEnvelopeId)
|
||||
Dim oReceiver = ReceiverModel.GetById(pReceiverId)
|
||||
|
||||
Dim oEmailData As New EmailData(oEnvelope, oReceiver) With
|
||||
Public Function SendEnvelopeDeletedEmail(pEnvelope As Envelope, pReceiver As EnvelopeReceiver) As Boolean
|
||||
Dim oEmailData As New EmailData(pEnvelope, pReceiver) With
|
||||
{
|
||||
.SignatureLink = ""
|
||||
}
|
||||
@@ -42,13 +39,10 @@ Public Class EmailService
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Function SendInitialEmail(pReceiverId As Integer, pEnvelopeId As Integer) As Boolean
|
||||
Dim oEnvelope = EnvelopeModel.GetById(pEnvelopeId)
|
||||
Dim oReceiver = ReceiverModel.GetById(pReceiverId)
|
||||
|
||||
Dim oEmailData As New EmailData(oEnvelope, oReceiver) With
|
||||
Public Function SendDocumentReceivedEmail(pEnvelope As Envelope, pReceiver As EnvelopeReceiver) As Boolean
|
||||
Dim oEmailData As New EmailData(pEnvelope, pReceiver) With
|
||||
{
|
||||
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, oEnvelope.Uuid, oReceiver.Signature)
|
||||
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature)
|
||||
}
|
||||
|
||||
EmailTemplate.FillDocumentReceivedEmailBody(oEmailData)
|
||||
@@ -61,11 +55,12 @@ Public Class EmailService
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Function SendSignedEmail(pReceiverId As Integer, pEnvelopeId As Integer) As Boolean
|
||||
Dim oEnvelope = EnvelopeModel.GetById(pEnvelopeId)
|
||||
Dim oReceiver = ReceiverModel.GetById(pReceiverId)
|
||||
Public Function SendSignedEmail(pEnvelope As Envelope, pReceiver As EnvelopeReceiver) As Boolean
|
||||
Dim oEmailData = New EmailData(pEnvelope, pReceiver) With
|
||||
{
|
||||
.SignatureLink = ""
|
||||
}
|
||||
|
||||
Dim oEmailData = New EmailData(oEnvelope, oReceiver) With {.SignatureLink = ""}
|
||||
EmailTemplate.FillDocumentSignedEmailBody(oEmailData)
|
||||
|
||||
If EmailModel.Insert(oEmailData) = False Then
|
||||
|
||||
@@ -22,11 +22,19 @@ Public Class HistoryService
|
||||
End Sub
|
||||
|
||||
Public Function SetEnvelopeStatus(pEnvelope As Envelope, pStatus As EnvelopeStatus, pUserReference As String) As Boolean
|
||||
Return HistoryModel.Insert(New EnvelopeHistoryEntry() With {
|
||||
Dim oResult = HistoryModel.Insert(New EnvelopeHistoryEntry() With {
|
||||
.EnvelopeId = pEnvelope.Id,
|
||||
.ActionDate = Now(),
|
||||
.Status = pStatus,
|
||||
.UserReference = pUserReference
|
||||
})
|
||||
|
||||
If oResult = False Then
|
||||
Logger.Warn("Could not set Envelope status to [{0}] for Envelope [{1}].", pStatus.ToString, pEnvelope.Id)
|
||||
Return False
|
||||
End If
|
||||
|
||||
Logger.Debug("Envelope status set to [{0}] for Envelope [{1}].", pStatus.ToString, pEnvelope.Id)
|
||||
Return True
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user