10.01.2024

This commit is contained in:
Jonathan Jenne 2024-01-10 09:31:04 +01:00
parent b7fbb21076
commit 277f5d3f0d
8 changed files with 148 additions and 27 deletions

View File

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

View File

@ -16,10 +16,19 @@ Public Class EmailData
Public Property Message 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)
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
''' <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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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
}
}