This commit is contained in:
PitzM 2024-01-10 13:06:03 +01:00
commit 8657c0b212
8 changed files with 148 additions and 27 deletions

View File

@ -22,6 +22,7 @@
MessageAccessCodeSent = 3002 MessageAccessCodeSent = 3002
MessageConfirmationSent = 3003 MessageConfirmationSent = 3003
MessageDeletionSent = 3004 MessageDeletionSent = 3004
MessageCompletionSent = 3005
End Enum End Enum
Public Enum ElementStatus Public Enum ElementStatus

View File

@ -16,10 +16,19 @@ Public Class EmailData
Public Property Message As String Public Property Message As String
Public Property EnvelopeTitle As String Public Property EnvelopeTitle As String
Public Property EmailAttachment As String = ""
''' <summary>
''' Constructor for sending email to receiver
''' </summary>
''' <param name="pEnvelope"></param>
''' <param name="pReceiver"></param>
''' <param name="pStatus"></param>
Public Sub New(pEnvelope As Envelope, pReceiver As EnvelopeReceiver, pStatus As Constants.EnvelopeStatus) Public Sub New(pEnvelope As Envelope, pReceiver As EnvelopeReceiver, pStatus As Constants.EnvelopeStatus)
EmailAdress = pReceiver.Email EmailAdress = pReceiver.Email
EmailSubject = String.Empty EmailSubject = String.Empty
EmailType = pStatus EmailType = pStatus
Message = pEnvelope.Message Message = pEnvelope.Message
ReferenceID = pEnvelope.Id ReferenceID = pEnvelope.Id
ReferenceString = pEnvelope.Uuid ReferenceString = pEnvelope.Uuid
@ -30,4 +39,24 @@ Public Class EmailData
EnvelopeTitle = pEnvelope.Title EnvelopeTitle = pEnvelope.Title
End Sub End Sub
''' <summary>
''' Constructor for sending email to creator
''' </summary>
''' <param name="pEnvelope"></param>
''' <param name="pStatus"></param>
Public Sub New(pEnvelope As Envelope, pStatus As Constants.EnvelopeStatus)
EmailAdress = pEnvelope.User.Email
EmailSubject = String.Empty
EmailType = pStatus
Message = pEnvelope.Message
ReferenceID = pEnvelope.Id
ReferenceString = pEnvelope.Uuid
ReceiverName = pEnvelope.User.FullName
ReceiverAccessCode = String.Empty
SenderAdress = pEnvelope.User.Email
SenderName = pEnvelope.User.FullName
EnvelopeTitle = pEnvelope.Title
End Sub
End Class End Class

View File

@ -7,6 +7,8 @@ Imports System.Security.Cryptography
Imports System.IO Imports System.IO
Imports EnvelopeGenerator.Common.Jobs.FinalizeDocument.FinalizeDocumentExceptions Imports EnvelopeGenerator.Common.Jobs.FinalizeDocument.FinalizeDocumentExceptions
Imports EnvelopeGenerator.Common.Jobs.FinalizeDocument Imports EnvelopeGenerator.Common.Jobs.FinalizeDocument
Imports EnvelopeGenerator.Common.My.Resources
Imports EnvelopeGenerator.Common.Constants
Namespace Jobs Namespace Jobs
Public Class FinalizeDocumentJob Public Class FinalizeDocumentJob
@ -142,6 +144,8 @@ Namespace Jobs
Throw New ExportDocumentException("Could not export final document to disk!", ex) Throw New ExportDocumentException("Could not export final document to disk!", ex)
End Try End Try
SendFinalEmails(oEnvelope, oOutputFilePath)
oCurrent += 1 oCurrent += 1
Logger.Info("Envelope finalized!") Logger.Info("Envelope finalized!")
@ -162,7 +166,62 @@ Namespace Jobs
Return Task.FromResult(True) Return Task.FromResult(True)
End Function End Function
Private Function SendFinalEmails(pEnvelope As Envelope, pAttachment As String) As Boolean
Dim oMailToCreator = pEnvelope.FinalEmailToCreator
Dim oMailToReceivers = pEnvelope.FinalEmailToReceivers
If oMailToCreator <> FinalEmailType.No Then
SendFinalEmailToCreator(pEnvelope, pAttachment)
End If
If oMailToReceivers <> FinalEmailType.No Then
SendFinalEmailToReceivers(pEnvelope, pAttachment)
End If
Return True
End Function
Private Function SendFinalEmailToCreator(pEnvelope As Envelope, pAttachment As String) As Boolean
Dim oIncludeAttachment = SendFinalEmailWithAttachment(pEnvelope.FinalEmailToCreator)
Dim oAttachment = Nothing
If oIncludeAttachment Then
oAttachment = pAttachment
End If
If ActionService.CompleteEnvelope(pEnvelope, oAttachment) = False Then
Logger.Error("Envelope could not be completed for receiver [{0}]", pEnvelope.User.Email)
Return False
End If
Return True
End Function
Private Function SendFinalEmailToReceivers(pEnvelope As Envelope, pAttachment As String) As Boolean
Dim oIncludeAttachment = SendFinalEmailWithAttachment(pEnvelope.FinalEmailToReceivers)
Dim oAttachment = Nothing
If oIncludeAttachment Then
oAttachment = pAttachment
End If
For Each oReceiver In pEnvelope.Receivers
If ActionService.CompleteEnvelope(pEnvelope, oReceiver, oAttachment) = False Then
Logger.Error("Envelope could not be completed for receiver [{0}]", oReceiver.Email)
Return False
End If
Next
Return True
End Function
Private Function SendFinalEmailWithAttachment(pType As FinalEmailType)
If pType = FinalEmailType.YesWithAttachment Then
Return True
Else
Return False
End If
End Function
Private Function BurnAnnotationsToPdf(pData As EnvelopeData) As Byte() Private Function BurnAnnotationsToPdf(pData As EnvelopeData) As Byte()
Dim pEnvelopeId = pData.EnvelopeId Dim pEnvelopeId = pData.EnvelopeId

View File

@ -12,8 +12,8 @@ Public Class EmailModel
Public Function Insert(pEmail As EmailData) As Boolean Public Function Insert(pEmail As EmailData) As Boolean
Try Try
Dim oSql = "INSERT INTO [dbo].[TBEMLP_EMAIL_OUT] " Dim oSql = "INSERT INTO [dbo].[TBEMLP_EMAIL_OUT] "
oSql += " (EMAIL_ADRESS, EMAIL_SUBJ, EMAIL_BODY, ADDED_WHO, SENDING_PROFILE, REFERENCE_ID, REFERENCE_STRING, REMINDER_TYPE_ID, WF_ID) " oSql += " (EMAIL_ADRESS, EMAIL_SUBJ, EMAIL_BODY, ADDED_WHO, SENDING_PROFILE, REFERENCE_ID, REFERENCE_STRING, REMINDER_TYPE_ID, EMAIL_ATTMT1, WF_ID) "
oSql += " VALUES (@EMAIL_ADRESS, @EMAIL_SUBJ, @EMAIL_BODY, @ADDED_WHO, @SENDING_PROFILE, @REFERENCE_ID, @REFERENCE_STRING, @REMINDER_TYPE_ID, @WF_ID)" oSql += " VALUES (@EMAIL_ADRESS, @EMAIL_SUBJ, @EMAIL_BODY, @ADDED_WHO, @SENDING_PROFILE, @REFERENCE_ID, @REFERENCE_STRING, @REMINDER_TYPE_ID, @EMAIL_ATTMT1, @WF_ID)"
Dim oCommand As New SqlCommand(oSql) Dim oCommand As New SqlCommand(oSql)
oCommand.Parameters.Add("EMAIL_ADRESS", SqlDbType.NVarChar).Value = pEmail.EmailAdress oCommand.Parameters.Add("EMAIL_ADRESS", SqlDbType.NVarChar).Value = pEmail.EmailAdress
oCommand.Parameters.Add("EMAIL_SUBJ", SqlDbType.NVarChar).Value = pEmail.EmailSubject oCommand.Parameters.Add("EMAIL_SUBJ", SqlDbType.NVarChar).Value = pEmail.EmailSubject
@ -23,6 +23,7 @@ Public Class EmailModel
oCommand.Parameters.Add("REFERENCE_ID", SqlDbType.Int).Value = pEmail.ReferenceID oCommand.Parameters.Add("REFERENCE_ID", SqlDbType.Int).Value = pEmail.ReferenceID
oCommand.Parameters.Add("REFERENCE_STRING", SqlDbType.NVarChar).Value = pEmail.ReferenceString oCommand.Parameters.Add("REFERENCE_STRING", SqlDbType.NVarChar).Value = pEmail.ReferenceString
oCommand.Parameters.Add("REMINDER_TYPE_ID", SqlDbType.Int).Value = 202377 oCommand.Parameters.Add("REMINDER_TYPE_ID", SqlDbType.Int).Value = 202377
oCommand.Parameters.Add("EMAIL_ATTMT1", SqlDbType.NVarChar).Value = pEmail.EmailAttachment
oCommand.Parameters.Add("WF_ID", SqlDbType.Int).Value = pEmail.EmailType ' Wegen DB-Trigger MUSS dieser Wert gesetzt werden oCommand.Parameters.Add("WF_ID", SqlDbType.Int).Value = pEmail.EmailType ' Wegen DB-Trigger MUSS dieser Wert gesetzt werden
If Database.ExecuteNonQuery(oCommand) Then If Database.ExecuteNonQuery(oCommand) Then

View File

@ -108,4 +108,12 @@ Public Class ActionService
Return True Return True
End Function End Function
Public Function CompleteEnvelope(pEnvelope As Envelope, pReceiver As EnvelopeReceiver, pAttachment As String) As Boolean
Return EmailService.SendDocumentCompletedEmailToReceiver(pEnvelope, pReceiver, pAttachment)
End Function
Public Function CompleteEnvelope(pEnvelope As Envelope, pAttachment As String) As Boolean
Return EmailService.SendDocumentCompletedEmailToCreator(pEnvelope, pAttachment)
End Function
End Class End Class

View File

@ -5,17 +5,12 @@ Imports DigitalData.Modules.Logging
Public Class EmailService Public Class EmailService
Inherits BaseService Inherits BaseService
Private ReadOnly EnvelopeModel As EnvelopeModel
Private ReadOnly ReceiverModel As ReceiverModel
Private ReadOnly EmailModel As EmailModel Private ReadOnly EmailModel As EmailModel
Private ReadOnly EmailTemplate As EmailTemplate Private ReadOnly EmailTemplate As EmailTemplate
Public Sub New(pState As State) Public Sub New(pState As State)
MyBase.New(pState) MyBase.New(pState)
EnvelopeModel = New EnvelopeModel(pState)
ReceiverModel = New ReceiverModel(pState)
EmailModel = New EmailModel(pState) EmailModel = New EmailModel(pState)
EmailTemplate = New EmailTemplate(pState) EmailTemplate = New EmailTemplate(pState)
End Sub End Sub
@ -85,5 +80,39 @@ Public Class EmailService
Return True Return True
End Function End Function
Public Function SendDocumentCompletedEmailToReceiver(pEnvelope As Envelope, pReceiver As EnvelopeReceiver, pAttachment As String) As Boolean
Dim oEmailData = New EmailData(pEnvelope, pReceiver, Constants.EnvelopeStatus.MessageCompletionSent) With
{
.SignatureLink = "",
.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
Public Function SendDocumentCompletedEmailToCreator(pEnvelope As Envelope, pAttachment As String) As Boolean
Dim oEmailData = New EmailData(pEnvelope, Constants.EnvelopeStatus.MessageCompletionSent) With
{
.SignatureLink = "",
.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 End Class

View File

@ -26,17 +26,15 @@
} }
async deleteAnnotations(instance) { async deleteAnnotations(instance) {
let pageAnnotations = this.getAnnotations(instance) const allAnnotations = await this.getAnnotations(instance)
.filter( const pageAnnotations = allAnnotations.filter(this.isSignature)
(annotation) =>
!!annotation.isSignature || annotation.description == 'FRAME'
)
//deleting all Annotations //deleting all Annotations
return await instance.delete(pageAnnotations) return await instance.delete(pageAnnotations)
} }
async validateAnnotations(instance) { async validateAnnotations(instance) {
let pageAnnotations = this.getAnnotations(instance) const allAnnotations = await this.getAnnotations(instance)
const pageAnnotations = allAnnotations
.map((annotation) => { .map((annotation) => {
console.log(annotation.toJS()) console.log(annotation.toJS())
return annotation return annotation
@ -45,6 +43,10 @@
return true return true
} }
isSignature(annotation) {
return !!annotation.isSignature || annotation.description == 'FRAME'
}
createAnnotationFromElement(element) { createAnnotationFromElement(element) {
const id = PSPDFKit.generateInstantId() const id = PSPDFKit.generateInstantId()
const width = this.inchToPoint(element.width) const width = this.inchToPoint(element.width)

View File

@ -165,18 +165,14 @@ class App {
case 'RESET': case 'RESET':
result = await this.handleReset(null) result = await this.handleReset(null)
console.log(result)
if (result == true) { if (result == true) {
Swal.fire({ Swal.fire({
title: 'Erfolg', title: 'Erfolg',
text: 'Dokument wurde zurückgesetzt', text: 'Dokument wurde zurückgesetzt',
icon: 'info', icon: 'info',
}) })
} else {
Swal.fire({
title: 'Fehler',
text: 'Dokument konnte nicht zurückgesetzt werden!',
icon: 'error',
})
} }
break break
@ -293,17 +289,13 @@ class App {
title: 'Sind sie sicher?', title: 'Sind sie sicher?',
text: 'Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?', text: 'Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?',
icon: 'question', icon: 'question',
showCancelButton: true
}) })
if (result.isConfirmed) { if (result.isConfirmed) {
const result = this.Annotation.deleteAnnotations(this.Instance) const result = await this.Annotation.deleteAnnotations(this.Instance)
return true
} }
if (result.isDimissed) { return result
return true
}
return false
} }
} }