29-11-2023
This commit is contained in:
parent
c964b97e55
commit
1b88a6cff7
@ -2,11 +2,18 @@
|
|||||||
|
|
||||||
#Region "Status Fields"
|
#Region "Status Fields"
|
||||||
Public Enum EnvelopeStatus
|
Public Enum EnvelopeStatus
|
||||||
Created = 0
|
EnvelopeCreated = 1001
|
||||||
Saved = 1
|
EnvelopeSaved = 1002
|
||||||
Sent = 2
|
EnvelopeQueued = 1003
|
||||||
PartlySigned = 3
|
EnvelopeSent = 1004
|
||||||
CompletelySigned = 4
|
EnvelopePartlySigned = 1005
|
||||||
|
EnvelopeCompletelySigned = 1006
|
||||||
|
EnvelopeArchived = 1007
|
||||||
|
EnvelopeTransmittedDMS = 1008
|
||||||
|
EnvelopeDeleted = 1009
|
||||||
|
DocumentOpened = 2001
|
||||||
|
DocumentSigned = 2002
|
||||||
|
SignatureConfirmed = 2003
|
||||||
End Enum
|
End Enum
|
||||||
|
|
||||||
Public Enum ElementStatus
|
Public Enum ElementStatus
|
||||||
@ -26,16 +33,16 @@
|
|||||||
''' <summary>
|
''' <summary>
|
||||||
''' This is a status, which is called Type because it fits with the other action fields
|
''' This is a status, which is called Type because it fits with the other action fields
|
||||||
''' </summary>
|
''' </summary>
|
||||||
Public Enum EnvelopeHistoryActionType
|
'Public Enum EnvelopeHistoryActionType
|
||||||
Created = 0
|
' Created = 0
|
||||||
Saved = 1
|
' Saved = 1
|
||||||
Sent = 2
|
' Sent = 2
|
||||||
EmailSent = 3
|
' EmailSent = 3
|
||||||
Delivered = 4
|
' Delivered = 4
|
||||||
Seen = 5
|
' Seen = 5
|
||||||
Signed = 6
|
' Signed = 6
|
||||||
Rejected = 7
|
' Rejected = 7
|
||||||
End Enum
|
'End Enum
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
#Region "Type Fields"
|
#Region "Type Fields"
|
||||||
|
|||||||
@ -4,6 +4,7 @@ Public Class EmailTemplate
|
|||||||
Private _DocumentReceivedBodyTemplate As List(Of String)
|
Private _DocumentReceivedBodyTemplate As List(Of String)
|
||||||
Private _DocumentSignedBodyTemplate As List(Of String)
|
Private _DocumentSignedBodyTemplate As List(Of String)
|
||||||
Private _DocumentCompletedBodyTemplate As List(Of String)
|
Private _DocumentCompletedBodyTemplate As List(Of String)
|
||||||
|
Private _DocumentDeletedBodyTemplate As List(Of String)
|
||||||
|
|
||||||
Private _replaceDictionary As Dictionary(Of String, String)
|
Private _replaceDictionary As Dictionary(Of String, String)
|
||||||
|
|
||||||
@ -34,6 +35,15 @@ Public Class EmailTemplate
|
|||||||
"<NAME_SENDER>"
|
"<NAME_SENDER>"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_DocumentDeletedBodyTemplate = New List(Of String) From {
|
||||||
|
"Guten Tag, <NAME_RECEIVER>",
|
||||||
|
"",
|
||||||
|
"Der User <NAME_SENDER> hat den Umschlag <DOCUMENT_TITLE> gelöscht.",
|
||||||
|
"",
|
||||||
|
"Mit freundlichen Grüßen",
|
||||||
|
"<NAME_SENDER>"
|
||||||
|
}
|
||||||
|
|
||||||
_DocumentCompletedBodyTemplate = New List(Of String) From {
|
_DocumentCompletedBodyTemplate = New List(Of String) From {
|
||||||
"Guten Tag, <NAME_RECEIVER>",
|
"Guten Tag, <NAME_RECEIVER>",
|
||||||
"",
|
"",
|
||||||
@ -60,6 +70,10 @@ Public Class EmailTemplate
|
|||||||
FillEmailBody(pEmailData, _DocumentReceivedBodyTemplate)
|
FillEmailBody(pEmailData, _DocumentReceivedBodyTemplate)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Public Sub FillEnvelopeDeletedEmailBody(pEmailData As EmailData)
|
||||||
|
FillEmailBody(pEmailData, _DocumentDeletedBodyTemplate)
|
||||||
|
End Sub
|
||||||
|
|
||||||
Public Sub FillDocumentSignedEmailBody(pEmailData As EmailData)
|
Public Sub FillDocumentSignedEmailBody(pEmailData As EmailData)
|
||||||
FillEmailBody(pEmailData, _DocumentSignedBodyTemplate)
|
FillEmailBody(pEmailData, _DocumentSignedBodyTemplate)
|
||||||
End Sub
|
End Sub
|
||||||
|
|||||||
@ -29,33 +29,7 @@
|
|||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
Public Function Validate() As List(Of String)
|
|
||||||
Dim oErrors As New List(Of String)
|
|
||||||
|
|
||||||
If String.IsNullOrWhiteSpace(Subject) Then
|
|
||||||
oErrors.Add(My.Resources.Envelope.Missing_Subject)
|
|
||||||
End If
|
|
||||||
|
|
||||||
If String.IsNullOrWhiteSpace(Message) Then
|
|
||||||
oErrors.Add(My.Resources.Envelope.Missing_Message)
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Documents.Count = 0 Then
|
|
||||||
oErrors.Add(My.Resources.Envelope.Missing_Documents)
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Receivers.Count = 0 Then
|
|
||||||
oErrors.Add(My.Resources.Envelope.Missing_Receivers)
|
|
||||||
End If
|
|
||||||
|
|
||||||
For Each Receiver In Receivers
|
|
||||||
If IsValidEmailAddress(Receiver.Email) = False Then
|
|
||||||
oErrors.Add(String.Format(My.Resources.Envelope.Invalid_Email_Address, Receiver.Name))
|
|
||||||
End If
|
|
||||||
Next
|
|
||||||
|
|
||||||
Return oErrors
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function ValidateReceiverDocumentData() As List(Of String)
|
Public Function ValidateReceiverDocumentData() As List(Of String)
|
||||||
Dim oErrors As New List(Of String)
|
Dim oErrors As New List(Of String)
|
||||||
@ -72,12 +46,5 @@
|
|||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|
||||||
Private Function IsValidEmailAddress(pEmailAddress As String) As Boolean
|
|
||||||
Try
|
|
||||||
Dim oAddress = New System.Net.Mail.MailAddress(pEmailAddress)
|
|
||||||
Return oAddress.Address = pEmailAddress
|
|
||||||
Catch ex As Exception
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
Public Class EnvelopeHistoryEntry
|
Public Class EnvelopeHistoryEntry
|
||||||
Public EnvelopeId As Integer
|
Public EnvelopeId As Integer
|
||||||
Public UserReference As String
|
Public UserReference As String
|
||||||
Public ActionType As Constants.EnvelopeHistoryActionType
|
Public Status As Constants.EnvelopeStatus
|
||||||
Public ActionDate As Date
|
Public ActionDate As Date = Now()
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -137,7 +137,9 @@
|
|||||||
<DependentUpon>Settings.settings</DependentUpon>
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Services\ActionService.vb" />
|
||||||
<Compile Include="Services\EmailService.vb" />
|
<Compile Include="Services\EmailService.vb" />
|
||||||
|
<Compile Include="Services\HistoryService.vb" />
|
||||||
<Compile Include="Strings\Email.en.Designer.vb">
|
<Compile Include="Strings\Email.en.Designer.vb">
|
||||||
<DependentUpon>Email.en.resx</DependentUpon>
|
<DependentUpon>Email.en.resx</DependentUpon>
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
|
|||||||
@ -85,4 +85,13 @@ Public Class Helpers
|
|||||||
|
|
||||||
Return oColoredImage
|
Return oColoredImage
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Shared Function IsValidEmailAddress(pEmailAddress As String) As Boolean
|
||||||
|
Try
|
||||||
|
Dim oAddress = New System.Net.Mail.MailAddress(pEmailAddress)
|
||||||
|
Return oAddress.Address = pEmailAddress
|
||||||
|
Catch ex As Exception
|
||||||
|
Return False
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -27,7 +27,7 @@ Public Class EnvelopeModel
|
|||||||
.Subject = pRow.ItemEx("SUBJECT", ""),
|
.Subject = pRow.ItemEx("SUBJECT", ""),
|
||||||
.Message = pRow.ItemEx("MESSAGE", ""),
|
.Message = pRow.ItemEx("MESSAGE", ""),
|
||||||
.UserId = pRow.ItemEx("USER_ID", 0),
|
.UserId = pRow.ItemEx("USER_ID", 0),
|
||||||
.Status = ObjectEx.ToEnum(Of Constants.EnvelopeStatus)(pRow.ItemEx("STATUS", Constants.EnvelopeStatus.Created.ToString())),
|
.Status = ObjectEx.ToEnum(Of Constants.EnvelopeStatus)(pRow.ItemEx("STATUS", Constants.EnvelopeStatus.EnvelopeCreated.ToString())),
|
||||||
.AddedWhen = pRow.Item("ADDED_WHEN"),
|
.AddedWhen = pRow.Item("ADDED_WHEN"),
|
||||||
.User = New User()
|
.User = New User()
|
||||||
}
|
}
|
||||||
@ -57,6 +57,18 @@ Public Class EnvelopeModel
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function GetById(pEnvelopeId As String) As Envelope
|
||||||
|
Try
|
||||||
|
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_ENVELOPE] WHERE GUID = '{pEnvelopeId}'"
|
||||||
|
Dim oTable = Database.GetDatatable(oSql)
|
||||||
|
|
||||||
|
Return ToEnvelope(oTable)
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
Return Nothing
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Function List() As IEnumerable(Of Envelope)
|
Public Function List() As IEnumerable(Of Envelope)
|
||||||
Try
|
Try
|
||||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_ENVELOPE] WHERE USER_ID = {State.UserId} AND STATUS IN (0,1,2,3)"
|
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_ENVELOPE] WHERE USER_ID = {State.UserId} AND STATUS IN (0,1,2,3)"
|
||||||
@ -102,25 +114,6 @@ Public Class EnvelopeModel
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
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"
|
|
||||||
Dim oCommand As New SqlCommand(oSql)
|
|
||||||
oCommand.Parameters.Add("GUID", SqlDbType.Int).Value = pEnvelope.Id
|
|
||||||
oCommand.Parameters.Add("STATUS", SqlDbType.Int).Value = Constants.EnvelopeStatus.Sent
|
|
||||||
|
|
||||||
If Database.ExecuteNonQuery(oCommand) Then
|
|
||||||
Return True
|
|
||||||
Else
|
|
||||||
Return False
|
|
||||||
End If
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Logger.Error(ex)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function Insert(pEnvelope As Envelope) As Boolean
|
Public Function Insert(pEnvelope As Envelope) As Boolean
|
||||||
Try
|
Try
|
||||||
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE] (SUBJECT, MESSAGE, ENVELOPE_UUID, STATUS, USER_ID, TITLE, CONTRACT_TYPE) "
|
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE] (SUBJECT, MESSAGE, ENVELOPE_UUID, STATUS, USER_ID, TITLE, CONTRACT_TYPE) "
|
||||||
@ -129,7 +122,7 @@ Public Class EnvelopeModel
|
|||||||
oCommand.Parameters.Add("SUBJECT", SqlDbType.NVarChar).Value = String.Empty
|
oCommand.Parameters.Add("SUBJECT", SqlDbType.NVarChar).Value = String.Empty
|
||||||
oCommand.Parameters.Add("MESSAGE", SqlDbType.NVarChar).Value = String.Empty
|
oCommand.Parameters.Add("MESSAGE", SqlDbType.NVarChar).Value = String.Empty
|
||||||
oCommand.Parameters.Add("UUID", SqlDbType.NVarChar).Value = pEnvelope.Uuid
|
oCommand.Parameters.Add("UUID", SqlDbType.NVarChar).Value = pEnvelope.Uuid
|
||||||
oCommand.Parameters.Add("STATUS", SqlDbType.Int).Value = Constants.EnvelopeStatus.Created
|
oCommand.Parameters.Add("STATUS", SqlDbType.Int).Value = Constants.EnvelopeStatus.EnvelopeCreated
|
||||||
oCommand.Parameters.Add("USER_ID", SqlDbType.Int).Value = pEnvelope.UserId
|
oCommand.Parameters.Add("USER_ID", SqlDbType.Int).Value = pEnvelope.UserId
|
||||||
oCommand.Parameters.Add("TITLE", SqlDbType.NVarChar).Value = pEnvelope.Title
|
oCommand.Parameters.Add("TITLE", SqlDbType.NVarChar).Value = pEnvelope.Title
|
||||||
oCommand.Parameters.Add("CONTRACT_TYPE", SqlDbType.Int).Value = pEnvelope.ContractType
|
oCommand.Parameters.Add("CONTRACT_TYPE", SqlDbType.Int).Value = pEnvelope.ContractType
|
||||||
@ -179,7 +172,7 @@ Public Class EnvelopeModel
|
|||||||
Public Function Delete(pEnvelope As Envelope, pTransaction As SqlTransaction) As Boolean
|
Public Function Delete(pEnvelope As Envelope, pTransaction As SqlTransaction) As Boolean
|
||||||
Try
|
Try
|
||||||
Dim oSql = $"DELETE FROM [dbo].[TBSIG_ENVELOPE] WHERE GUID = {pEnvelope.Id}"
|
Dim oSql = $"DELETE FROM [dbo].[TBSIG_ENVELOPE] WHERE GUID = {pEnvelope.Id}"
|
||||||
Return Database.ExecuteNonQuery(oSql, pTransaction)
|
'Return Database.ExecuteNonQuery(oSql, pTransaction)
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Return False
|
Return False
|
||||||
|
|||||||
@ -7,46 +7,24 @@ Public Class HistoryModel
|
|||||||
MyBase.New(pState)
|
MyBase.New(pState)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Function GetActionDescription(pActionType As Constants.EnvelopeHistoryActionType)
|
|
||||||
Select Case pActionType
|
|
||||||
Case Constants.EnvelopeHistoryActionType.Created
|
|
||||||
Return "Umschlag erfolgreich erstellt"
|
|
||||||
|
|
||||||
Case Constants.EnvelopeHistoryActionType.Sent
|
|
||||||
Return "Umschlag an Empfänger versendet"
|
|
||||||
|
|
||||||
Case Constants.EnvelopeHistoryActionType.Seen
|
|
||||||
Return "Umschlag von Empfänger geöffnet"
|
|
||||||
|
|
||||||
Case Constants.EnvelopeHistoryActionType.Signed
|
|
||||||
Return "Umschlag von Empfänger signiert"
|
|
||||||
|
|
||||||
Case Else
|
|
||||||
Return pActionType.ToString()
|
|
||||||
End Select
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function Insert(pHistory As EnvelopeHistoryEntry) As Boolean
|
Public Function Insert(pHistory As EnvelopeHistoryEntry) As Boolean
|
||||||
Try
|
Try
|
||||||
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE_HISTORY] "
|
Dim oSql = "INSERT INTO [dbo].[TBSIG_ENVELOPE_HISTORY] "
|
||||||
oSql += " ([ENVELOPE_ID] "
|
oSql += " ([ENVELOPE_ID] "
|
||||||
oSql += " ,[USER_REFERENCE] "
|
oSql += " ,[USER_REFERENCE] "
|
||||||
oSql += " ,[ACTION_TYPE] "
|
oSql += " ,[STATUS] "
|
||||||
oSql += " ,[ACTION_DESCRIPTION] "
|
|
||||||
oSql += " ,[ACTION_DATE]) "
|
oSql += " ,[ACTION_DATE]) "
|
||||||
oSql += " VALUES "
|
oSql += " VALUES "
|
||||||
oSql += " (@ENVELOPE_ID "
|
oSql += " (@ENVELOPE_ID "
|
||||||
oSql += " ,@USER_REFERENCE "
|
oSql += " ,@USER_REFERENCE "
|
||||||
oSql += " ,@ACTION_TYPE "
|
oSql += " ,@STATUS "
|
||||||
oSql += " ,@ACTION_DESCRIPTION "
|
|
||||||
oSql += " ,@ACTION_DATE) "
|
oSql += " ,@ACTION_DATE) "
|
||||||
|
|
||||||
Dim oCommand As New SqlCommand(oSql)
|
Dim oCommand As New SqlCommand(oSql)
|
||||||
oCommand.Parameters.Add("ENVELOPE_ID", SqlDbType.Int).Value = pHistory.EnvelopeId
|
oCommand.Parameters.Add("ENVELOPE_ID", SqlDbType.Int).Value = pHistory.EnvelopeId
|
||||||
oCommand.Parameters.Add("USER_REFERENCE", SqlDbType.NVarChar).Value = pHistory.UserReference
|
oCommand.Parameters.Add("USER_REFERENCE", SqlDbType.NVarChar).Value = pHistory.UserReference
|
||||||
oCommand.Parameters.Add("ACTION_TYPE", SqlDbType.Int).Value = pHistory.ActionType
|
oCommand.Parameters.Add("STATUS", SqlDbType.Int).Value = pHistory.Status
|
||||||
oCommand.Parameters.Add("ACTION_DESCRIPTION", SqlDbType.NVarChar).Value = GetActionDescription(pHistory.ActionType)
|
oCommand.Parameters.Add("ACTION_DATE", SqlDbType.DateTime).Value = pHistory.ActionDate
|
||||||
oCommand.Parameters.Add("ACTION_DATE", SqlDbType.DateTime).Value = Now()
|
|
||||||
|
|
||||||
If Database.ExecuteNonQuery(oCommand) Then
|
If Database.ExecuteNonQuery(oCommand) Then
|
||||||
Return True
|
Return True
|
||||||
|
|||||||
@ -23,6 +23,12 @@ Public Class ReceiverModel
|
|||||||
}
|
}
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Private Function ToReceiver(pTable As DataTable) As EnvelopeReceiver
|
||||||
|
Return pTable?.Rows.Cast(Of DataRow).
|
||||||
|
Select(AddressOf ToReceiver).
|
||||||
|
Single()
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Function TestReceiverExists(pReceiver As EnvelopeReceiver) As Boolean
|
Public Function TestReceiverExists(pReceiver As EnvelopeReceiver) As Boolean
|
||||||
Try
|
Try
|
||||||
Dim oGuid = Database.GetScalarValue($"SELECT COALESCE(GUID, 0) FROM TBSIG_RECEIVER WHERE EMAIL_ADDRESS = '{pReceiver.Email}'")
|
Dim oGuid = Database.GetScalarValue($"SELECT COALESCE(GUID, 0) FROM TBSIG_RECEIVER WHERE EMAIL_ADDRESS = '{pReceiver.Email}'")
|
||||||
@ -140,13 +146,13 @@ Public Class ReceiverModel
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function ListReceivers(pExistingReceivers As IEnumerable(Of EnvelopeReceiver)) As IEnumerable(Of EnvelopeReceiver)
|
Public Function ListReceivers(pReceiversFromGrid As List(Of EnvelopeReceiver)) As IEnumerable(Of EnvelopeReceiver)
|
||||||
Try
|
Try
|
||||||
If pExistingReceivers.Count = 0 Then
|
If pReceiversFromGrid.Count = 0 Then
|
||||||
Return New List(Of EnvelopeReceiver)
|
Return New List(Of EnvelopeReceiver)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim oAddresses = pExistingReceivers.Select(Function(r) $"'{r.Email}'").JoinToString(",")
|
Dim oAddresses = pReceiversFromGrid.Select(Function(r) $"'{r.Email}'").JoinToString(",")
|
||||||
|
|
||||||
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_RECEIVER] WHERE EMAIL_ADDRESS IN ({oAddresses})"
|
Dim oSql = $"SELECT * FROM [dbo].[TBSIG_RECEIVER] WHERE EMAIL_ADDRESS IN ({oAddresses})"
|
||||||
Dim oTable = Database.GetDatatable(oSql)
|
Dim oTable = Database.GetDatatable(oSql)
|
||||||
@ -173,6 +179,19 @@ Public Class ReceiverModel
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function GetById(pReceiverId As Integer) As EnvelopeReceiver
|
||||||
|
Try
|
||||||
|
Dim oSql = $"SELECT * FROM [dbo].[VWSIG_ENVELOPE_RECEIVERS] WHERE GUID = {pReceiverId}"
|
||||||
|
Dim oTable = Database.GetDatatable(oSql)
|
||||||
|
|
||||||
|
Return ToReceiver(oTable)
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
Return Nothing
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Function GetReceiverIdBySignature(pSignature As String) As Integer
|
Public Function GetReceiverIdBySignature(pSignature As String) As Integer
|
||||||
Try
|
Try
|
||||||
Return Database.GetScalarValue($"SELECT GUID FROM TBSIG_RECEIVER WHERE SIGNATURE = '{pSignature}'")
|
Return Database.GetScalarValue($"SELECT GUID FROM TBSIG_RECEIVER WHERE SIGNATURE = '{pSignature}'")
|
||||||
|
|||||||
32
EnvelopeGenerator.Common/Services/ActionService.vb
Normal file
32
EnvelopeGenerator.Common/Services/ActionService.vb
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
Imports DigitalData.Modules.Base
|
||||||
|
|
||||||
|
Public Class ActionService
|
||||||
|
Inherits BaseClass
|
||||||
|
|
||||||
|
Private ReadOnly State As State
|
||||||
|
|
||||||
|
Private EmailService As EmailService
|
||||||
|
Private HistoryService As HistoryService
|
||||||
|
|
||||||
|
|
||||||
|
Public Sub New(pState As State)
|
||||||
|
MyBase.New(pState.LogConfig)
|
||||||
|
|
||||||
|
State = pState
|
||||||
|
EmailService = New EmailService(pState)
|
||||||
|
HistoryService = New HistoryService(pState)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Function DeleteEnvelope(pEnvelope As Envelope) As Boolean
|
||||||
|
|
||||||
|
HistoryService.SetEnvelopeStatus(pEnvelope, Constants.EnvelopeStatus.EnvelopeDeleted, pEnvelope.User.Email)
|
||||||
|
|
||||||
|
For Each oReceiver As EnvelopeReceiver In pEnvelope.Receivers
|
||||||
|
EmailService.SendEnvelopeDeletedEmail(oReceiver.Id, pEnvelope.Id)
|
||||||
|
Next
|
||||||
|
|
||||||
|
|
||||||
|
Return True
|
||||||
|
End Function
|
||||||
|
|
||||||
|
End Class
|
||||||
@ -1,18 +1,79 @@
|
|||||||
Imports DigitalData.Modules.Base
|
|
||||||
|
Imports DigitalData.Modules.Base
|
||||||
Imports DigitalData.Modules.Logging
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
Public Class EmailService
|
Public Class EmailService
|
||||||
Inherits BaseClass
|
Inherits BaseClass
|
||||||
|
|
||||||
|
Private ReadOnly State As State
|
||||||
|
|
||||||
|
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)
|
Public Sub New(pState As State)
|
||||||
MyBase.New(pState.LogConfig)
|
MyBase.New(pState.LogConfig)
|
||||||
|
|
||||||
|
State = pState
|
||||||
|
EnvelopeModel = New EnvelopeModel(pState)
|
||||||
|
ReceiverModel = New ReceiverModel(pState)
|
||||||
|
EmailModel = New EmailModel(pState)
|
||||||
|
EmailTemplate = New EmailTemplate()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Function SendSignedEmail(pReceiverId As Integer, pEnvelopeId As Integer)
|
Public Function SendEnvelopeDeletedEmail(pReceiverId As Integer, pEnvelopeId As Integer) As Boolean
|
||||||
|
Dim oEnvelope = EnvelopeModel.GetById(pEnvelopeId)
|
||||||
|
Dim oReceiver = ReceiverModel.GetById(pReceiverId)
|
||||||
|
|
||||||
Dim oEnvelope =
|
Dim oEmailData As New EmailData(oEnvelope, oReceiver) With
|
||||||
|
{
|
||||||
|
.SignatureLink = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
EmailTemplate.FillEnvelopeDeletedEmailBody(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 SendInitialEmail(pReceiverId As Integer, pEnvelopeId As Integer) As Boolean
|
||||||
|
Dim oEnvelope = EnvelopeModel.GetById(pEnvelopeId)
|
||||||
|
Dim oReceiver = ReceiverModel.GetById(pReceiverId)
|
||||||
|
|
||||||
|
Dim oEmailData As New EmailData(oEnvelope, oReceiver) With
|
||||||
|
{
|
||||||
|
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, oEnvelope.Uuid, oReceiver.Signature)
|
||||||
|
}
|
||||||
|
|
||||||
|
EmailTemplate.FillDocumentReceivedEmailBody(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 SendSignedEmail(pReceiverId As Integer, pEnvelopeId As Integer) As Boolean
|
||||||
|
Dim oEnvelope = EnvelopeModel.GetById(pEnvelopeId)
|
||||||
|
Dim oReceiver = ReceiverModel.GetById(pReceiverId)
|
||||||
|
|
||||||
|
Dim oEmailData = New EmailData(oEnvelope, oReceiver) With {.SignatureLink = ""}
|
||||||
|
EmailTemplate.FillDocumentSignedEmailBody(oEmailData)
|
||||||
|
|
||||||
|
If EmailModel.Insert(oEmailData) = False Then
|
||||||
|
Logger.Error("EMail data could not be inserted.")
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return True
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
32
EnvelopeGenerator.Common/Services/HistoryService.vb
Normal file
32
EnvelopeGenerator.Common/Services/HistoryService.vb
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
Imports DigitalData.Modules.Base
|
||||||
|
Imports DigitalData.Modules.Logging
|
||||||
|
Imports EnvelopeGenerator.Common.Constants
|
||||||
|
|
||||||
|
Public Class HistoryService
|
||||||
|
Inherits BaseClass
|
||||||
|
|
||||||
|
Private ReadOnly State As State
|
||||||
|
|
||||||
|
Private ReadOnly EnvelopeModel As EnvelopeModel
|
||||||
|
Private ReadOnly ReceiverModel As ReceiverModel
|
||||||
|
Private ReadOnly HistoryModel As HistoryModel
|
||||||
|
|
||||||
|
Public Sub New(pState As State)
|
||||||
|
MyBase.New(pState.LogConfig)
|
||||||
|
|
||||||
|
State = pState
|
||||||
|
EnvelopeModel = New EnvelopeModel(pState)
|
||||||
|
ReceiverModel = New ReceiverModel(pState)
|
||||||
|
HistoryModel = New HistoryModel(pState)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Function SetEnvelopeStatus(pEnvelope As Envelope, pStatus As EnvelopeStatus, pUserReference As String) As Boolean
|
||||||
|
Return HistoryModel.Insert(New EnvelopeHistoryEntry() With {
|
||||||
|
.EnvelopeId = pEnvelope.Id,
|
||||||
|
.ActionDate = Now(),
|
||||||
|
.Status = pStatus,
|
||||||
|
.UserReference = pUserReference
|
||||||
|
})
|
||||||
|
End Function
|
||||||
|
End Class
|
||||||
@ -14,6 +14,8 @@ Public MustInherit Class BaseController
|
|||||||
Public UserModel As UserModel
|
Public UserModel As UserModel
|
||||||
Public EmailModel As EmailModel
|
Public EmailModel As EmailModel
|
||||||
|
|
||||||
|
Public ActionService As ActionService
|
||||||
|
|
||||||
Public ReadOnly Property Database As MSSQLServer
|
Public ReadOnly Property Database As MSSQLServer
|
||||||
Public ReadOnly Property State As State
|
Public ReadOnly Property State As State
|
||||||
|
|
||||||
@ -22,6 +24,7 @@ Public MustInherit Class BaseController
|
|||||||
State = pState
|
State = pState
|
||||||
Database = pState.Database
|
Database = pState.Database
|
||||||
InitializeModels(pState)
|
InitializeModels(pState)
|
||||||
|
ActionService = New ActionService(pState)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub InitializeModels(pState As State)
|
Private Sub InitializeModels(pState As State)
|
||||||
@ -39,6 +42,15 @@ Public MustInherit Class BaseController
|
|||||||
Return True
|
Return True
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
Return ActionService.DeleteEnvelope(pEnvelope)
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function DeleteEnvelope_Old(pEnvelope As Envelope) As Boolean
|
||||||
|
If pEnvelope Is Nothing Then
|
||||||
|
Return True
|
||||||
|
End If
|
||||||
|
|
||||||
Dim oConnection As SqlConnection = Database.GetConnection()
|
Dim oConnection As SqlConnection = Database.GetConnection()
|
||||||
Dim oTransaction As SqlTransaction = oConnection.BeginTransaction()
|
Dim oTransaction As SqlTransaction = oConnection.BeginTransaction()
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ Public Class EnvelopeEditorController
|
|||||||
Inherits BaseController
|
Inherits BaseController
|
||||||
|
|
||||||
Public ReadOnly Envelope As Envelope = Nothing
|
Public ReadOnly Envelope As Envelope = Nothing
|
||||||
|
Public ReadOnly EmailService As EmailService
|
||||||
|
|
||||||
Public ReadOnly Thumbnail As Thumbnail
|
Public ReadOnly Thumbnail As Thumbnail
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ Public Class EnvelopeEditorController
|
|||||||
|
|
||||||
Envelope = CreateEnvelope()
|
Envelope = CreateEnvelope()
|
||||||
Thumbnail = New Thumbnail(pState.LogConfig)
|
Thumbnail = New Thumbnail(pState.LogConfig)
|
||||||
|
EmailService = New EmailService(pState)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Sub New(pState As State, pEnvelope As Envelope)
|
Public Sub New(pState As State, pEnvelope As Envelope)
|
||||||
@ -27,56 +29,36 @@ Public Class EnvelopeEditorController
|
|||||||
Envelope.Receivers = ReceiverModel.ListEnvelopeReceivers(pEnvelope.Id).ToList()
|
Envelope.Receivers = ReceiverModel.ListEnvelopeReceivers(pEnvelope.Id).ToList()
|
||||||
|
|
||||||
Thumbnail = New Thumbnail(pState.LogConfig)
|
Thumbnail = New Thumbnail(pState.LogConfig)
|
||||||
|
EmailService = New EmailService(pState)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
#Region "Public"
|
#Region "Public"
|
||||||
Public Function SendEnvelope() As Boolean
|
Public Function SendEnvelope() As Boolean
|
||||||
For Each receiverItem As EnvelopeReceiver In Envelope.Receivers
|
|
||||||
|
|
||||||
If receiverItem.Signature Is Nothing Then
|
For Each receiverItem As EnvelopeReceiver In Envelope.Receivers
|
||||||
Logger.Warn("Signature for Receiver is empty. Aborting.")
|
If EmailService.SendInitialEmail(receiverItem.Id, Envelope.Id) = False Then
|
||||||
|
Logger.Warn("Email could not be sent.")
|
||||||
Return False
|
Return False
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim oEmailData As New EmailData(Envelope, receiverItem) With
|
|
||||||
{
|
|
||||||
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, Envelope.Uuid, receiverItem.Signature)
|
|
||||||
}
|
|
||||||
|
|
||||||
Dim oTemplate As New EmailTemplate()
|
|
||||||
oTemplate.FillDocumentReceivedEmailBody(oEmailData)
|
|
||||||
|
|
||||||
If EmailModel.Insert(oEmailData) = False Then
|
|
||||||
Logger.Error("EMail data could not be inserted.")
|
|
||||||
Dim oResult As Boolean = False
|
|
||||||
End If
|
|
||||||
|
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
Dim newHistoryEntry As New EnvelopeHistoryEntry With {
|
||||||
If EnvelopeModel.Send(Envelope) Then
|
|
||||||
|
|
||||||
Dim newHistoryEntry As New EnvelopeHistoryEntry With {
|
|
||||||
.EnvelopeId = Envelope.Id,
|
.EnvelopeId = Envelope.Id,
|
||||||
.ActionType = EnvelopeHistoryActionType.Sent,
|
.Status = EnvelopeStatus.EnvelopeQueued,
|
||||||
.UserReference = Envelope.User.Email
|
.UserReference = Envelope.User.Email
|
||||||
}
|
}
|
||||||
|
|
||||||
If HistoryModel.Insert(newHistoryEntry) Then
|
If HistoryModel.Insert(newHistoryEntry) Then
|
||||||
'TODO: Send email to History
|
Return True
|
||||||
Return True
|
|
||||||
Else
|
|
||||||
Logger.Warn("History Entry could not be created!")
|
|
||||||
Return False
|
|
||||||
End If
|
|
||||||
Else
|
Else
|
||||||
Logger.Warn("Envelope could not be updated!")
|
Logger.Warn("History Entry could not be created!")
|
||||||
Return False
|
Return False
|
||||||
End If
|
End If
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function ValidateEnvelopeForSending() As List(Of String)
|
Public Function ValidateEnvelopeForSending(pErrors As List(Of String)) As List(Of String)
|
||||||
Dim oEnvelopeErrors = Envelope.Validate()
|
Dim oEnvelopeErrors = pErrors
|
||||||
|
|
||||||
If ElementModel.ElementsExist(Envelope.Id) = False Then
|
If ElementModel.ElementsExist(Envelope.Id) = False Then
|
||||||
oEnvelopeErrors.Add(Resources.Envelope.Missing_Elements)
|
oEnvelopeErrors.Add(Resources.Envelope.Missing_Elements)
|
||||||
@ -105,7 +87,7 @@ Public Class EnvelopeEditorController
|
|||||||
|
|
||||||
Dim newHistoryEntry As New EnvelopeHistoryEntry With {
|
Dim newHistoryEntry As New EnvelopeHistoryEntry With {
|
||||||
.EnvelopeId = oEnvelope.Id,
|
.EnvelopeId = oEnvelope.Id,
|
||||||
.ActionType = EnvelopeHistoryActionType.Created,
|
.Status = EnvelopeStatus.EnvelopeCreated,
|
||||||
.UserReference = oEnvelope.User.Email
|
.UserReference = oEnvelope.User.Email
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,12 +99,38 @@ Public Class EnvelopeEditorController
|
|||||||
End If
|
End If
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function SaveReceivers(pEnvelope As Envelope, pReceiversFromGrid As List(Of EnvelopeReceiver)) As Boolean
|
||||||
|
Dim oExistingReceivers As List(Of EnvelopeReceiver) = ReceiverModel.ListReceivers(pReceiversFromGrid).ToList()
|
||||||
|
Dim oExistingAddresses = oExistingReceivers.Select(Function(r) r.Email)
|
||||||
|
Dim oNewReceivers = pReceiversFromGrid.Where(Function(r) Not oExistingAddresses.Contains(r.Email)).ToList()
|
||||||
|
|
||||||
|
If CreateNewReceivers(oNewReceivers) = False Then
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim oAllReceivers As List(Of EnvelopeReceiver) = ReceiverModel.ListReceivers(pReceiversFromGrid).ToList()
|
||||||
|
|
||||||
|
pEnvelope.Receivers.Clear()
|
||||||
|
|
||||||
|
For Each oReceiver In pReceiversFromGrid
|
||||||
|
Dim oDbReceiver = oAllReceivers.Where(Function(r) r.Email = oReceiver.Email).SingleOrDefault()
|
||||||
|
If oDbReceiver IsNot Nothing Then
|
||||||
|
oReceiver.Id = oDbReceiver.Id
|
||||||
|
oReceiver.Signature = oDbReceiver.Signature
|
||||||
|
End If
|
||||||
|
|
||||||
|
pEnvelope.Receivers.Add(oReceiver)
|
||||||
|
Next
|
||||||
|
|
||||||
|
Return True
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Function SaveEnvelope() As Boolean
|
Public Function SaveEnvelope() As Boolean
|
||||||
Dim oConnection = Database.GetConnection()
|
Dim oConnection = Database.GetConnection()
|
||||||
Dim oTransaction = oConnection.BeginTransaction(IsolationLevel.ReadUncommitted)
|
Dim oTransaction = oConnection.BeginTransaction(IsolationLevel.ReadUncommitted)
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Envelope.Status = EnvelopeStatus.Saved
|
Envelope.Status = EnvelopeStatus.EnvelopeSaved
|
||||||
|
|
||||||
If SaveEnvelopeDocumentsToFilesystem(Envelope) = False Then
|
If SaveEnvelopeDocumentsToFilesystem(Envelope) = False Then
|
||||||
Throw New ApplicationException
|
Throw New ApplicationException
|
||||||
@ -152,18 +160,6 @@ Public Class EnvelopeEditorController
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function CleanupEnvelope() As Boolean
|
|
||||||
If Envelope Is Nothing Then
|
|
||||||
Return True
|
|
||||||
End If
|
|
||||||
|
|
||||||
If Envelope.Status = Common.Constants.EnvelopeStatus.Created Then
|
|
||||||
Return DeleteEnvelope(Envelope)
|
|
||||||
Else
|
|
||||||
Return True
|
|
||||||
End If
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Public Function CreateDocument(pDocumentFilePath As String) As EnvelopeDocument
|
Public Function CreateDocument(pDocumentFilePath As String) As EnvelopeDocument
|
||||||
Try
|
Try
|
||||||
Dim oFileInfo = New FileInfo(pDocumentFilePath)
|
Dim oFileInfo = New FileInfo(pDocumentFilePath)
|
||||||
@ -270,15 +266,8 @@ Public Class EnvelopeEditorController
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function CreateEnvelopeReceivers(pCurrentReceivers As List(Of EnvelopeReceiver)) As Boolean
|
Public Function CreateNewReceivers(pNewReceivers As List(Of EnvelopeReceiver)) As Boolean
|
||||||
Dim oExistingReceivers As List(Of EnvelopeReceiver) = ReceiverModel.ListReceivers(pCurrentReceivers).ToList()
|
If pNewReceivers.Count = 0 Then
|
||||||
Dim oExistingAddresses = oExistingReceivers.Select(Function(r) r.Email)
|
|
||||||
|
|
||||||
' Neue Empfänger
|
|
||||||
Dim oNewReceivers = pCurrentReceivers.
|
|
||||||
Where(Function(r) Not oExistingAddresses.Contains(r.Email)).ToList()
|
|
||||||
|
|
||||||
If oNewReceivers.Count = 0 Then
|
|
||||||
Return True
|
Return True
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@ -286,15 +275,12 @@ Public Class EnvelopeEditorController
|
|||||||
Dim oTransaction = oConnection.BeginTransaction()
|
Dim oTransaction = oConnection.BeginTransaction()
|
||||||
|
|
||||||
Try
|
Try
|
||||||
If InsertReceivers(oNewReceivers, oTransaction) = False Then
|
If InsertReceivers(pNewReceivers, oTransaction) = False Then
|
||||||
Throw New ApplicationException("Could not insert receivers!")
|
Throw New ApplicationException("Could not insert receivers!")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@ -4,6 +4,7 @@ Imports DevExpress.Utils.Svg
|
|||||||
Imports DevExpress.XtraEditors
|
Imports DevExpress.XtraEditors
|
||||||
Imports DevExpress.XtraGrid
|
Imports DevExpress.XtraGrid
|
||||||
Imports DevExpress.XtraGrid.Views.Grid
|
Imports DevExpress.XtraGrid.Views.Grid
|
||||||
|
Imports DevExpress.XtraPrinting.Native
|
||||||
Imports DevExpress.XtraSplashScreen
|
Imports DevExpress.XtraSplashScreen
|
||||||
Imports DigitalData.Modules.Logging
|
Imports DigitalData.Modules.Logging
|
||||||
Imports EnvelopeGenerator.Common
|
Imports EnvelopeGenerator.Common
|
||||||
@ -70,7 +71,7 @@ Partial Public Class frmEnvelopeEditor
|
|||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
If Envelope.Status = Constants.EnvelopeStatus.Sent Then
|
If Envelope.Status = Constants.EnvelopeStatus.EnvelopeSent Then
|
||||||
' TODO - Nach Testen
|
' TODO - Nach Testen
|
||||||
' SetFormReadonly()
|
' SetFormReadonly()
|
||||||
End If
|
End If
|
||||||
@ -95,10 +96,6 @@ Partial Public Class frmEnvelopeEditor
|
|||||||
ViewDocuments.OptionsBehavior.ReadOnly = True
|
ViewDocuments.OptionsBehavior.ReadOnly = True
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub frmEnvelopeEditor_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
|
||||||
Controller.CleanupEnvelope()
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub btnDeleteFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDeleteFile.ItemClick
|
Private Sub btnDeleteFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDeleteFile.ItemClick
|
||||||
If ViewDocuments.GetSelectedRows().Count > 0 Then
|
If ViewDocuments.GetSelectedRows().Count > 0 Then
|
||||||
Dim oDocument As EnvelopeDocument = DirectCast(ViewDocuments.GetFocusedRow(), EnvelopeDocument)
|
Dim oDocument As EnvelopeDocument = DirectCast(ViewDocuments.GetFocusedRow(), EnvelopeDocument)
|
||||||
@ -133,7 +130,7 @@ Partial Public Class frmEnvelopeEditor
|
|||||||
Where(Function(d) d.Filename = oDocument.Filename).
|
Where(Function(d) d.Filename = oDocument.Filename).
|
||||||
SingleOrDefault(),
|
SingleOrDefault(),
|
||||||
.GDPictureKey = oGDPictureKey,
|
.GDPictureKey = oGDPictureKey,
|
||||||
.Receivers = Receivers.ToList,
|
.Receivers = Controller.Envelope.Receivers.ToList,
|
||||||
.State = State
|
.State = State
|
||||||
}
|
}
|
||||||
oForm.ShowDialog()
|
oForm.ShowDialog()
|
||||||
@ -174,6 +171,37 @@ Partial Public Class frmEnvelopeEditor
|
|||||||
Return True
|
Return True
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Private Function ValidateEnvelope() As List(Of String)
|
||||||
|
Dim oSubject = GetEditValueFromTextControl(txtSubject)
|
||||||
|
Dim oMessage = GetEditValueFromTextControl(txtMessage)
|
||||||
|
|
||||||
|
Dim oErrors As New List(Of String)
|
||||||
|
|
||||||
|
If String.IsNullOrWhiteSpace(oSubject) Then
|
||||||
|
oErrors.Add(Resources.Envelope.Missing_Subject)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If String.IsNullOrWhiteSpace(oMessage) Then
|
||||||
|
oErrors.Add(Resources.Envelope.Missing_Message)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Documents.Count = 0 Then
|
||||||
|
oErrors.Add(Resources.Envelope.Missing_Documents)
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Receivers.Count = 0 Then
|
||||||
|
oErrors.Add(Resources.Envelope.Missing_Receivers)
|
||||||
|
End If
|
||||||
|
|
||||||
|
For Each Receiver In Receivers
|
||||||
|
If Helpers.IsValidEmailAddress(Receiver.Email) = False Then
|
||||||
|
oErrors.Add(String.Format(Resources.Envelope.Invalid_Email_Address, Receiver.Name))
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
|
||||||
|
Return oErrors
|
||||||
|
End Function
|
||||||
|
|
||||||
Private Function SaveEnvelope(pWithValidation As Boolean) As Boolean
|
Private Function SaveEnvelope(pWithValidation As Boolean) As Boolean
|
||||||
Dim oSubject = GetEditValueFromTextControl(txtSubject)
|
Dim oSubject = GetEditValueFromTextControl(txtSubject)
|
||||||
Dim oMessage = GetEditValueFromTextControl(txtMessage)
|
Dim oMessage = GetEditValueFromTextControl(txtMessage)
|
||||||
@ -181,20 +209,25 @@ Partial Public Class frmEnvelopeEditor
|
|||||||
' Ensure all receivers are saved
|
' Ensure all receivers are saved
|
||||||
ViewReceivers.CloseEditor()
|
ViewReceivers.CloseEditor()
|
||||||
|
|
||||||
Dim oEnvelope = Controller.Envelope
|
|
||||||
oEnvelope.Subject = oSubject
|
|
||||||
oEnvelope.Message = oMessage
|
|
||||||
oEnvelope.Documents = Documents.ToList
|
|
||||||
|
|
||||||
If pWithValidation = True Then
|
If pWithValidation = True Then
|
||||||
Dim oErrors = oEnvelope.Validate()
|
Dim oErrors = ValidateEnvelope()
|
||||||
If oErrors.Any Then
|
If oErrors.Any Then
|
||||||
ShowValidationErrors(Resources.Envelope.Errors_when_saving_the_envelope, oErrors)
|
ShowValidationErrors(Resources.Envelope.Errors_when_saving_the_envelope, oErrors)
|
||||||
Return False
|
Return False
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If Controller.CreateEnvelopeReceivers(Receivers.ToList) = False Then
|
Dim oEnvelope = Controller.Envelope
|
||||||
|
oEnvelope.Subject = oSubject
|
||||||
|
oEnvelope.Message = oMessage
|
||||||
|
oEnvelope.Documents = Documents.ToList
|
||||||
|
|
||||||
|
|
||||||
|
'oEnvelope.Receivers = Receivers.ToList
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
If Controller.SaveReceivers(oEnvelope, 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
|
||||||
@ -249,7 +282,7 @@ Partial Public Class frmEnvelopeEditor
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub btnSendEnvelope_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnSendEnvelope.ItemClick
|
Private Sub btnSendEnvelope_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnSendEnvelope.ItemClick
|
||||||
If Controller.Envelope.Status = Constants.EnvelopeStatus.Sent Then
|
If Controller.Envelope.Status = Constants.EnvelopeStatus.EnvelopeSent Then
|
||||||
MsgBox(Resources.Envelope.Envelope_already_sent, MsgBoxStyle.Information, Text)
|
MsgBox(Resources.Envelope.Envelope_already_sent, MsgBoxStyle.Information, Text)
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
@ -258,7 +291,9 @@ Partial Public Class frmEnvelopeEditor
|
|||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim oErrors = Controller.ValidateEnvelopeForSending()
|
Dim oErrors = ValidateEnvelope()
|
||||||
|
oErrors = Controller.ValidateEnvelopeForSending(oErrors)
|
||||||
|
|
||||||
If oErrors.Any() Then
|
If oErrors.Any() Then
|
||||||
ShowValidationErrors(Resources.Envelope.Error_sending_the_envelope, oErrors)
|
ShowValidationErrors(Resources.Envelope.Error_sending_the_envelope, oErrors)
|
||||||
Exit Sub
|
Exit Sub
|
||||||
|
|||||||
@ -298,10 +298,10 @@
|
|||||||
<value>1088, 158</value>
|
<value>1088, 158</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="RibbonStatusBar.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="RibbonStatusBar.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>0, 657</value>
|
<value>0, 659</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="RibbonStatusBar.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="RibbonStatusBar.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>1088, 24</value>
|
<value>1088, 22</value>
|
||||||
</data>
|
</data>
|
||||||
<data name=">>RibbonStatusBar.Name" xml:space="preserve">
|
<data name=">>RibbonStatusBar.Name" xml:space="preserve">
|
||||||
<value>RibbonStatusBar</value>
|
<value>RibbonStatusBar</value>
|
||||||
@ -328,7 +328,7 @@
|
|||||||
<value>2</value>
|
<value>2</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="GridEnvelopes.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="GridEnvelopes.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>1086, 294</value>
|
<value>1086, 415</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="GridEnvelopes.TabIndex" type="System.Int32, mscorlib">
|
<data name="GridEnvelopes.TabIndex" type="System.Int32, mscorlib">
|
||||||
<value>2</value>
|
<value>2</value>
|
||||||
@ -346,7 +346,7 @@
|
|||||||
<value>0</value>
|
<value>0</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="XtraTabPage1.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="XtraTabPage1.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>1086, 294</value>
|
<value>1086, 415</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="XtraTabPage1.Text" xml:space="preserve">
|
<data name="XtraTabPage1.Text" xml:space="preserve">
|
||||||
<value>Offene Umschläge</value>
|
<value>Offene Umschläge</value>
|
||||||
@ -436,7 +436,7 @@
|
|||||||
<value>112</value>
|
<value>112</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="GridCompleted.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="GridCompleted.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>1086, 413</value>
|
<value>1086, 415</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="GridCompleted.TabIndex" type="System.Int32, mscorlib">
|
<data name="GridCompleted.TabIndex" type="System.Int32, mscorlib">
|
||||||
<value>3</value>
|
<value>3</value>
|
||||||
@ -454,7 +454,7 @@
|
|||||||
<value>0</value>
|
<value>0</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="XtraTabPage2.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="XtraTabPage2.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>1086, 413</value>
|
<value>1086, 415</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="XtraTabPage2.Text" xml:space="preserve">
|
<data name="XtraTabPage2.Text" xml:space="preserve">
|
||||||
<value>Abgeschlossene Umschläge</value>
|
<value>Abgeschlossene Umschläge</value>
|
||||||
@ -514,7 +514,7 @@
|
|||||||
<value>1</value>
|
<value>1</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SplitContainerControl1.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="SplitContainerControl1.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>1088, 499</value>
|
<value>1088, 501</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SplitContainerControl1.TabIndex" type="System.Int32, mscorlib">
|
<data name="SplitContainerControl1.TabIndex" type="System.Int32, mscorlib">
|
||||||
<value>5</value>
|
<value>5</value>
|
||||||
|
|||||||
@ -9,10 +9,10 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
private readonly EnvelopeService envelopeService;
|
private readonly EnvelopeService envelopeService;
|
||||||
private readonly EmailService emailService;
|
private readonly EmailService emailService;
|
||||||
|
|
||||||
public EnvelopeController(DatabaseService database, LoggingService logging, EnvelopeService envelope, EmailService email) : base(database, logging)
|
public EnvelopeController(DatabaseService database, LoggingService logging, EnvelopeService envelope) : base(database, logging)
|
||||||
{
|
{
|
||||||
envelopeService = envelope;
|
envelopeService = envelope;
|
||||||
emailService = email;
|
emailService = new(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -62,7 +62,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
|
|
||||||
envelopeService.InsertHistoryEntrySigned(response);
|
envelopeService.InsertHistoryEntrySigned(response);
|
||||||
|
|
||||||
SendSignedEmail(response);
|
emailService.SendSignedEmail(response.Receiver.Id, response.Envelope.Id);
|
||||||
|
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
@ -71,18 +71,5 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
return ErrorResponse(e);
|
return ErrorResponse(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SendSignedEmail(EnvelopeResponse response)
|
|
||||||
{
|
|
||||||
EmailTemplate template = new();
|
|
||||||
EmailData emailData = new(response.Envelope, response.Receiver)
|
|
||||||
{
|
|
||||||
SignatureLink = "",
|
|
||||||
};
|
|
||||||
|
|
||||||
template.FillDocumentSignedEmailBody(emailData);
|
|
||||||
|
|
||||||
return emailService.SendEmail(emailData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,11 +5,6 @@ using static EnvelopeGenerator.Common.Constants;
|
|||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers
|
namespace EnvelopeGenerator.Web.Controllers
|
||||||
{
|
{
|
||||||
public class ActionObject
|
|
||||||
{
|
|
||||||
public int ActionType { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class HistoryController : BaseController
|
public class HistoryController : BaseController
|
||||||
{
|
{
|
||||||
private readonly EnvelopeService envelopeService;
|
private readonly EnvelopeService envelopeService;
|
||||||
@ -21,7 +16,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("api/history/{envelopeKey}")]
|
[Route("api/history/{envelopeKey}")]
|
||||||
public IActionResult Get(string envelopeKey, [FromBody] ActionObject action)
|
public IActionResult Get(string envelopeKey)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -30,12 +25,11 @@ namespace EnvelopeGenerator.Web.Controllers
|
|||||||
// Validate Envelope Key and load envelope
|
// Validate Envelope Key and load envelope
|
||||||
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
|
||||||
EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey);
|
EnvelopeResponse response = envelopeService.LoadEnvelope(envelopeKey);
|
||||||
EnvelopeHistoryActionType actionType = (EnvelopeHistoryActionType)action.ActionType;
|
|
||||||
|
|
||||||
envelopeService.InsertHistoryEntry(new EnvelopeHistoryEntry()
|
envelopeService.InsertHistoryEntry(new EnvelopeHistoryEntry()
|
||||||
{
|
{
|
||||||
ActionDate = DateTime.Now,
|
ActionDate = DateTime.Now,
|
||||||
ActionType = actionType,
|
Status = EnvelopeStatus.DocumentOpened,
|
||||||
EnvelopeId = response.Envelope.Id,
|
EnvelopeId = response.Envelope.Id,
|
||||||
UserReference = response.Receiver.Email
|
UserReference = response.Receiver.Email
|
||||||
});
|
});
|
||||||
|
|||||||
@ -11,7 +11,6 @@ namespace EnvelopeGenerator.Web
|
|||||||
// Add base services
|
// Add base services
|
||||||
builder.Services.AddSingleton<LoggingService>();
|
builder.Services.AddSingleton<LoggingService>();
|
||||||
builder.Services.AddTransient<DatabaseService>();
|
builder.Services.AddTransient<DatabaseService>();
|
||||||
builder.Services.AddTransient<EmailService>();
|
|
||||||
|
|
||||||
// Add higher order services
|
// Add higher order services
|
||||||
builder.Services.AddSingleton<EnvelopeService>();
|
builder.Services.AddSingleton<EnvelopeService>();
|
||||||
|
|||||||
@ -1,38 +0,0 @@
|
|||||||
using EnvelopeGenerator.Common;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Services
|
|
||||||
{
|
|
||||||
public class EmailService : BaseService
|
|
||||||
{
|
|
||||||
private ReceiverModel receiverModel;
|
|
||||||
private EnvelopeModel envelopeModel;
|
|
||||||
private HistoryModel historyModel;
|
|
||||||
private DocumentModel documentModel;
|
|
||||||
private DocumentStatusModel documentStatusModel;
|
|
||||||
private EmailModel emailModel;
|
|
||||||
|
|
||||||
public EmailService(IConfiguration Config, LoggingService Logging, DatabaseService database) : base(Config, Logging)
|
|
||||||
{
|
|
||||||
logger = Logging.LogConfig.GetLogger();
|
|
||||||
|
|
||||||
if (database.Models == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("Models not loaded.");
|
|
||||||
}
|
|
||||||
|
|
||||||
receiverModel = database.Models.receiverModel;
|
|
||||||
envelopeModel = database.Models.envelopeModel;
|
|
||||||
historyModel = database.Models.historyModel;
|
|
||||||
documentModel = database.Models.documentModel;
|
|
||||||
documentStatusModel = database.Models.documentStatusModel;
|
|
||||||
emailModel = database.Models.emailModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SendEmail(EmailData emailData)
|
|
||||||
{
|
|
||||||
return emailModel.Insert(emailData);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -111,7 +111,7 @@ namespace EnvelopeGenerator.Web.Services
|
|||||||
return historyModel.Insert(new EnvelopeHistoryEntry()
|
return historyModel.Insert(new EnvelopeHistoryEntry()
|
||||||
{
|
{
|
||||||
ActionDate = DateTime.Now,
|
ActionDate = DateTime.Now,
|
||||||
ActionType = EnvelopeHistoryActionType.Signed,
|
Status = EnvelopeStatus.DocumentSigned,
|
||||||
EnvelopeId = response.Envelope.Id,
|
EnvelopeId = response.Envelope.Id,
|
||||||
UserReference = response.Receiver.Email
|
UserReference = response.Receiver.Email
|
||||||
});
|
});
|
||||||
|
|||||||
@ -90,7 +90,7 @@ class App {
|
|||||||
)
|
)
|
||||||
const createdAnnotations = await this.Instance.create(annotations)
|
const createdAnnotations = await this.Instance.create(annotations)
|
||||||
|
|
||||||
await this.Network.postHistory(this.envelopeKey, ActionType.Seen)
|
await this.Network.postHistory(this.envelopeKey)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,20 +32,16 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
postHistory(envelopeKey, actionType) {
|
postHistory(envelopeKey) {
|
||||||
const url = `/api/history/${envelopeKey}`
|
const url = `/api/history/${envelopeKey}`
|
||||||
|
|
||||||
const data = {
|
|
||||||
actionType: actionType,
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json; charset=utf-8',
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
},
|
},
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify({}),
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug('PostHistory/Calling url: ' + url)
|
console.debug('PostHistory/Calling url: ' + url)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user