Files
EnvelopeGenerator/EnvelopeGenerator.CommonServices/Models/EmailData.vb
OlgunR 92d88812e8 Add SignatureLinkText to EmailData and template support
Introduced SignatureLinkText property in EmailData to hold signature-related text, set dynamically based on envelope type. Updated constructor to HTML-encode SignatureLinkText. Added [SIGNATURE_LINK_TEXT] to template dictionary in TemplateService for email customization.
2026-03-03 12:44:54 +01:00

112 lines
4.2 KiB
VB.net

Imports EnvelopeGenerator.Domain
Imports EnvelopeGenerator.Domain.Entities
Public Class EmailData
Public Property EmailAdress As String = ""
Public Property EmailSubject As String = ""
Public Property EmailBody As String = ""
Public Property EmailType As Constants.EnvelopeStatus = Constants.EnvelopeStatus.Invalid
Public Property ReferenceID As Integer = 0
Public Property ReferenceString As String = ""
Public Property ReceiverAccessCode As String = ""
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 = ""
Public Property EnvelopeTitle As String = ""
Public Property EmailAttachment As String = ""
Public Property ATT1_RELATED_ID As Long
Public Property ATT1_REL_TYPE As String = ""
Public Property ADDED_WHO_PROCESS As String = "DDEnvelopGenerator"
Public ReadOnly Property EnvelopeTypeId As Integer = 0
Public Property SignatureType As String = ""
Public Property SignatureLinkText As String = ""
Public Sub DynamicStringsForEmails(pEnvelope As Entities.Envelope)
If pEnvelope.EnvelopeTypeId = 1 Then
SignatureType = "Signieren"
Message = "Bitte lesen und unterzeichnen Sie dieses Dokument."
SignatureLinkText = " und elektronisch unterschreiben"
ElseIf pEnvelope.EnvelopeTypeId = 2 Then
SignatureType = "Lesen und bestätigen"
Message = "Bitte lesen und bestätigen Sie, dieses Dokument gelesen zu haben."
SignatureLinkText = ""
End If
End Sub
''' <summary>
''' Constructor for sending email to receiver
''' </summary>
''' <param name="pEnvelope"></param>
''' <param name="pReceiver"></param>
''' <param name="pStatus"></param>
Public Sub New(pEnvelope As Entities.Envelope, pReceiver As Receiver, pStatus As Constants.EnvelopeStatus)
DynamicStringsForEmails(pEnvelope)
EmailAdress = pReceiver.EmailAddress
EmailSubject = String.Empty
EmailType = pStatus
Message = TextToHtml(Message)
ReferenceID = pEnvelope.Id
ReferenceString = pEnvelope.Uuid
ReceiverName = pReceiver.Name
ReceiverAccessCode = pReceiver.AccessCode
SenderAdress = pEnvelope.User.Email
SenderName = pEnvelope.User.GetFullName()
EnvelopeTitle = pEnvelope.Title
EnvelopeTypeId = pEnvelope.EnvelopeTypeId
SignatureType = TextToHtml(SignatureType)
SignatureLinkText = TextToHtml(SignatureLinkText)
End Sub
Public Function TextToHtml(input As String) As String
If String.IsNullOrEmpty(input) Then Return ""
' HTML-Encodierung der Sonderzeichen
Dim encoded As String = System.Net.WebUtility.HtmlEncode(input)
' Tabs in &nbsp; umwandeln (z.B. 4 non-breaking spaces)
encoded = encoded.Replace(vbTab, "&nbsp;&nbsp;&nbsp;&nbsp;")
' Zeilenumbrüche in <br /> umwandeln
encoded = encoded.Replace(vbCrLf, "<br />") ' Windows
encoded = encoded.Replace(vbCr, "<br />") ' Mac alt
encoded = encoded.Replace(vbLf, "<br />") ' Unix/Linux
Return encoded
End Function
''' <summary>
''' Constructor for sending email to creator
''' </summary>
''' <param name="pEnvelope"></param>
''' <param name="pStatus"></param>
Public Sub New(pEnvelope As Entities.Envelope, pStatus As Constants.EnvelopeStatus)
DynamicStringsForEmails(pEnvelope)
EmailAdress = pEnvelope.User.Email
EmailSubject = String.Empty
EmailType = pStatus
Message = TextToHtml(Message)
ReferenceID = pEnvelope.Id
ReferenceString = pEnvelope.Uuid
ReceiverName = pEnvelope.User.GetFullName()
ReceiverAccessCode = String.Empty
SenderAdress = pEnvelope.User.Email
SenderName = pEnvelope.User.GetFullName()
EnvelopeTitle = pEnvelope.Title
EnvelopeTypeId = pEnvelope.EnvelopeTypeId
SignatureType = TextToHtml(SignatureType)
SignatureLinkText = TextToHtml(SignatureLinkText)
End Sub
End Class