convert PlaceHolders-property to CreatePlaceHolders callback-method
This commit is contained in:
parent
95fe1aefcf
commit
9c48b230b4
@ -27,12 +27,26 @@ public class SendSignedMailHandler : SendMailHandler<DocSignedNotification>
|
||||
/// </summary>
|
||||
/// <param name="notification"></param>
|
||||
/// <param name="emailOut"></param>
|
||||
protected override void ConfigEmailOut(DocSignedNotification notification, EmailOut emailOut)
|
||||
protected override void ConfigureEmailOut(DocSignedNotification notification, EmailOut emailOut)
|
||||
{
|
||||
emailOut.ReferenceString = notification.EmailAddress;
|
||||
emailOut.ReferenceId = notification.ReceiverId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="notification"></param>
|
||||
/// <returns></returns>
|
||||
protected override Dictionary<string, string> CreatePlaceHolders(DocSignedNotification notification)
|
||||
{
|
||||
var placeHolders = new Dictionary<string, string>()
|
||||
{
|
||||
};
|
||||
|
||||
return placeHolders;
|
||||
}
|
||||
|
||||
private static string TextToHtml(string input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input)) return "";
|
||||
|
||||
@ -45,7 +45,7 @@ public abstract class SendMailHandler<TNotification> : INotificationHandler<TNot
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
protected virtual Dictionary<string, string> PlaceHolders { get; } = new();
|
||||
protected abstract Dictionary<string, string> CreatePlaceHolders(TNotification notification);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@ -62,7 +62,7 @@ public abstract class SendMailHandler<TNotification> : INotificationHandler<TNot
|
||||
/// </summary>
|
||||
/// <param name="notification"></param>
|
||||
/// <param name="emailOut"></param>
|
||||
protected abstract void ConfigEmailOut(TNotification notification, EmailOut emailOut);
|
||||
protected abstract void ConfigureEmailOut(TNotification notification, EmailOut emailOut);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@ -86,17 +86,18 @@ public abstract class SendMailHandler<TNotification> : INotificationHandler<TNot
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task Handle(TNotification notification, CancellationToken cancel)
|
||||
public virtual async Task Handle(TNotification notification, CancellationToken cancel)
|
||||
{
|
||||
var placeHolders = CreatePlaceHolders(notification);
|
||||
var temp = await TempRepo
|
||||
.ReadOnly()
|
||||
.SingleOrDefaultAsync(x => x.Name == notification.TemplateType.ToString(), cancel)
|
||||
?? throw new InvalidOperationException($"Receiver information is missing in the notification." +
|
||||
$"{typeof(TNotification)}:\n {JsonConvert.SerializeObject(notification, Format.Json.ForDiagnostics)}");
|
||||
|
||||
temp.Subject = ReplacePlaceHolders(temp.Subject, PlaceHolders, MailParams.Placeholders);
|
||||
temp.Subject = ReplacePlaceHolders(temp.Subject, placeHolders, MailParams.Placeholders);
|
||||
|
||||
temp.Body = ReplacePlaceHolders(temp.Body, PlaceHolders, MailParams.Placeholders);
|
||||
temp.Body = ReplacePlaceHolders(temp.Body, placeHolders, MailParams.Placeholders);
|
||||
|
||||
var emailOut = new EmailOut
|
||||
{
|
||||
@ -111,7 +112,7 @@ public abstract class SendMailHandler<TNotification> : INotificationHandler<TNot
|
||||
WfId = (int)EnvelopeStatus.MessageConfirmationSent,
|
||||
|
||||
};
|
||||
ConfigEmailOut(notification, emailOut);
|
||||
ConfigureEmailOut(notification, emailOut);
|
||||
await EmailOutRepo.CreateAsync(emailOut, cancel);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user