| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | 
							- using System;
 
- using System.Threading.Tasks;
 
- using Comal.TaskScheduler.Shared;
 
- using InABox.IPC;
 
- using InABox.Clients;
 
- using InABox.Core;
 
- using InABox.Rpc;
 
- namespace PRSServer
 
- {
 
-     internal class ScheduleEngine : Engine<ScheduleServerProperties>
 
-     {
 
-         private readonly Scheduler scheduler = new();
 
-         private void CheckConnection()
 
-         {
 
-             // Wait for server connection
 
-             while (!Client.Ping())
 
-             {
 
-                 Logger.Send(LogType.Error, "", "Database server unavailable. Trying again in 30 seconds...");
 
-                 Task.Delay(30_000).Wait();
 
-                 Logger.Send(LogType.Information, "", "Retrying connection...");
 
-             }
 
-             ClientFactory.SetBypass();
 
-         }
 
-         public override void Run()
 
-         {
 
-             try
 
-             {
 
-                 if (string.IsNullOrWhiteSpace(Properties.Server))
 
-                 {
 
-                     Logger.Send(LogType.Error, "", "Server is blank!");
 
-                     return;
 
-                 }
 
-                 var transport = new RpcClientPipeTransport(DatabaseServerProperties.GetPipeName(Properties.Server));
 
-                 ClientFactory.SetClientType(typeof(RpcClient<>), Platform.SchedulerEngine, Version, transport);
 
-                 CheckConnection();
 
-                 Logger.Send(LogType.Information, "", "Starting Scheduler: ");
 
-                 scheduler.Start();
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 Logger.Send(LogType.Error, "", "Error: " + ex.Message + "\n" + ex.StackTrace);
 
-                 throw ex;
 
-             }
 
-         }
 
-         public override void Stop()
 
-         {
 
-             scheduler.Stop();
 
-         }
 
-     }
 
- }
 
 
  |