This commit is contained in:
RDeck 2025-10-20 09:22:53 -04:00
parent fb1243a519
commit 88a8609b3e
3 changed files with 25 additions and 2 deletions

View File

@ -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
}

View File

@ -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
{

View File

@ -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)
{