configure attributes
This commit is contained in:
parent
9c48b230b4
commit
124523ad88
@ -34,7 +34,6 @@ public class SendSignedMailHandler : SendMailHandler<DocSignedNotification>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="notification"></param>
|
/// <param name="notification"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@ -42,26 +41,10 @@ public class SendSignedMailHandler : SendMailHandler<DocSignedNotification>
|
|||||||
{
|
{
|
||||||
var placeHolders = new Dictionary<string, string>()
|
var placeHolders = new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
|
{ "[NAME_RECEIVER]", notification.Name ?? string.Empty },
|
||||||
|
{ "[DOCUMENT_TITLE]", notification.Envelope?.Title ?? string.Empty },
|
||||||
};
|
};
|
||||||
|
|
||||||
return placeHolders;
|
return placeHolders;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string TextToHtml(string input)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(input)) return "";
|
|
||||||
|
|
||||||
// HTML encoding special characters
|
|
||||||
string encoded = System.Net.WebUtility.HtmlEncode(input);
|
|
||||||
|
|
||||||
// Convert tabs to (4 non-breaking spaces)
|
|
||||||
encoded = encoded.Replace("\t", " ");
|
|
||||||
|
|
||||||
// Convert line breaks to <br />
|
|
||||||
encoded = encoded.Replace("\r\n", "<br />"); // Windows
|
|
||||||
encoded = encoded.Replace("\r", "<br />"); // Mac old
|
|
||||||
encoded = encoded.Replace("\n", "<br />"); // Unix/Linux
|
|
||||||
|
|
||||||
return encoded;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -48,7 +48,14 @@ public abstract class SendMailHandler<TNotification> : INotificationHandler<TNot
|
|||||||
protected abstract Dictionary<string, string> CreatePlaceHolders(TNotification notification);
|
protected abstract Dictionary<string, string> CreatePlaceHolders(TNotification notification);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///{ "[MESSAGE]", notification.Message },<br/>
|
||||||
|
///{ "[DOCUMENT_ACCESS_CODE]", notification.ReceiverAccessCode },<br/>
|
||||||
|
///{ "[REASON]", pReason }<br/>
|
||||||
|
///{ "[NAME_SENDER]", notification.Envelope.User?.FullName},<br/>
|
||||||
|
///{ "[NAME_PORTAL]", DispatcherParams. },<br/>
|
||||||
|
///{ "[SIGNATURE_TYPE]", "signieren" },<br/>
|
||||||
|
///{ "[LINK_TO_DOCUMENT]", notification.SignatureLink },<br/>
|
||||||
|
///{ "[LINK_TO_DOCUMENT_TEXT]", $"{notification.SignatureLink.Truncate(40)}.." },
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly MailParams MailParams;
|
protected readonly MailParams MailParams;
|
||||||
|
|
||||||
@ -89,6 +96,7 @@ public abstract class SendMailHandler<TNotification> : INotificationHandler<TNot
|
|||||||
public virtual async Task Handle(TNotification notification, CancellationToken cancel)
|
public virtual async Task Handle(TNotification notification, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
var placeHolders = CreatePlaceHolders(notification);
|
var placeHolders = CreatePlaceHolders(notification);
|
||||||
|
|
||||||
var temp = await TempRepo
|
var temp = await TempRepo
|
||||||
.ReadOnly()
|
.ReadOnly()
|
||||||
.SingleOrDefaultAsync(x => x.Name == notification.TemplateType.ToString(), cancel)
|
.SingleOrDefaultAsync(x => x.Name == notification.TemplateType.ToString(), cancel)
|
||||||
@ -102,7 +110,7 @@ public abstract class SendMailHandler<TNotification> : INotificationHandler<TNot
|
|||||||
var emailOut = new EmailOut
|
var emailOut = new EmailOut
|
||||||
{
|
{
|
||||||
EmailAddress = notification.EmailAddress,
|
EmailAddress = notification.EmailAddress,
|
||||||
EmailBody = temp.Body,
|
EmailBody = TextToHtml(temp.Body),
|
||||||
EmailSubj = temp.Subject,
|
EmailSubj = temp.Subject,
|
||||||
AddedWhen = DateTime.UtcNow,
|
AddedWhen = DateTime.UtcNow,
|
||||||
AddedWho = DispatcherParams.AddedWho,
|
AddedWho = DispatcherParams.AddedWho,
|
||||||
@ -123,4 +131,22 @@ public abstract class SendMailHandler<TNotification> : INotificationHandler<TNot
|
|||||||
text = text.Replace(ph.Key, ph.Value);
|
text = text.Replace(ph.Key, ph.Value);
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private static string TextToHtml(string input)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(input)) return "";
|
||||||
|
|
||||||
|
// HTML encoding special characters
|
||||||
|
string encoded = System.Net.WebUtility.HtmlEncode(input);
|
||||||
|
|
||||||
|
// Convert tabs to (4 non-breaking spaces)
|
||||||
|
encoded = encoded.Replace("\t", " ");
|
||||||
|
|
||||||
|
// Convert line breaks to <br />
|
||||||
|
encoded = encoded.Replace("\r\n", "<br />"); // Windows
|
||||||
|
encoded = encoded.Replace("\r", "<br />"); // Mac old
|
||||||
|
encoded = encoded.Replace("\n", "<br />"); // Unix/Linux
|
||||||
|
|
||||||
|
return encoded;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user