29-11-2023
This commit is contained in:
32
EnvelopeGenerator.Common/Services/ActionService.vb
Normal file
32
EnvelopeGenerator.Common/Services/ActionService.vb
Normal file
@@ -0,0 +1,32 @@
|
||||
Imports DigitalData.Modules.Base
|
||||
|
||||
Public Class ActionService
|
||||
Inherits BaseClass
|
||||
|
||||
Private ReadOnly State As State
|
||||
|
||||
Private EmailService As EmailService
|
||||
Private HistoryService As HistoryService
|
||||
|
||||
|
||||
Public Sub New(pState As State)
|
||||
MyBase.New(pState.LogConfig)
|
||||
|
||||
State = pState
|
||||
EmailService = New EmailService(pState)
|
||||
HistoryService = New HistoryService(pState)
|
||||
End Sub
|
||||
|
||||
Public Function DeleteEnvelope(pEnvelope As Envelope) As Boolean
|
||||
|
||||
HistoryService.SetEnvelopeStatus(pEnvelope, Constants.EnvelopeStatus.EnvelopeDeleted, pEnvelope.User.Email)
|
||||
|
||||
For Each oReceiver As EnvelopeReceiver In pEnvelope.Receivers
|
||||
EmailService.SendEnvelopeDeletedEmail(oReceiver.Id, pEnvelope.Id)
|
||||
Next
|
||||
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
End Class
|
||||
@@ -1,18 +1,79 @@
|
||||
Imports DigitalData.Modules.Base
|
||||
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class EmailService
|
||||
Inherits BaseClass
|
||||
|
||||
Private ReadOnly State As State
|
||||
|
||||
Private ReadOnly EnvelopeModel As EnvelopeModel
|
||||
Private ReadOnly ReceiverModel As ReceiverModel
|
||||
Private ReadOnly EmailModel As EmailModel
|
||||
|
||||
Private ReadOnly EmailTemplate As EmailTemplate
|
||||
|
||||
Public Sub New(pState As State)
|
||||
MyBase.New(pState.LogConfig)
|
||||
|
||||
State = pState
|
||||
EnvelopeModel = New EnvelopeModel(pState)
|
||||
ReceiverModel = New ReceiverModel(pState)
|
||||
EmailModel = New EmailModel(pState)
|
||||
EmailTemplate = New EmailTemplate()
|
||||
End Sub
|
||||
|
||||
Public Function SendSignedEmail(pReceiverId As Integer, pEnvelopeId As Integer)
|
||||
Public Function SendEnvelopeDeletedEmail(pReceiverId As Integer, pEnvelopeId As Integer) As Boolean
|
||||
Dim oEnvelope = EnvelopeModel.GetById(pEnvelopeId)
|
||||
Dim oReceiver = ReceiverModel.GetById(pReceiverId)
|
||||
|
||||
Dim oEnvelope =
|
||||
Dim oEmailData As New EmailData(oEnvelope, oReceiver) With
|
||||
{
|
||||
.SignatureLink = ""
|
||||
}
|
||||
|
||||
EmailTemplate.FillEnvelopeDeletedEmailBody(oEmailData)
|
||||
|
||||
If EmailModel.Insert(oEmailData) = False Then
|
||||
Logger.Error("EMail data could not be inserted.")
|
||||
Return False
|
||||
End If
|
||||
|
||||
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
|
||||
{
|
||||
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, oEnvelope.Uuid, oReceiver.Signature)
|
||||
}
|
||||
|
||||
EmailTemplate.FillDocumentReceivedEmailBody(oEmailData)
|
||||
|
||||
If EmailModel.Insert(oEmailData) = False Then
|
||||
Logger.Error("EMail data could not be inserted.")
|
||||
Return False
|
||||
End If
|
||||
|
||||
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)
|
||||
|
||||
Dim oEmailData = New EmailData(oEnvelope, oReceiver) With {.SignatureLink = ""}
|
||||
EmailTemplate.FillDocumentSignedEmailBody(oEmailData)
|
||||
|
||||
If EmailModel.Insert(oEmailData) = False Then
|
||||
Logger.Error("EMail data could not be inserted.")
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
32
EnvelopeGenerator.Common/Services/HistoryService.vb
Normal file
32
EnvelopeGenerator.Common/Services/HistoryService.vb
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports EnvelopeGenerator.Common.Constants
|
||||
|
||||
Public Class HistoryService
|
||||
Inherits BaseClass
|
||||
|
||||
Private ReadOnly State As State
|
||||
|
||||
Private ReadOnly EnvelopeModel As EnvelopeModel
|
||||
Private ReadOnly ReceiverModel As ReceiverModel
|
||||
Private ReadOnly HistoryModel As HistoryModel
|
||||
|
||||
Public Sub New(pState As State)
|
||||
MyBase.New(pState.LogConfig)
|
||||
|
||||
State = pState
|
||||
EnvelopeModel = New EnvelopeModel(pState)
|
||||
ReceiverModel = New ReceiverModel(pState)
|
||||
HistoryModel = New HistoryModel(pState)
|
||||
End Sub
|
||||
|
||||
Public Function SetEnvelopeStatus(pEnvelope As Envelope, pStatus As EnvelopeStatus, pUserReference As String) As Boolean
|
||||
Return HistoryModel.Insert(New EnvelopeHistoryEntry() With {
|
||||
.EnvelopeId = pEnvelope.Id,
|
||||
.ActionDate = Now(),
|
||||
.Status = pStatus,
|
||||
.UserReference = pUserReference
|
||||
})
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user