09-08-2023
This commit is contained in:
parent
73149e2101
commit
7c31ccee1c
@ -42,7 +42,7 @@ Public Class ReceiverModel
|
||||
oCommand.Parameters.Add("EMAIL", SqlDbType.NVarChar).Value = pReceiver.Email
|
||||
oCommand.Parameters.Add("SIGNATURE", SqlDbType.NVarChar).Value = pReceiver.Signature
|
||||
|
||||
Dim oResult = Database.ExecuteNonQuery(oCommand, pTransaction)
|
||||
Dim oResult = Database.ExecuteNonQuery(oCommand)
|
||||
If oResult = True Then
|
||||
pReceiver.Id = GetReceiverId(pReceiver.Email, pTransaction)
|
||||
Else
|
||||
@ -120,7 +120,7 @@ Public Class ReceiverModel
|
||||
Return Database.ExecuteNonQuery(oCommand, pTransaction)
|
||||
End Function
|
||||
|
||||
Public Function List(pEnvelopeId As Integer) As IEnumerable(Of EnvelopeReceiver)
|
||||
Public Function ListEnvelopeReceivers(pEnvelopeId As Integer) As IEnumerable(Of EnvelopeReceiver)
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [dbo].[VWSIG_ENVELOPE_RECEIVERS] WHERE ENVELOPE_ID = {pEnvelopeId}"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
@ -135,6 +135,22 @@ Public Class ReceiverModel
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ListReceivers(pExistingReceivers As IEnumerable(Of EnvelopeReceiver)) As IEnumerable(Of EnvelopeReceiver)
|
||||
Try
|
||||
Dim oAddresses = pExistingReceivers.Select(Function(r) $"'{r.Email}'").JoinToString(",")
|
||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_RECEIVER] WHERE EMAIL_ADDRESS IN ({oAddresses})"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
|
||||
Return oTable?.Rows.Cast(Of DataRow).
|
||||
Select(AddressOf ToReceiver).
|
||||
ToList()
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Delete(pReceiverId As Integer, pDocumentId As Integer) As Boolean
|
||||
Try
|
||||
Dim oSql = $"DELETE FROM TBSIG_DOCUMENT_RECEIVER WHERE RECEIVER_ID = {pReceiverId} AND DOCUMENT_ID = {pDocumentId}"
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Data.Common
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Database
|
||||
@ -42,7 +43,7 @@ Public Class EnvelopeEditorController
|
||||
|
||||
Envelope = pEnvelope
|
||||
Envelope.Documents = DocumentModel.List(pEnvelope.Id)
|
||||
Envelope.Receivers = ReceiverModel.List(pEnvelope.Id)
|
||||
Envelope.Receivers = ReceiverModel.ListEnvelopeReceivers(pEnvelope.Id)
|
||||
End Sub
|
||||
|
||||
Private Sub InitializeModels(pState As State)
|
||||
@ -66,8 +67,8 @@ Public Class EnvelopeEditorController
|
||||
.EnvelopeId = oEnvelope.Id,
|
||||
.Status = HistoryStatus.Created,
|
||||
.ActionTitle = "Envelope erzeugt",
|
||||
.ActionDescription = "Envelope wurde erzeugt",
|
||||
}
|
||||
.ActionDescription = "Envelope wurde erzeugt"
|
||||
}
|
||||
'TODO .UserEmailAddress = oEnvelope.User.Email ' TODO - fehlt noch
|
||||
|
||||
Return oEnvelope
|
||||
@ -81,7 +82,7 @@ Public Class EnvelopeEditorController
|
||||
Dim oTransaction = oConnection.BeginTransaction(IsolationLevel.ReadUncommitted)
|
||||
|
||||
Try
|
||||
pEnvelope.Status = Common.Constants.EnvelopeStatus.Created
|
||||
pEnvelope.Status = EnvelopeStatus.Saved
|
||||
|
||||
If SaveEnvelopeDocumentsToFilesystem(pEnvelope) = False Then
|
||||
Throw New ApplicationException
|
||||
@ -205,16 +206,50 @@ Public Class EnvelopeEditorController
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function CreateEnvelopeReceivers(pReceivers As List(Of EnvelopeReceiver)) As Boolean
|
||||
Dim oExistingReceivers As List(Of EnvelopeReceiver) = ReceiverModel.ListReceivers(pReceivers)
|
||||
Dim oExistingAddresses = oExistingReceivers.Select(Function(r) r.Email)
|
||||
|
||||
Dim oNewReceivers = pReceivers.
|
||||
Where(Function(r) Not oExistingAddresses.Contains(r.Email)).ToList()
|
||||
|
||||
Dim oOldReceivers = pReceivers.
|
||||
Where(Function(r) oExistingAddresses.Contains(r.Email)).ToList()
|
||||
|
||||
For Each oReceiver In oOldReceivers
|
||||
oReceiver.Id = oExistingReceivers.
|
||||
Where(Function(r) r.Email = oReceiver.Email).
|
||||
Select(Function(r) r.Id).
|
||||
FirstOrDefault()
|
||||
Next
|
||||
|
||||
Dim oConnection = Database.GetConnection()
|
||||
Dim oTransaction = oConnection.BeginTransaction()
|
||||
|
||||
Try
|
||||
|
||||
If InsertReceivers(oNewReceivers, oTransaction) = False Then
|
||||
Throw New ApplicationException("Could not insert receivers!")
|
||||
End If
|
||||
|
||||
oTransaction.Commit()
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
oTransaction.Rollback()
|
||||
|
||||
Return False
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function SaveEnvelopeReceivers(pEnvelope As Envelope, pTransaction As SqlTransaction) As Boolean
|
||||
Try
|
||||
If pEnvelope.Id = Nothing Then
|
||||
Throw New ArgumentNullException("EnvelopeId")
|
||||
End If
|
||||
|
||||
If InsertReceivers(pEnvelope.Receivers, pTransaction) = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
If AssignReceivers(pEnvelope, pTransaction) = False Then
|
||||
Return False
|
||||
End If
|
||||
@ -262,10 +297,6 @@ Public Class EnvelopeEditorController
|
||||
End Function
|
||||
|
||||
Private Function InsertReceiver(pReceiver As EnvelopeReceiver, pTransaction As SqlTransaction) As Boolean
|
||||
If ReceiverModel.TestReceiverExists(pReceiver) Then
|
||||
Return True
|
||||
End If
|
||||
|
||||
If pReceiver.HasId = False Then
|
||||
Return ReceiverModel.Insert(pReceiver, pTransaction)
|
||||
Else
|
||||
|
||||
@ -56,8 +56,9 @@ Public Class FieldEditorController
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function SaveElements() As Boolean
|
||||
Public Function SaveElements(pReceiverId As Integer) As Boolean
|
||||
Return Elements.
|
||||
Where(Function(e) e.ReceiverId = pReceiverId).
|
||||
Select(AddressOf SaveElement).
|
||||
All(Function(pResult) pResult = True)
|
||||
End Function
|
||||
|
||||
@ -95,10 +95,16 @@ Partial Public Class frmEnvelopeEditor
|
||||
' Ensure all receivers are saved
|
||||
ViewReceivers.CloseEditor()
|
||||
|
||||
Dim oReceivers = Receivers.ToList
|
||||
If Controller.CreateEnvelopeReceivers(Receivers.ToList) = False Then
|
||||
MsgBox("Fehler beim Speichern der Empfänger!", MsgBoxStyle.Critical, Text)
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim oEnvelope = Controller.Envelope
|
||||
oEnvelope.Subject = oSubject
|
||||
oEnvelope.Message = oMessage
|
||||
oEnvelope.Receivers = Receivers.ToList
|
||||
oEnvelope.Receivers = oReceivers
|
||||
oEnvelope.Documents = Documents.ToList
|
||||
|
||||
Dim oErrors = oEnvelope.Validate()
|
||||
|
||||
@ -69,7 +69,9 @@ Partial Public Class frmFieldEditor
|
||||
End Function
|
||||
|
||||
Private Sub BarItem_Click(sender As Object, e As ItemClickEventArgs)
|
||||
If Controller.SaveElements() Then
|
||||
AddElements()
|
||||
|
||||
If Controller.SaveElements(SelectedReceiver.Id) Then
|
||||
Dim oReceiver As EnvelopeReceiver = e.Item.Tag
|
||||
SetReceiver(oReceiver)
|
||||
ClearAnnotations()
|
||||
@ -122,10 +124,19 @@ Partial Public Class frmFieldEditor
|
||||
End Sub
|
||||
|
||||
Private Sub btnSave_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnSave.ItemClick
|
||||
Dim oPageCount = GDViewer.PageCount
|
||||
Dim oCurrentPage = GDViewer.CurrentPage
|
||||
|
||||
'TODO: Save Annotations in Background
|
||||
AddElements()
|
||||
|
||||
If Not Controller.SaveElements(SelectedReceiver.Id) Then
|
||||
MsgBox("Elemente konnten nicht gespeichert werden!", MsgBoxStyle.Critical, Text)
|
||||
End If
|
||||
|
||||
GDViewer.DisplayPage(GDViewer.CurrentPage)
|
||||
End Sub
|
||||
|
||||
Private Sub AddElements()
|
||||
Dim oPageCount = GDViewer.PageCount
|
||||
|
||||
For oPage = 1 To oPageCount
|
||||
GDViewer.DisplayPage(oPage)
|
||||
Dim oAnnotationCount = GDViewer.GetAnnotationCount()
|
||||
@ -138,16 +149,8 @@ Partial Public Class frmFieldEditor
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
|
||||
If Not Controller.SaveElements() Then
|
||||
MsgBox("Elemente konnten nicht gespeichert werden!", MsgBoxStyle.Critical, Text)
|
||||
End If
|
||||
|
||||
GDViewer.DisplayPage(oCurrentPage)
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub ApplyAnnotationStyle(ByRef pAnnotation As Annotation)
|
||||
If TypeOf pAnnotation Is AnnotationStickyNote Then
|
||||
Dim oStickyNote As AnnotationStickyNote = pAnnotation
|
||||
@ -187,8 +190,8 @@ Partial Public Class frmFieldEditor
|
||||
oAnnotation.Text = "SIGNATUR"
|
||||
oAnnotation.Tag = GetAnnotationTag(pReceiverId, oPage, oIndex)
|
||||
|
||||
If Manager.SaveAnnotationsToPage() = GdPictureStatus.OK Then
|
||||
End If
|
||||
'If Manager.SaveAnnotationsToPage() = GdPictureStatus.OK Then
|
||||
'End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@ -209,7 +212,10 @@ Partial Public Class frmFieldEditor
|
||||
For oPage = 1 To oPageCount
|
||||
GDViewer.DisplayPage(oPage)
|
||||
Dim oCurrentPage = oPage
|
||||
Dim oElements = Controller.Elements.Where(Function(element) element.Page = oCurrentPage And element.ReceiverId = pReceiverId).ToList()
|
||||
Dim oElements = Controller.Elements.
|
||||
Where(Function(e) e.Page = oCurrentPage And e.ReceiverId = pReceiverId).
|
||||
ToList()
|
||||
|
||||
For Each oElement In oElements
|
||||
LoadAnnotation(oElement, pReceiverId)
|
||||
Next
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user