Fix empty receiver signature when sending

This commit is contained in:
Jonathan Jenne 2023-11-28 15:54:35 +01:00
parent 38577f66e0
commit 80246b8964
2 changed files with 13 additions and 12 deletions

View File

@ -33,6 +33,11 @@ Public Class EnvelopeEditorController
Public Function SendEnvelope() As Boolean Public Function SendEnvelope() As Boolean
For Each receiverItem As EnvelopeReceiver In Envelope.Receivers For Each receiverItem As EnvelopeReceiver In Envelope.Receivers
If receiverItem.Signature Is Nothing Then
Logger.Warn("Signature for Receiver is empty. Aborting.")
Return False
End If
Dim oEmailData As New EmailData(Envelope, receiverItem) With Dim oEmailData As New EmailData(Envelope, receiverItem) With
{ {
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, Envelope.Uuid, receiverItem.Signature) .SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, Envelope.Uuid, receiverItem.Signature)
@ -266,22 +271,16 @@ Public Class EnvelopeEditorController
End Function End Function
Public Function CreateEnvelopeReceivers(pCurrentReceivers As List(Of EnvelopeReceiver)) As Boolean Public Function CreateEnvelopeReceivers(pCurrentReceivers As List(Of EnvelopeReceiver)) As Boolean
Dim oExistingReceivers As List(Of EnvelopeReceiver) = ReceiverModel.ListReceivers(pCurrentReceivers) Dim oExistingReceivers As List(Of EnvelopeReceiver) = ReceiverModel.ListReceivers(pCurrentReceivers).ToList()
Dim oExistingAddresses = oExistingReceivers.Select(Function(r) r.Email) Dim oExistingAddresses = oExistingReceivers.Select(Function(r) r.Email)
' Neue Empfänger ' Neue Empfänger
Dim oNewReceivers = pCurrentReceivers. Dim oNewReceivers = pCurrentReceivers.
Where(Function(r) Not oExistingAddresses.Contains(r.Email)).ToList() Where(Function(r) Not oExistingAddresses.Contains(r.Email)).ToList()
' Empfänger, die bereits einmal verwendet wurden If oNewReceivers.Count = 0 Then
For Each oCurrentReceiver In pCurrentReceivers Return True
If oCurrentReceiver.Id = 0 Then End If
Dim oExistingReceiver As EnvelopeReceiver = oExistingReceivers.Where(Function(r) r.Email.Equals(oCurrentReceiver.Email, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault()
If oExistingReceiver IsNot Nothing Then
oCurrentReceiver.Id = oExistingReceiver.Id
End If
End If
Next
Dim oConnection = Database.GetConnection() Dim oConnection = Database.GetConnection()
Dim oTransaction = oConnection.BeginTransaction() Dim oTransaction = oConnection.BeginTransaction()
@ -293,6 +292,9 @@ Public Class EnvelopeEditorController
oTransaction.Commit() oTransaction.Commit()
' Empfänger neu aus der Datenbank laden
Envelope.Receivers = ReceiverModel.ListReceivers(pCurrentReceivers).ToList()
Return True Return True
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)

View File

@ -184,7 +184,6 @@ Partial Public Class frmEnvelopeEditor
Dim oEnvelope = Controller.Envelope Dim oEnvelope = Controller.Envelope
oEnvelope.Subject = oSubject oEnvelope.Subject = oSubject
oEnvelope.Message = oMessage oEnvelope.Message = oMessage
oEnvelope.Receivers = Receivers.ToList
oEnvelope.Documents = Documents.ToList oEnvelope.Documents = Documents.ToList
If pWithValidation = True Then If pWithValidation = True Then
@ -195,7 +194,7 @@ Partial Public Class frmEnvelopeEditor
End If End If
End If End If
If Controller.CreateEnvelopeReceivers(oEnvelope.Receivers) = False Then If Controller.CreateEnvelopeReceivers(Receivers.ToList) = False Then
MsgBox(Resources.Envelope.Error_when_saving_the_recipients, MsgBoxStyle.Critical, Text) MsgBox(Resources.Envelope.Error_when_saving_the_recipients, MsgBoxStyle.Critical, Text)
Return False Return False
End If End If