This commit is contained in:
2020-07-16 15:39:59 +00:00
parent b8db90d65c
commit 12ccca9bd0
2 changed files with 60 additions and 1 deletions

View File

@@ -17,6 +17,65 @@ namespace AyaNova.Biz
//This class handles word breaking, processing keywords and searching for results
public static class NotifyEventProcessor
{
private static ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("NotifyEventProcessor");
//Add operations message
public static async Task AddOpsProblemEvent(string message, Exception ex = null)
{
if (string.IsNullOrWhiteSpace(message) && ex == null)
return;
//Log as a backup in case there is no one to notify and also for the record and support
if (ex != null)
{
log.LogError(ex, $"Ops problem notification: \"{message}\"");
message += $"\nException error: {ExceptionUtil.ExtractAllExceptionMessages(ex)}";
}
else
log.LogWarning($"Ops problem notification: \"{message}\"");
await AddEvent(new NotifyEvent() { EventType = NotifyEventType.ServerOperationsProblem, Message = message });
}
public static async Task AddEvent(NotifyEvent ev)
{
//iterate subs, figure out who gets this event
//add to table for any that do
try
{
log.LogTrace("Notify set to RUNNING state and starting now");
using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext)
{
//select all jobs with no deliver date or deliver date no longer in future
//### PLAN if it's an smtp delivery that fails and it's to someone who can be delivered in app then it should send an inapp notification of
//delivery failure and still delete the smtp delivery
//If it's not possible to notify the person via in app of the failed smtp then perhaps it notifies OPS personnel and biz admin personnel
//NEW NOTIFICATION SUBSCRIPTION EVENT TYPE:
//OPERATIONS_PROBLEMS - backup, notifications, out of memory, what have you, anyone can subscribe to it regardless of rights
//this is just to let people know there is a problem
}
}
catch (Exception ex)
{
}
finally
{
log.LogTrace("Notify is done setting to not running state and tagging lastRun timestamp");
lastRun = DateTime.UtcNow;
NotifyIsRunning = false;
}
}
}//eoc

View File

@@ -21,7 +21,7 @@ namespace AyaNova.Models
[Required]
public NotifyEventType EventType { get; set; }
[Required]
public long SubscriptionId { get; set; }
public long SubscriptionId { get; set; }//source subscription that triggered this event to be created
public long? IdValue { get; set; }
public decimal? DecValue { get; set; }
public DateTime? EventDate { get; set; }//date of the event actually occuring, e.g. WarrantyExpiry date. Duped with delivery date as source of truth in case edit to advance setting in subscription changes delivery date