diff --git a/EnvelopeGenerator.Common/Constants.vb b/EnvelopeGenerator.Common/Constants.vb
index a3c6fa73..9a0cb767 100644
--- a/EnvelopeGenerator.Common/Constants.vb
+++ b/EnvelopeGenerator.Common/Constants.vb
@@ -22,6 +22,7 @@
MessageAccessCodeSent = 3002
MessageConfirmationSent = 3003
MessageDeletionSent = 3004
+ MessageCompletionSent = 3005
End Enum
Public Enum ElementStatus
diff --git a/EnvelopeGenerator.Common/Entities/EmailData.vb b/EnvelopeGenerator.Common/Entities/EmailData.vb
index 673f3a1f..e5a01427 100644
--- a/EnvelopeGenerator.Common/Entities/EmailData.vb
+++ b/EnvelopeGenerator.Common/Entities/EmailData.vb
@@ -16,10 +16,19 @@ Public Class EmailData
Public Property Message As String
Public Property EnvelopeTitle As String
+ Public Property EmailAttachment As String = ""
+
+ '''
+ ''' Constructor for sending email to receiver
+ '''
+ '''
+ '''
+ '''
Public Sub New(pEnvelope As Envelope, pReceiver As EnvelopeReceiver, pStatus As Constants.EnvelopeStatus)
EmailAdress = pReceiver.Email
EmailSubject = String.Empty
EmailType = pStatus
+
Message = pEnvelope.Message
ReferenceID = pEnvelope.Id
ReferenceString = pEnvelope.Uuid
@@ -30,4 +39,24 @@ Public Class EmailData
EnvelopeTitle = pEnvelope.Title
End Sub
+ '''
+ ''' Constructor for sending email to creator
+ '''
+ '''
+ '''
+ 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
diff --git a/EnvelopeGenerator.Common/Jobs/FinalizeDocument/FinalizeDocumentJob.vb b/EnvelopeGenerator.Common/Jobs/FinalizeDocument/FinalizeDocumentJob.vb
index be54b15c..48fa2eea 100644
--- a/EnvelopeGenerator.Common/Jobs/FinalizeDocument/FinalizeDocumentJob.vb
+++ b/EnvelopeGenerator.Common/Jobs/FinalizeDocument/FinalizeDocumentJob.vb
@@ -7,6 +7,8 @@ Imports System.Security.Cryptography
Imports System.IO
Imports EnvelopeGenerator.Common.Jobs.FinalizeDocument.FinalizeDocumentExceptions
Imports EnvelopeGenerator.Common.Jobs.FinalizeDocument
+Imports EnvelopeGenerator.Common.My.Resources
+Imports EnvelopeGenerator.Common.Constants
Namespace Jobs
Public Class FinalizeDocumentJob
@@ -142,6 +144,8 @@ Namespace Jobs
Throw New ExportDocumentException("Could not export final document to disk!", ex)
End Try
+ SendFinalEmails(oEnvelope, oOutputFilePath)
+
oCurrent += 1
Logger.Info("Envelope finalized!")
@@ -162,7 +166,62 @@ Namespace Jobs
Return Task.FromResult(True)
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()
Dim pEnvelopeId = pData.EnvelopeId
diff --git a/EnvelopeGenerator.Common/Models/EmailModel.vb b/EnvelopeGenerator.Common/Models/EmailModel.vb
index bb1dbe51..f658dd36 100644
--- a/EnvelopeGenerator.Common/Models/EmailModel.vb
+++ b/EnvelopeGenerator.Common/Models/EmailModel.vb
@@ -12,8 +12,8 @@ Public Class EmailModel
Public Function Insert(pEmail As EmailData) As Boolean
Try
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 += " VALUES (@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, @EMAIL_ATTMT1, @WF_ID)"
Dim oCommand As New SqlCommand(oSql)
oCommand.Parameters.Add("EMAIL_ADRESS", SqlDbType.NVarChar).Value = pEmail.EmailAdress
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_STRING", SqlDbType.NVarChar).Value = pEmail.ReferenceString
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
If Database.ExecuteNonQuery(oCommand) Then
diff --git a/EnvelopeGenerator.Common/Services/ActionService.vb b/EnvelopeGenerator.Common/Services/ActionService.vb
index e759a7f9..0b3d5037 100644
--- a/EnvelopeGenerator.Common/Services/ActionService.vb
+++ b/EnvelopeGenerator.Common/Services/ActionService.vb
@@ -108,4 +108,12 @@ Public Class ActionService
Return True
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
\ No newline at end of file
diff --git a/EnvelopeGenerator.Common/Services/EmailService.vb b/EnvelopeGenerator.Common/Services/EmailService.vb
index c23ea3cc..4026ba53 100644
--- a/EnvelopeGenerator.Common/Services/EmailService.vb
+++ b/EnvelopeGenerator.Common/Services/EmailService.vb
@@ -5,17 +5,12 @@ Imports DigitalData.Modules.Logging
Public Class EmailService
Inherits BaseService
- 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)
- EnvelopeModel = New EnvelopeModel(pState)
- ReceiverModel = New ReceiverModel(pState)
EmailModel = New EmailModel(pState)
EmailTemplate = New EmailTemplate(pState)
End Sub
@@ -85,5 +80,39 @@ Public Class EmailService
Return True
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
diff --git a/EnvelopeGenerator.Web/wwwroot/js/annotation.js b/EnvelopeGenerator.Web/wwwroot/js/annotation.js
index eede16bc..2daa6a4b 100644
--- a/EnvelopeGenerator.Web/wwwroot/js/annotation.js
+++ b/EnvelopeGenerator.Web/wwwroot/js/annotation.js
@@ -26,17 +26,15 @@
}
async deleteAnnotations(instance) {
- let pageAnnotations = this.getAnnotations(instance)
- .filter(
- (annotation) =>
- !!annotation.isSignature || annotation.description == 'FRAME'
- )
+ const allAnnotations = await this.getAnnotations(instance)
+ const pageAnnotations = allAnnotations.filter(this.isSignature)
//deleting all Annotations
return await instance.delete(pageAnnotations)
- }
+ }
async validateAnnotations(instance) {
- let pageAnnotations = this.getAnnotations(instance)
+ const allAnnotations = await this.getAnnotations(instance)
+ const pageAnnotations = allAnnotations
.map((annotation) => {
console.log(annotation.toJS())
return annotation
@@ -45,6 +43,10 @@
return true
}
+ isSignature(annotation) {
+ return !!annotation.isSignature || annotation.description == 'FRAME'
+ }
+
createAnnotationFromElement(element) {
const id = PSPDFKit.generateInstantId()
const width = this.inchToPoint(element.width)
diff --git a/EnvelopeGenerator.Web/wwwroot/js/app.js b/EnvelopeGenerator.Web/wwwroot/js/app.js
index f36c1d00..b8e2811e 100644
--- a/EnvelopeGenerator.Web/wwwroot/js/app.js
+++ b/EnvelopeGenerator.Web/wwwroot/js/app.js
@@ -165,18 +165,14 @@ class App {
case 'RESET':
result = await this.handleReset(null)
+ console.log(result)
+
if (result == true) {
Swal.fire({
title: 'Erfolg',
text: 'Dokument wurde zurückgesetzt',
icon: 'info',
})
- } else {
- Swal.fire({
- title: 'Fehler',
- text: 'Dokument konnte nicht zurückgesetzt werden!',
- icon: 'error',
- })
}
break
@@ -293,17 +289,13 @@ class App {
title: 'Sind sie sicher?',
text: 'Wollen Sie das Dokument und alle erstellten Signaturen zurücksetzen?',
icon: 'question',
+ showCancelButton: true
})
if (result.isConfirmed) {
- const result = this.Annotation.deleteAnnotations(this.Instance)
- return true
+ const result = await this.Annotation.deleteAnnotations(this.Instance)
}
- if (result.isDimissed) {
- return true
- }
-
- return false
+ return result
}
}