diff --git a/EnvelopeGenerator.Application/Configurations/DispatcherParams.cs b/EnvelopeGenerator.Application/Configurations/DispatcherParams.cs
index 7570601c..2310151c 100644
--- a/EnvelopeGenerator.Application/Configurations/DispatcherParams.cs
+++ b/EnvelopeGenerator.Application/Configurations/DispatcherParams.cs
@@ -23,5 +23,5 @@ public class DispatcherParams
///
/// Default value is string.Empty
///
- public string EmailAttmt1 { get; init; } = string.Empty;
+ public string? EmailAttmt1 { get; init; } = null;
}
\ No newline at end of file
diff --git a/EnvelopeGenerator.Application/Notifications/SendMailHandler.cs b/EnvelopeGenerator.Application/Notifications/SendMailHandler.cs
index 03237f3c..331fcdbd 100644
--- a/EnvelopeGenerator.Application/Notifications/SendMailHandler.cs
+++ b/EnvelopeGenerator.Application/Notifications/SendMailHandler.cs
@@ -1,8 +1,11 @@
using DigitalData.Core.Abstraction.Application.Repository;
+using DigitalData.EmailProfilerDispatcher.Abstraction.Entities;
+using EnvelopeGenerator.Application.Configurations;
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Domain.Entities;
using MediatR;
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Options;
using Newtonsoft.Json;
namespace EnvelopeGenerator.Application.Notifications;
@@ -16,6 +19,11 @@ public interface ISendMailNotification : INotification
///
///
public EmailTemplateType TemplateType { get; }
+
+ ///
+ ///
+ ///
+ public string EmailAddress { get; }
}
///
@@ -29,23 +37,51 @@ public abstract class SendMailHandler : INotificationHandler
protected readonly IRepository TempRepo;
+ ///
+ ///
+ ///
+ protected readonly IRepository EmailOutRepo;
+
///
///
///
protected virtual Dictionary BodyPlaceHolders { get; } = new();
+ ///
+ ///
+ ///
+ protected readonly MailParams MailParams;
+
+ ///
+ ///
+ ///
+ protected readonly DispatcherParams DispatcherParams;
+
///
///
///
protected virtual Dictionary SubjectPlaceHolders { get; } = new();
+ ///
+ /// ReferenceString = Envelope.Uuid
+ ///
+ ///
+ ///
+ protected abstract void ConfigEmailOut(EmailOut emailOut);
+
///
///
///
///
- protected SendMailHandler(IRepository tempRepo)
+ ///
+ ///
+ ///
+ protected SendMailHandler(IRepository tempRepo, IRepository emailOutRepo, IOptions mailParamsOptions, IOptions dispatcherParamsOptions)
{
TempRepo = tempRepo;
+ EmailOutRepo = emailOutRepo;
+ MailParams = mailParamsOptions.Value;
+ DispatcherParams = dispatcherParamsOptions.Value;
}
///
@@ -63,15 +99,50 @@ public abstract class SendMailHandler : INotificationHandler placeHolders)
+ private static string ReplacePlaceHolders(string text, params Dictionary[] placeHoldersList)
{
- foreach (var ph in placeHolders)
- text = text.Replace(ph.Key, ph.Value);
+ foreach (var placeHolders in placeHoldersList)
+ foreach (var ph in placeHolders)
+ text = text.Replace(ph.Key, ph.Value);
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
+ encoded = encoded.Replace("\r\n", "
"); // Windows
+ encoded = encoded.Replace("\r", "
"); // Mac old
+ encoded = encoded.Replace("\n", "
"); // Unix/Linux
+
+ return encoded;
+ }
}
diff --git a/EnvelopeGenerator.Domain/Entities/EmailOut.cs b/EnvelopeGenerator.Domain/Entities/EmailOut.cs
index ecaff793..2e8b8770 100644
--- a/EnvelopeGenerator.Domain/Entities/EmailOut.cs
+++ b/EnvelopeGenerator.Domain/Entities/EmailOut.cs
@@ -2,17 +2,14 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#if NETFRAMEWORK
-using System.ComponentModel;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-
using System;
#endif
namespace EnvelopeGenerator.Domain.Entities
{
+ [Obsolete("Use EmailDispatcher.EmailOut")]
[Table("TBEMLP_EMAIL_OUT")]
- public class EmailOut
+ internal class EmailOut
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
diff --git a/EnvelopeGenerator.Infrastructure/DependencyExtensions.cs b/EnvelopeGenerator.Infrastructure/DependencyExtensions.cs
index ffaa1be9..c1f35007 100644
--- a/EnvelopeGenerator.Infrastructure/DependencyExtensions.cs
+++ b/EnvelopeGenerator.Infrastructure/DependencyExtensions.cs
@@ -13,6 +13,7 @@ using Dapper;
using System.ComponentModel.DataAnnotations.Schema;
using System.Reflection;
using DigitalData.UserManager.Domain.Entities;
+using DigitalData.EmailProfilerDispatcher.Abstraction.Entities;
namespace EnvelopeGenerator.Infrastructure;
@@ -60,6 +61,7 @@ public static class DIExtensions
services.AddDbRepository(context => context.EnvelopeDocument).UseAutoMapper();
services.AddDbRepository(context => context.DocumentStatus).UseAutoMapper();
services.AddDbRepository(context => context.EmailTemplate).UseAutoMapper();
+ services.AddDbRepository(context => context.EMailOuts).UseAutoMapper();
services.AddDbRepository(context => context.Envelopes).UseAutoMapper();
services.AddDbRepository(context => context.EnvelopeHistories).UseAutoMapper();
services.AddDbRepository(context => context.EnvelopeReceivers).UseAutoMapper();
diff --git a/EnvelopeGenerator.Web/appsettings.json b/EnvelopeGenerator.Web/appsettings.json
index 6c26db74..ec350f00 100644
--- a/EnvelopeGenerator.Web/appsettings.json
+++ b/EnvelopeGenerator.Web/appsettings.json
@@ -132,7 +132,7 @@
"SendingProfile": 1,
"AddedWho": "DDEnvelopGenerator",
"ReminderTypeId": 202377,
- "EmailAttmt1": ""
+ "EmailAttmt1": null
},
"MailParams": {
"Placeholders": {