2023-09-20
This commit is contained in:
parent
12556e41e4
commit
510813b06a
@ -1,4 +1,5 @@
|
||||
Public Class DbConfig
|
||||
Public Property DocumentPath As String = ""
|
||||
Public Property SendingProfile As Integer = 0
|
||||
Public Property SignatureHost As String = ""
|
||||
End Class
|
||||
|
||||
@ -2,6 +2,13 @@
|
||||
Public Property EmailAdress As String
|
||||
Public Property EmailSubject As String
|
||||
Public Property EmailBody As String
|
||||
|
||||
Public Property ReferenceID As Integer
|
||||
|
||||
|
||||
Public Property ReceiverName As String
|
||||
Public Property SenderName As String
|
||||
Public Property SenderAdress As String
|
||||
Public Property SignatureLink As String
|
||||
Public Property Message As String
|
||||
|
||||
End Class
|
||||
|
||||
59
EnvelopeGenerator.Common/Entities/EmailTemplate.vb
Normal file
59
EnvelopeGenerator.Common/Entities/EmailTemplate.vb
Normal file
@ -0,0 +1,59 @@
|
||||
Public Class EmailTemplate
|
||||
Inherits BaseModel
|
||||
|
||||
Private _firstBodyTemplate As List(Of String)
|
||||
|
||||
Private _replaceDictionary As Dictionary(Of String, String)
|
||||
|
||||
Public Sub New(pState As State)
|
||||
MyBase.New(pState)
|
||||
|
||||
InitTemplate()
|
||||
End Sub
|
||||
|
||||
Private Sub InitTemplate()
|
||||
_firstBodyTemplate = New List(Of String) From {
|
||||
"Guten Tag, <NAME_RECEIVER>,",
|
||||
"",
|
||||
"<NAME_SENDER> hat Ihnen ein Dokument zum <SIGNATURE_TYPE> gesendet.",
|
||||
"",
|
||||
"Über den folgenden Link können Sie das Dokument einsehen: <LINK_TO_DOCUMENT>",
|
||||
"",
|
||||
"<MESSAGE>",
|
||||
"",
|
||||
"Mit freundlichen Grüßen",
|
||||
"<NAME_SENDER>"
|
||||
}
|
||||
End Sub
|
||||
|
||||
Private Sub InitDictionary(pEmailData As EmailData)
|
||||
_replaceDictionary = New Dictionary(Of String, String) From {
|
||||
{"<NAME_RECEIVER>", pEmailData.ReceiverName},
|
||||
{"<NAME_SENDER>", pEmailData.SenderName},
|
||||
{"<SIGNATURE_TYPE>", ""},
|
||||
{"<LINK_TO_DOCUMENT>", pEmailData.SignatureLink},
|
||||
{"<MESSAGE>", pEmailData.Message}
|
||||
}
|
||||
End Sub
|
||||
|
||||
Public Sub SetEmailBody(pEmailData As EmailData)
|
||||
|
||||
InitDictionary(pEmailData)
|
||||
|
||||
Dim resultBody As String = ""
|
||||
|
||||
For Each lineItem As String In _firstBodyTemplate
|
||||
Dim oLineValue As String = lineItem
|
||||
For Each dictItem As KeyValuePair(Of String, String) In _replaceDictionary
|
||||
If oLineValue.Contains(dictItem.Key) Then
|
||||
oLineValue = oLineValue.Replace(dictItem.Key, dictItem.Value)
|
||||
|
||||
End If
|
||||
Next
|
||||
resultBody += oLineValue + "<br/>"
|
||||
Next
|
||||
|
||||
pEmailData.EmailBody = resultBody
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
@ -6,4 +6,9 @@
|
||||
Public Property Email As String
|
||||
Public Property Language As String
|
||||
|
||||
Public ReadOnly Property FullName() As String
|
||||
Get
|
||||
Return Prename + " " + Name
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
|
||||
@ -96,6 +96,7 @@
|
||||
<Compile Include="DbConfig.vb" />
|
||||
<Compile Include="Entities\ElementMetadata.vb" />
|
||||
<Compile Include="Entities\EmailData.vb" />
|
||||
<Compile Include="Entities\EmailTemplate.vb" />
|
||||
<Compile Include="Entities\Envelope.vb" />
|
||||
<Compile Include="Entities\EnvelopeDocument.vb" />
|
||||
<Compile Include="Entities\EnvelopeDocumentElement.vb" />
|
||||
|
||||
@ -10,4 +10,14 @@
|
||||
'TODO: Entschlüsseln
|
||||
Return New Tuple(Of String, String)(oSplit(0), oSplit(1))
|
||||
End Function
|
||||
|
||||
Public Shared Function GetEnvelopeURL(pHost As String, pEnvelopeUuid As String, pReceiverSignature As String) As String
|
||||
|
||||
Dim oEnvelopeUserReference As String = EncodeEnvelopeReceiverId(pEnvelopeUuid, pReceiverSignature)
|
||||
|
||||
Dim oURL As String = ""
|
||||
oURL = String.Format("{0}/EnvelopeKey/{1}", pHost.Trim(), oEnvelopeUserReference)
|
||||
Return oURL
|
||||
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports System.Data
|
||||
|
||||
Public MustInherit Class BaseModel
|
||||
Protected Database As MSSQLServer
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Transactions
|
||||
Imports System.Data.SqlClient
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports EnvelopeGenerator.Common.My.Resources
|
||||
|
||||
Public Class DocumentModel
|
||||
Inherits BaseModel
|
||||
|
||||
@ -5,8 +5,12 @@ Imports DigitalData.Modules.Logging
|
||||
Public Class EnvelopeModel
|
||||
Inherits BaseModel
|
||||
|
||||
Private UserModel As UserModel
|
||||
|
||||
Public Sub New(pState As State)
|
||||
MyBase.New(pState)
|
||||
|
||||
UserModel = New UserModel(pState)
|
||||
End Sub
|
||||
|
||||
Private Function ToEnvelope(pRow As DataRow) As Envelope
|
||||
@ -17,12 +21,14 @@ Public Class EnvelopeModel
|
||||
.Uuid = pRow.ItemEx("ENVELOPE_UUID", ""),
|
||||
.Subject = pRow.ItemEx("SUBJECT", ""),
|
||||
.Message = pRow.ItemEx("MESSAGE", ""),
|
||||
.UserId = State.UserId,
|
||||
.UserId = pRow.ItemEx("USER_ID", 0),
|
||||
.Status = ObjectEx.ToEnum(Of Constants.EnvelopeStatus)(pRow.ItemEx("STATUS", "Created")),
|
||||
.AddedWhen = pRow.Item("ADDED_WHEN"),
|
||||
.User = New User()
|
||||
}
|
||||
|
||||
oEnvelope.User = UserModel.SelectUser(oEnvelope.UserId)
|
||||
|
||||
Return oEnvelope
|
||||
End Function
|
||||
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
Imports System.Data.SqlClient
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports EnvelopeGenerator.Common.My.Resources
|
||||
|
||||
Public Class UserModel
|
||||
Inherits BaseModel
|
||||
@ -36,4 +34,17 @@ Public Class UserModel
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function SelectUser(pUserID As Integer) As User
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [dbo].[TBDD_USER] WHERE GUID = {pUserID}"
|
||||
Dim oTable = Database.GetDatatable(oSql)
|
||||
|
||||
Return oTable?.Rows.Cast(Of DataRow).
|
||||
Select(AddressOf ToUser).First
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
@ -35,17 +35,23 @@ Public Class EnvelopeEditorController
|
||||
|
||||
For Each receiverItem As EnvelopeReceiver In Envelope.Receivers
|
||||
|
||||
' TODO Email-Template füllen
|
||||
Dim oEmailBody As String = String.Empty
|
||||
|
||||
Dim oEmailData As EmailData = New EmailData With
|
||||
{
|
||||
.EmailAdress = receiverItem.Email,
|
||||
.EmailSubject = Envelope.Subject,
|
||||
.EmailBody = oEmailBody,
|
||||
.ReferenceID = Envelope.Id
|
||||
.Message = Envelope.Message,
|
||||
.ReferenceID = Envelope.Id,
|
||||
.ReceiverName = receiverItem.Name,
|
||||
.SenderAdress = Envelope.User.Email,
|
||||
.SenderName = Envelope.User.FullName,
|
||||
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, Envelope.Uuid, receiverItem.Signature)
|
||||
}
|
||||
|
||||
' TODO Email-Template füllen
|
||||
Dim oTemplate As EmailTemplate = New EmailTemplate(State)
|
||||
oTemplate.SetEmailBody(oEmailData)
|
||||
|
||||
|
||||
If EmailModel.Insert(oEmailData) = False Then
|
||||
Logger.Error("EMail data could not be inserted.")
|
||||
oResult = False
|
||||
|
||||
@ -72,7 +72,8 @@ Public Class frmMain
|
||||
|
||||
Return New DbConfig() With {
|
||||
.DocumentPath = oRow.ItemEx("DOCUMENT_PATH", ""),
|
||||
.SendingProfile = oRow.ItemEx("SENDING_PROFILE", 0)
|
||||
.SendingProfile = oRow.ItemEx("SENDING_PROFILE", 0),
|
||||
.SignatureHost = oRow.ItemEx("SIGNATURE_HOST", "")
|
||||
}
|
||||
Catch ex As Exception
|
||||
Return New DbConfig()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user