29-11-2023

This commit is contained in:
Jonathan Jenne
2023-11-29 16:15:48 +01:00
parent c964b97e55
commit 1b88a6cff7
23 changed files with 342 additions and 257 deletions

View 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

View File

@@ -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

View 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