This commit is contained in:
@@ -1288,6 +1288,8 @@ namespace AyaNova.Biz
|
||||
//note order by id ascending so that only the oldest notification "wins" as per docs in case of overlap to same customer
|
||||
var subs = await ct.CustomerNotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.QuoteStatusChange && z.IdValue == oProposed.QuoteStatusId).OrderBy(z => z.Id).ToListAsync();
|
||||
|
||||
|
||||
|
||||
foreach (var sub in subs)
|
||||
{
|
||||
//Object tags must match and Customer tags must match
|
||||
|
||||
@@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
|
||||
using AyaNova.Models;
|
||||
using AyaNova.Util;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace AyaNova.Biz
|
||||
{
|
||||
@@ -133,7 +134,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
else
|
||||
{
|
||||
IMailer m = AyaNova.Util.ServiceProviderProvider.Mailer;
|
||||
|
||||
if (!ServerGlobalOpsSettingsCache.Notify.SmtpDeliveryActive)
|
||||
{
|
||||
await NotifyEventHelper.AddOpsProblemEvent($"Email notifications are set to OFF at server, unable to send Customer email notification for this event:{ne}");
|
||||
@@ -143,8 +144,76 @@ namespace AyaNova.Biz
|
||||
}
|
||||
else
|
||||
{
|
||||
//generate report if applicable
|
||||
|
||||
//BUILD SUBJECT AND BODY FROM TOKENS IF REQUIRED
|
||||
var Subject = subscription.Subject;
|
||||
var Body = subscription.Template;
|
||||
|
||||
if (Subject.Contains("{{") || Body.Contains("{{"))
|
||||
{
|
||||
|
||||
//fetch the object with viz fields for easy templatization
|
||||
switch (ne.AyaType)
|
||||
{
|
||||
case AyaType.Quote:
|
||||
{
|
||||
var qb = QuoteBiz.GetBiz(ct);
|
||||
await qb.QuoteGetAsync(ne.ObjectId, true, false);
|
||||
todo figure this regex out, make it a function
|
||||
MatchCollection matches = Regex.Matches(Subject, @"\{{(.|\n)*?\}}", RegexOptions.IgnorePatternWhitespace
|
||||
| RegexOptions.Compiled);
|
||||
foreach (Match KeyMatch in matches)
|
||||
{
|
||||
switch (KeyMatch.Value)
|
||||
{
|
||||
case "[WorkorderService.Label.ServiceNumber]":
|
||||
sTemplate = sTemplate.Replace(KeyMatch.Value, wonumber);
|
||||
break;
|
||||
case "[O.WorkorderStatus]":
|
||||
if (statpick.Contains(WorkorderStatusID))
|
||||
sTemplate = sTemplate.Replace(KeyMatch.Value, statpick[WorkorderStatusID].Name);
|
||||
else
|
||||
sTemplate = sTemplate.Replace(KeyMatch.Value, "");
|
||||
break;
|
||||
case "[Workorder.Label.CustomerContactName]":
|
||||
sTemplate = sTemplate.Replace(KeyMatch.Value, contact);
|
||||
break;
|
||||
case "[Workorder.Label.CustomerReferenceNumber]":
|
||||
sTemplate = sTemplate.Replace(KeyMatch.Value, cref);
|
||||
break;
|
||||
case "[Region.Label.WBIUrl]":
|
||||
sTemplate = sTemplate.Replace(KeyMatch.Value, r.WBIUrl);
|
||||
break;
|
||||
case "[Client.Label.Name]":
|
||||
sTemplate = sTemplate.Replace(KeyMatch.Value, cl[0].LT_O_Client.Display);
|
||||
break;
|
||||
case "[ClientServiceRequest.Label.Details]":
|
||||
sTemplate = sTemplate.Replace(KeyMatch.Value, csrdetails);
|
||||
break;
|
||||
case "[Workorder.Label.Summary]":
|
||||
sTemplate = sTemplate.Replace(KeyMatch.Value, wosummary);
|
||||
break;
|
||||
case "[ClientServiceRequest.Label.Title]":
|
||||
sTemplate = sTemplate.Replace(KeyMatch.Value, csrtitle);
|
||||
break;
|
||||
//case 1499
|
||||
case "[WorkorderQuote.Label.QuoteNumber]":
|
||||
sTemplate = sTemplate.Replace(KeyMatch.Value, wonumber);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AyaType.WorkOrder:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
IMailer m = AyaNova.Util.ServiceProviderProvider.Mailer;
|
||||
//generate report if applicable
|
||||
if (subscription.LinkReportId != null)
|
||||
{
|
||||
long subTranslationId = (long)subscription.TranslationId;
|
||||
|
||||
Reference in New Issue
Block a user