refactor(EnvelopeGenerator.Common): umbenennen in EnvelopeGenerator.CommonService
This commit is contained in:
145
EnvelopeGenerator.CommonServices/Services/EmailService.vb
Normal file
145
EnvelopeGenerator.CommonServices/Services/EmailService.vb
Normal file
@@ -0,0 +1,145 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports EnvelopeGenerator.Domain.Entities
|
||||
|
||||
Public Class EmailService
|
||||
Inherits BaseService
|
||||
|
||||
Private ReadOnly EmailModel As EmailModel
|
||||
Private ReadOnly EmailTemplate As TemplateService
|
||||
|
||||
Public Sub New(pState As State)
|
||||
MyBase.New(pState)
|
||||
|
||||
EmailModel = New EmailModel(pState)
|
||||
EmailTemplate = New TemplateService(pState)
|
||||
End Sub
|
||||
|
||||
Public Function SendEnvelopeDeletedEmail(pEnvelope As Envelope, pReceiver As Receiver, pReason As String) As Boolean
|
||||
Logger.Debug("SendEnvelopeDeletedEmail - Creating email data object...")
|
||||
Dim oEmailData As New EmailData(pEnvelope, pReceiver, Domain.Constants.EnvelopeStatus.MessageDeletionSent) With
|
||||
{
|
||||
.SignatureLink = "",
|
||||
.ADDED_WHO_PROCESS = pEnvelope.CURRENT_WORK_APP
|
||||
}
|
||||
|
||||
EmailTemplate.FillEnvelopeDeletedEmailBody(oEmailData, pReason)
|
||||
|
||||
If EmailModel.Insert(oEmailData) = False Then
|
||||
Logger.Error("EMail data could not be inserted.")
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Function SendDocumentReceivedEmail(pEnvelope As Envelope, pReceiver As Receiver) As Boolean
|
||||
Logger.Debug("Creating email data object.")
|
||||
Dim oEmailData As New EmailData(pEnvelope, pReceiver, Domain.Constants.EnvelopeStatus.MessageInvitationSent) With
|
||||
{
|
||||
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature),
|
||||
.ADDED_WHO_PROCESS = pEnvelope.CURRENT_WORK_APP
|
||||
}
|
||||
|
||||
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 GetReceiverUrl(pEnvelope As Envelope, pReceiver As Receiver) As String
|
||||
Logger.Debug($"State.DbConfig.SignatureHost: {State.DbConfig.SignatureHost}")
|
||||
Logger.Debug($" pEnvelope.Uuid: {pEnvelope.Uuid}")
|
||||
Logger.Debug($" pReceiver.Signature: {pReceiver.Signature}")
|
||||
Dim oEmailData As New EmailData(pEnvelope, pReceiver, Domain.Constants.EnvelopeStatus.MessageInvitationSent) With
|
||||
{
|
||||
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature),
|
||||
.ADDED_WHO_PROCESS = pEnvelope.CURRENT_WORK_APP
|
||||
}
|
||||
Return oEmailData.SignatureLink
|
||||
End Function
|
||||
|
||||
|
||||
Public Function SendDocumentAccessCodeReceivedEmail(pEnvelope As Envelope, pReceiver As Receiver) As Boolean
|
||||
Logger.Debug("Creating email data object.")
|
||||
Logger.Debug($"State.DbConfig.SignatureHost: {State.DbConfig.SignatureHost}")
|
||||
Logger.Debug($" pEnvelope.Uuid: {pEnvelope.Uuid}")
|
||||
Logger.Debug($" pReceiver.Signature: {pReceiver.Signature}")
|
||||
Dim oEmailData As New EmailData(pEnvelope, pReceiver, Domain.Constants.EnvelopeStatus.MessageAccessCodeSent) With
|
||||
{
|
||||
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, pEnvelope.Uuid, pReceiver.Signature),
|
||||
.ADDED_WHO_PROCESS = pEnvelope.CURRENT_WORK_APP
|
||||
}
|
||||
|
||||
EmailTemplate.FillDocumentAccessCodeReceivedEmailBody(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(pEnvelope As Envelope, pReceiver As Receiver) As Boolean
|
||||
Logger.Debug("Creating email data object.")
|
||||
Dim oEmailData = New EmailData(pEnvelope, pReceiver, Domain.Constants.EnvelopeStatus.MessageConfirmationSent) 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
|
||||
|
||||
Public Function SendDocumentCompletedEmailToReceiver(pEnvelope As Envelope, pReceiver As Receiver) As Boolean ', pAttachment As String
|
||||
Logger.Debug("Creating email data object.")
|
||||
Dim oEmailData = New EmailData(pEnvelope, pReceiver, Domain.Constants.EnvelopeStatus.MessageCompletionSent) With
|
||||
{
|
||||
.SignatureLink = "",
|
||||
.ATT1_RELATED_ID = pEnvelope.Id,
|
||||
.ATT1_REL_TYPE = "EnvelopeResult"
|
||||
}
|
||||
' .EmailAttachment = pAttachment,
|
||||
Logger.Debug("Sending mail to receiver: [{0}]", oEmailData.EmailAdress)
|
||||
|
||||
EmailTemplate.FillDocumentCompletedEmailBody(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 SendDocumentCompletedEmailToCreator(pEnvelope As Envelope) As Boolean ', pAttachment As String
|
||||
Logger.Debug("Creating email data object.")
|
||||
Dim oEmailData = New EmailData(pEnvelope, Domain.Constants.EnvelopeStatus.MessageCompletionSent) With
|
||||
{
|
||||
.SignatureLink = "",
|
||||
.ATT1_RELATED_ID = pEnvelope.Id,
|
||||
.ATT1_REL_TYPE = "EnvelopeResult"
|
||||
}
|
||||
'.EmailAttachment = pAttachment,
|
||||
EmailTemplate.FillDocumentCompletedEmailBody(oEmailData)
|
||||
|
||||
If EmailModel.Insert(oEmailData) = False Then
|
||||
Logger.Error("EMail data could not be inserted.")
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user