From a666eb88131f5b43eda77936da1ac3aad0904e4c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 17 Jul 2020 17:39:59 +0000 Subject: [PATCH] --- server/AyaNova/biz/NotifyEventProcessor.cs | 2 +- server/AyaNova/biz/NotifyEventType.cs | 2 +- server/AyaNova/generator/CoreJobNotify.cs | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/server/AyaNova/biz/NotifyEventProcessor.cs b/server/AyaNova/biz/NotifyEventProcessor.cs index 850ccad8..2d80b26d 100644 --- a/server/AyaNova/biz/NotifyEventProcessor.cs +++ b/server/AyaNova/biz/NotifyEventProcessor.cs @@ -49,7 +49,7 @@ namespace AyaNova.Biz { case NotifyEventType.BackupStatus: case NotifyEventType.DefaultNotification: - case NotifyEventType.NotifyHealthCheck: + case NotifyEventType.NotifyHealthCheck://created by job processor itself case NotifyEventType.ServerOperationsProblem: break; default://this will likely be a development error, not a production error so no need to log etc diff --git a/server/AyaNova/biz/NotifyEventType.cs b/server/AyaNova/biz/NotifyEventType.cs index 87ec27a7..5f660dda 100644 --- a/server/AyaNova/biz/NotifyEventType.cs +++ b/server/AyaNova/biz/NotifyEventType.cs @@ -28,7 +28,7 @@ namespace AyaNova.Biz OutsideServiceOverdue = 16,//Workorder object , WorkorderItemOutsideService created / updated, sets advance notice on due date tag filterable OutsideServiceReceived = 17,//Workorder object , WorkorderItemOutsideService updated, instant notification when item received, tag filterable PartRequestReceived = 18,//Workorder object / workorderitempartrequest updated, sent to person who requested when parts received back - NotifyHealthCheck = 19,//NO OBJECT, direct subscription to receive recurring daily notify system "ping" sent out at fixed time of 9am every day server local time + NotifyHealthCheck = 19,//NO OBJECT, direct subscription to receive recurring daily notify system "ping" sent out between 8am and 10am once every 24 hours minimum every day server local time BackupStatus = 20,//NO OBJECT, direct subscription to receive results of last backup operation CustomerServiceImminent = 21,//Workorder / WorkorderItemScheduledUser object, notice that scheduled service is due, can set advance notice, CUSTOMER gets delivery PartRequested = 22,//Workorder object / workorderitempartrequest created tag filterable diff --git a/server/AyaNova/generator/CoreJobNotify.cs b/server/AyaNova/generator/CoreJobNotify.cs index 0e487b1b..7cce20df 100644 --- a/server/AyaNova/generator/CoreJobNotify.cs +++ b/server/AyaNova/generator/CoreJobNotify.cs @@ -18,6 +18,9 @@ namespace AyaNova.Biz private static DateTime lastRun = DateTime.MinValue; private static TimeSpan DELETE_AFTER_AGE = new TimeSpan(90, 0, 0, 0); private static TimeSpan RUN_EVERY_INTERVAL = new TimeSpan(0, 2, 0);//once every 2 minutes minimum + private static DateTime lastNotifyHealthCheckSentLocal = DateTime.MinValue; + private static TimeSpan TS_24_HOURS = new TimeSpan(24, 0, 0);//used to ensure daily ops happen no more than that + //////////////////////////////////////////////////////////////////////////////////////////////// // DoSweep @@ -41,6 +44,23 @@ namespace AyaNova.Biz NotifyIsRunning = true; log.LogTrace("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 + //However if server is on UTC already then that's what is used, there is no adjustment + DateTime dtNowLocal = DateTime.Now; + if (dtNowLocal - lastNotifyHealthCheckSentLocal > TS_24_HOURS) + { + //are we in the 7th to 9th hour? + if (dtNowLocal.Hour > 6 && dtNowLocal.Hour < 10) + { + log.LogTrace("Notify health check submitted to subscribers"); + await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.NotifyHealthCheck, "OK"); + lastNotifyHealthCheckSentLocal = dtNowLocal; + } + } + + + using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext) {