This commit is contained in:
@@ -34,22 +34,22 @@ namespace AyaNova.Biz
|
||||
//
|
||||
public static async Task DoWorkAsync()
|
||||
{
|
||||
log.LogTrace("Checking if Notify should run");
|
||||
log.LogDebug("Checking if Notify should run");
|
||||
if (NotifyIsRunning)
|
||||
{
|
||||
log.LogTrace("Notify is running already exiting this cycle");
|
||||
log.LogDebug("Notify is running already exiting this cycle");
|
||||
return;
|
||||
}
|
||||
//This will get triggered roughly every minute, but we don't want to deliver that frequently
|
||||
if (DateTime.UtcNow - lastRun < RUN_EVERY_INTERVAL)
|
||||
{
|
||||
log.LogTrace($"Notify ran less than {RUN_EVERY_INTERVAL} ago, exiting this cycle");
|
||||
log.LogDebug($"Notify ran less than {RUN_EVERY_INTERVAL} ago, exiting this cycle");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
NotifyIsRunning = true;
|
||||
log.LogTrace("Notify set to RUNNING state and starting now");
|
||||
log.LogDebug("Notify set to RUNNING state and starting now");
|
||||
|
||||
//NotifyHealthCheck processing
|
||||
//Note this deliberately uses LOCAL time in effort to deliver the health check first thing in the morning for workers
|
||||
@@ -60,7 +60,7 @@ namespace AyaNova.Biz
|
||||
//are we in the 7th to 9th hour?
|
||||
if (dtNowLocal.Hour > 6 && dtNowLocal.Hour < 10)
|
||||
{
|
||||
log.LogTrace("Notify health check submitted to subscribers");
|
||||
log.LogDebug("Notify health check submitted to subscribers");
|
||||
await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.NotifyHealthCheck, "OK", "");
|
||||
lastNotifyHealthCheckSentLocal = dtNowLocal;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ namespace AyaNova.Biz
|
||||
using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext)
|
||||
{
|
||||
var events = await ct.NotifyEvent.AsNoTracking().ToListAsync();
|
||||
log.LogTrace($"Found {events.Count} NotifyEvents to examine for potential delivery");
|
||||
log.LogDebug($"Found {events.Count} NotifyEvents to examine for potential delivery");
|
||||
|
||||
//iterate and deliver
|
||||
foreach (var notifyevent in events)
|
||||
@@ -78,7 +78,7 @@ namespace AyaNova.Biz
|
||||
var UserInfo = await ct.User.AsNoTracking().Where(x => x.Id == notifyevent.UserId).Select(x => new { Active = x.Active, Name = x.Name }).FirstOrDefaultAsync();
|
||||
if (!UserInfo.Active)
|
||||
{
|
||||
log.LogTrace($"Inactive user {UserInfo.Name}, removing notify rather than delivering it: {notifyevent}");
|
||||
log.LogDebug($"Inactive user {UserInfo.Name}, removing notify rather than delivering it: {notifyevent}");
|
||||
ct.NotifyEvent.Remove(notifyevent);
|
||||
await ct.SaveChangesAsync();
|
||||
continue;
|
||||
@@ -115,7 +115,7 @@ namespace AyaNova.Biz
|
||||
//look for same delivery less than last12hours ago
|
||||
if (await ct.NotifyDeliveryLog.AnyAsync(z => z.Processed > twelvehoursago && z.NotifySubscriptionId == notifyevent.NotifySubscriptionId && z.ObjectId == notifyevent.ObjectId))
|
||||
{
|
||||
log.LogTrace($"Notification event will not be delivered: repetitive (server system event type and delivered at least once in the last 12 hours to this subscriber: {notifyevent})");
|
||||
log.LogDebug($"Notification event will not be delivered: repetitive (server system event type and delivered at least once in the last 12 hours to this subscriber: {notifyevent})");
|
||||
ct.NotifyEvent.Remove(notifyevent);
|
||||
await ct.SaveChangesAsync();
|
||||
#if (DEBUG)
|
||||
@@ -142,7 +142,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
finally
|
||||
{
|
||||
log.LogTrace("Notify is done setting to not running state and tagging lastRun timestamp");
|
||||
log.LogDebug("Notify is done setting to not running state and tagging lastRun timestamp");
|
||||
lastRun = DateTime.UtcNow;
|
||||
NotifyIsRunning = false;
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace AyaNova.Biz
|
||||
|
||||
private static async Task DeliverInApp(NotifyEvent ne, TimeSpan ageValue, AyContext ct)
|
||||
{
|
||||
log.LogTrace($"DeliverInApp notify event: {ne}");
|
||||
log.LogDebug($"DeliverInApp notify event: {ne}");
|
||||
|
||||
//Place in the In-app notification table for user to view
|
||||
await ct.InAppNotification.AddAsync(
|
||||
@@ -195,7 +195,7 @@ namespace AyaNova.Biz
|
||||
|
||||
try
|
||||
{
|
||||
log.LogTrace($"DeliverSMTP delivering notify event: {ne}");
|
||||
log.LogDebug($"DeliverSMTP delivering notify event: {ne}");
|
||||
if (string.IsNullOrWhiteSpace(deliveryAddress))
|
||||
{
|
||||
await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"No email address is set in subscription to deliver email notification. This event will be removed from the delivery queue as undeliverable: {ne}", "Error", null, ne.UserId);
|
||||
@@ -314,7 +314,7 @@ namespace AyaNova.Biz
|
||||
await NotifyEventHelper.AddGeneralNotifyEvent(NotifyEventType.GeneralNotification, $"An error prevented delivering the following notification via email. System operator users have been notified:{ne}", "Error", null, ne.UserId);
|
||||
DeliveryLogItem.Fail = true;
|
||||
DeliveryLogItem.Error = $"SMTP Notification failed to deliver for this event: {ne}, message: {ex.Message}";
|
||||
log.LogTrace(ex, $"DeliverSMTP Failure delivering notify event: {ne}");
|
||||
log.LogDebug(ex, $"DeliverSMTP Failure delivering notify event: {ne}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user