From 88a8609b3ef888555d1cfd4ea14f04bc187260f4 Mon Sep 17 00:00:00 2001 From: RDeck Date: Mon, 20 Oct 2025 09:22:53 -0400 Subject: [PATCH] ! --- ClassObj/ClsConstants.cs | 22 ++++++++++++++++++++++ ClassObj/ServiceMain.cs | 2 +- Program.cs | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ClassObj/ClsConstants.cs b/ClassObj/ClsConstants.cs index 72bf82a..c4e2125 100644 --- a/ClassObj/ClsConstants.cs +++ b/ClassObj/ClsConstants.cs @@ -84,4 +84,26 @@ public class ClsConstants { dctScheduler[TaskName] = theTime; } + + internal static bool CanWeGo(byte whichLevel) + { + var rv = true; + lock (Program.objSync2) + { + try + { + using (var cn = new SqlConnection(kmCommonLibsCore.Constants.cnCommon)) + { + rv = (Convert.ToInt32(cn.ExecuteScalar($"Select dbo.rdbCanWeGo({whichLevel})")) == 1) ? true : false; + } + } + catch // Something is wrong with SQL, so don't let anything run + { + rv = false; + throw; + } + } + return rv; + } //CanWeGo + } diff --git a/ClassObj/ServiceMain.cs b/ClassObj/ServiceMain.cs index 54982d9..f4bfc7f 100644 --- a/ClassObj/ServiceMain.cs +++ b/ClassObj/ServiceMain.cs @@ -35,7 +35,7 @@ internal class ServiceMain : ServiceControl while (!Program.isExiting) { Thread.Sleep(rn.Next(250, 1500)); - if (dtNext < DateTimeOffset.Now) + if (ClsConstants.CanWeGo(1) && dtNext < DateTimeOffset.Now) { try { diff --git a/Program.cs b/Program.cs index 1cb05d1..7586909 100644 --- a/Program.cs +++ b/Program.cs @@ -13,7 +13,8 @@ internal class Program internal static string AppName = AppDomain.CurrentDomain.FriendlyName.Trim(); internal static string MachineName = Environment.MachineName.Trim(); - public static bool isExiting = false; + internal static bool isExiting = false; + internal static object objSync2 = new(); // used by the CanWeGo proc in Constants static void Main(string[] args) {