20-09-2023
This commit is contained in:
@@ -4,8 +4,6 @@ Imports System.IO
|
||||
Public Class EnvelopeDocument
|
||||
Public Property Id As Integer
|
||||
|
||||
Public Property FileInfo As FileInfo
|
||||
|
||||
Public Property FileNameOriginal As String
|
||||
|
||||
Public Property IsTempFile As Boolean = True
|
||||
@@ -16,15 +14,7 @@ Public Class EnvelopeDocument
|
||||
|
||||
Public Property Elements As New List(Of EnvelopeDocumentElement)
|
||||
|
||||
Public ReadOnly Property Filename As String
|
||||
Get
|
||||
Return FileInfo.Name
|
||||
End Get
|
||||
End Property
|
||||
Public Property Filename As String
|
||||
|
||||
Public ReadOnly Property Filepath As String
|
||||
Get
|
||||
Return FileInfo.FullName
|
||||
End Get
|
||||
End Property
|
||||
Public Property Filepath As String
|
||||
End Class
|
||||
|
||||
4
EnvelopeGenerator.Common/Entities/EnvelopeResponse.vb
Normal file
4
EnvelopeGenerator.Common/Entities/EnvelopeResponse.vb
Normal file
@@ -0,0 +1,4 @@
|
||||
Public Class EnvelopeResponse
|
||||
Public Property Envelope As Envelope
|
||||
Public Property ReceiverId As Integer
|
||||
End Class
|
||||
@@ -101,6 +101,7 @@
|
||||
<Compile Include="Entities\EnvelopeDocumentElement.vb" />
|
||||
<Compile Include="Entities\EnvelopeHistoryEntry.vb" />
|
||||
<Compile Include="Entities\EnvelopeReceiver.vb" />
|
||||
<Compile Include="Entities\EnvelopeResponse.vb" />
|
||||
<Compile Include="Entities\State.vb" />
|
||||
<Compile Include="Entities\User.vb" />
|
||||
<Compile Include="Helpers.vb" />
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
Public Class Helpers
|
||||
|
||||
''' <summary>
|
||||
''' Encodes the EnvelopeUUID and the ReceiverSignature into an EnvelopeKey
|
||||
''' </summary>
|
||||
''' <param name="pEnvelopeUuid"></param>
|
||||
''' <param name="pReceiverSignature"></param>
|
||||
''' <returns>The EnvelopeKey</returns>
|
||||
Public Shared Function EncodeEnvelopeReceiverId(pEnvelopeUuid As String, pReceiverSignature As String) As String
|
||||
Dim oString = $"{pEnvelopeUuid}::{pReceiverSignature}"
|
||||
'TODO: Verschlüsseln
|
||||
Return oString
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Decodes the EnvelopeKey and returns the EnvelopeUUID and the ReceiverSignature
|
||||
''' </summary>
|
||||
''' <param name="pEnvelopeReceiverId">The EnvelopeKey</param>
|
||||
''' <returns>A tuple containing EnvelopeUUID and Receiver Signature</returns>
|
||||
Public Shared Function DecodeEnvelopeReceiverId(pEnvelopeReceiverId As String) As Tuple(Of String, String)
|
||||
Dim oSplit = pEnvelopeReceiverId.Split("::")
|
||||
Dim oSplit = pEnvelopeReceiverId.Split(New String() {"::"}, StringSplitOptions.None)
|
||||
'TODO: Entschlüsseln
|
||||
Return New Tuple(Of String, String)(oSplit(0), oSplit(1))
|
||||
End Function
|
||||
|
||||
@@ -15,14 +15,19 @@ Public Class DocumentModel
|
||||
End Sub
|
||||
|
||||
Private Function ToDocument(pRow As DataRow) As EnvelopeDocument
|
||||
Return ToDocument(pRow, 0)
|
||||
End Function
|
||||
|
||||
Private Function ToDocument(pRow As DataRow, pReceiverId As Integer) As EnvelopeDocument
|
||||
Dim oDocumentId = pRow.ItemEx("GUID", 0)
|
||||
Return New EnvelopeDocument() With {
|
||||
.Id = oDocumentId,
|
||||
.EnvelopeId = pRow.ItemEx("ENVELOPE_ID", 0),
|
||||
.FileInfo = New IO.FileInfo(pRow.ItemEx("FILEPATH", "")),
|
||||
.Filename = pRow.ItemEx("FILENAME", ""),
|
||||
.Filepath = pRow.ItemEx("FILEPATH", ""),
|
||||
.FileNameOriginal = pRow.ItemEx("FILENAME_ORIGINAL", ""),
|
||||
.IsTempFile = False,
|
||||
.Elements = ElementModel.List(oDocumentId)
|
||||
.Elements = ElementModel.List(oDocumentId, pReceiverId)
|
||||
}
|
||||
End Function
|
||||
|
||||
@@ -32,7 +37,7 @@ Public Class DocumentModel
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
|
||||
Return oTable?.Rows.Cast(Of DataRow).
|
||||
Select(AddressOf ToDocument).
|
||||
Select(Function(row) ToDocument(row)).
|
||||
Single()
|
||||
|
||||
Catch ex As Exception
|
||||
@@ -47,7 +52,22 @@ Public Class DocumentModel
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
|
||||
Return oTable?.Rows.Cast(Of DataRow).
|
||||
Select(AddressOf ToDocument).
|
||||
Select(Function(row) ToDocument(row)).
|
||||
ToList()
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function List(pEnvelopeId As Integer, pReceiverId As Integer) As IEnumerable(Of EnvelopeDocument)
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_ENVELOPE_DOCUMENT] WHERE ENVELOPE_ID = {pEnvelopeId}"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
|
||||
Return oTable?.Rows.Cast(Of DataRow).
|
||||
Select(Function(row) ToDocument(row, pReceiverId)).
|
||||
ToList()
|
||||
|
||||
Catch ex As Exception
|
||||
|
||||
@@ -23,6 +23,12 @@ Public Class ElementModel
|
||||
}
|
||||
End Function
|
||||
|
||||
Private Function ToElements(pTable As DataTable) As List(Of EnvelopeDocumentElement)
|
||||
Return pTable?.Rows.Cast(Of DataRow).
|
||||
Select(AddressOf ToElement).
|
||||
ToList()
|
||||
End Function
|
||||
|
||||
Public Function ElementsExist(pEnvelopeId As Integer, pReceiverId As Integer) As Boolean
|
||||
Try
|
||||
Dim oSql = $"SELECT COUNT(*) FROM [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] T
|
||||
@@ -58,9 +64,25 @@ Public Class ElementModel
|
||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] WHERE DOCUMENT_ID = {pDocumentId} ORDER BY PAGE ASC"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
|
||||
Return oTable?.Rows.Cast(Of DataRow).
|
||||
Select(AddressOf ToElement).
|
||||
ToList()
|
||||
Return ToElements(oTable)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function List(pDocumentId As Integer, pReceiverId As Integer) As List(Of EnvelopeDocumentElement)
|
||||
Try
|
||||
Dim oReceiverConstraint = ""
|
||||
If pReceiverId > 0 Then
|
||||
oReceiverConstraint = $"AND RECEIVER_ID = {pReceiverId}"
|
||||
End If
|
||||
|
||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_DOCUMENT_RECEIVER_ELEMENT] WHERE DOCUMENT_ID = {pDocumentId} {oReceiverConstraint} ORDER BY PAGE ASC"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
|
||||
Return ToElements(oTable)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
@@ -160,6 +182,7 @@ Public Class ElementModel
|
||||
Try
|
||||
Dim oSql = $"DELETE FROM TBSIG_DOCUMENT_RECEIVER_ELEMENT WHERE GUID = {pElement.Id}"
|
||||
Return Database.ExecuteNonQuery(oSql)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
@@ -170,6 +193,7 @@ Public Class ElementModel
|
||||
Try
|
||||
Dim oSql = $"DELETE FROM TBSIG_DOCUMENT_RECEIVER_ELEMENT WHERE RECEIVER_ID = {pReceiverId} AND DOCUMENT_ID = {pDocumentId}"
|
||||
Return Database.ExecuteNonQuery(oSql, pTransaction)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
@@ -180,6 +204,7 @@ Public Class ElementModel
|
||||
Try
|
||||
Dim oSql = $"DELETE FROM TBSIG_DOCUMENT_RECEIVER_ELEMENT WHERE DOCUMENT_ID = {pDocumentId}"
|
||||
Return Database.ExecuteNonQuery(oSql, pTransaction)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Web.UI.WebControls
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
@@ -26,14 +27,18 @@ Public Class EnvelopeModel
|
||||
Return oEnvelope
|
||||
End Function
|
||||
|
||||
Private Function ToEnvelope(pTable As DataTable) As Envelope
|
||||
Return pTable?.Rows.Cast(Of DataRow).
|
||||
Select(AddressOf ToEnvelope).
|
||||
Single()
|
||||
End Function
|
||||
|
||||
Public Function GetByUuid(pEnvelopeUuid As String) As Envelope
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_ENVELOPE] WHERE ENVELOPE_UUID = '{pEnvelopeUuid}'"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
|
||||
Return oTable?.Rows.Cast(Of DataRow).
|
||||
Select(AddressOf ToEnvelope).
|
||||
Single()
|
||||
Return ToEnvelope(oTable)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
@@ -54,6 +59,23 @@ Public Class EnvelopeModel
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function List(pReceiverId As Integer) As IEnumerable(Of Envelope)
|
||||
Try
|
||||
Dim oSql = $"SELECT T.* FROM [dbo].[TBSIG_ENVELOPE] T
|
||||
JOIN TBSIG_ENVELOPE_RECEIVER T2 ON T.GUID = T2.ENVELOPE_ID
|
||||
WHERE T2.RECEIVER_ID = {pReceiverId}"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
|
||||
Return oTable?.Rows.Cast(Of DataRow).
|
||||
Select(AddressOf ToEnvelope).
|
||||
ToList()
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Send(pEnvelope As Envelope) As Boolean
|
||||
Try
|
||||
Dim oSql = "UPDATE [dbo].[TBSIG_ENVELOPE] SET STATUS = @STATUS, SENT_WHEN = GETDATE() WHERE GUID = @GUID"
|
||||
@@ -149,7 +171,7 @@ Public Class EnvelopeModel
|
||||
|
||||
Private Sub SetEnvelopeDate(pEnvelope As Envelope)
|
||||
Try
|
||||
Dim addedWhen As DateTime = Database.GetScalarValue($"SELECT ADDED_WHEN FROM TBSIG_ENVELOPE WHERE GUID = {pEnvelope.Id}")
|
||||
Dim addedWhen As Date = Database.GetScalarValue($"SELECT ADDED_WHEN FROM TBSIG_ENVELOPE WHERE GUID = {pEnvelope.Id}")
|
||||
pEnvelope.AddedWhen = addedWhen
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
|
||||
@@ -44,7 +44,7 @@ Public Class ReceiverModel
|
||||
|
||||
Dim oResult = Database.ExecuteNonQuery(oCommand)
|
||||
If oResult = True Then
|
||||
pReceiver.Id = GetReceiverId(pReceiver.Email, pTransaction)
|
||||
pReceiver.Id = GetReceiverIdByEmail(pReceiver.Email, pTransaction)
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
@@ -168,7 +168,16 @@ Public Class ReceiverModel
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetReceiverId(pEmailAddress As String, pTransaction As SqlTransaction) As Integer
|
||||
Public Function GetReceiverIdBySignature(pSignature As String) As Integer
|
||||
Try
|
||||
Return Database.GetScalarValue($"SELECT GUID FROM TBSIG_RECEIVER WHERE SIGNATURE = '{pSignature}'")
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetReceiverIdByEmail(pEmailAddress As String, pTransaction As SqlTransaction) As Integer
|
||||
Try
|
||||
Return Database.GetScalarValue($"SELECT GUID FROM TBSIG_RECEIVER WHERE EMAIL_ADDRESS = '{pEmailAddress}'", pTransaction)
|
||||
|
||||
@@ -177,4 +186,6 @@ Public Class ReceiverModel
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user