public override string Execute() { var jobQueue = _engine.GetJobInQueue().Result; if (jobQueue == null) { return("No job was found in queue."); } Console.WriteLine($"A job queue \"{jobQueue.Code}\" was found."); var confirmExecute = AutoExecute || Console.GetYesNo("Do you want to proceed with the execution?", false); if (!confirmExecute) { return($"Job queue \"{jobQueue.Code}\" has not been executed."); } Console.WriteLine($"Executing job queue {jobQueue.Code}..."); _engine.ExecuteJob(jobQueue).Wait(); var message = $"Job queue \"{jobQueue.Code}\" execution has completed."; Logger.LogInformation(message); return(message); }
private void _jobCheckerTimer_Elapsed(object sender, ElapsedEventArgs e) { _jobCheckerTimer.Stop(); var jobQueue = _engine.GetJobInQueue().Result; if (jobQueue != null) { Console.WriteLine($"Job queue {jobQueue.Code} is ready to be executed."); _engine.ExecuteJob(jobQueue).Wait(); switch (jobQueue.Status) { case JobStatus.Pending: Console.WriteLine($"Job queue {jobQueue.Code} execution is being halted. Please restart the job when it's ready."); break; case JobStatus.Completed: Console.WriteLine($"Job queue {jobQueue.Code} execution has completed."); break; default: Console.WriteLine($"Job queue {jobQueue.Code} execution has completed with error. Please check the job queue's log."); break; } Console.WriteLine("Engine is waiting for a job to execute.."); } else { if (Verbose) { Console.WriteLine($"[{e?.SignalTime.ToLongTimeString() ?? DateTime.Now.ToLongTimeString()}] No job in queue."); } } _jobCheckerTimer.Start(); }