Updated import statements and changed references from `Domain.Constants` to `Value` in `APIEnvelopeJob.vb`, `FinalizeDocumentJob.vb`, `HistoryModel.vb`, `EmailService.vb`, and job scheduling files. This standardizes constant access and improves code maintainability and readability.
148 lines
5.5 KiB
VB.net
148 lines
5.5 KiB
VB.net
Imports DigitalData.Modules.Logging
|
|
Imports EnvelopeGenerator.CommonServices.EnvelopeGenerator.Domain.Entities
|
|
Imports EnvelopeGenerator.Domain.Constants
|
|
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 ReceiverVM, pReason As String) As Boolean
|
|
Logger.Debug("SendEnvelopeDeletedEmail - Creating email data object...")
|
|
Dim oEmailData As New EmailData(pEnvelope, pReceiver, 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 ReceiverVM) As Boolean
|
|
Logger.Debug("Creating email data object.")
|
|
Dim oEmailData As New EmailData(pEnvelope, pReceiver, 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 ReceiverVM) 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, 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 ReceiverVM) 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, 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 ReceiverVM) As Boolean
|
|
Logger.Debug("Creating email data object.")
|
|
Dim oEmailData = New EmailData(pEnvelope, pReceiver, 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 ReceiverVM) As Boolean ', pAttachment As String
|
|
Logger.Debug("Creating email data object.")
|
|
Dim oEmailData = New EmailData(pEnvelope, pReceiver, 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, 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
|