Updated references from `Constants` to direct usage of `EnvelopeStatus` and `EmailTemplateType` enums. This change enhances code readability and reduces dependency on the `Constants` class. Modified properties and parameters across command classes, DTOs, repositories, and services to use the enums directly. Updated `ModifyDocStatusCommandBase`, `EnvelopeHistoryDto`, and `ResetEmailTemplateCommand` for improved clarity. Consistent updates across multiple files indicate a systematic refactoring aimed at streamlining the codebase and improving maintainability. Comments and documentation have also been revised to reflect these changes.
147 lines
5.5 KiB
VB.net
147 lines
5.5 KiB
VB.net
Imports DigitalData.Modules.Logging
|
|
Imports EnvelopeGenerator.CommonServices.EnvelopeGenerator.Domain.Entities
|
|
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, Domain.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, Domain.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, Domain.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, Domain.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, Domain.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, Domain.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.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
|