public void OnBatchLogUpdate(string batchLogUpdate)
        {
            var message = "On BatchLogUpdate in " + nameof(AgentLogConsumer) + "...";

            AppLog(message);
            ThreadHelperClass.SetText(_thisForm, DisplayTxt, batchLogUpdate);
        }
        public void OnStoped()
        {
            var message = "On Stopped in " + nameof(AgentLogConsumer) + "...";

            Log.Debug(message);
            AppLog(message);
            Timer.Enabled     = false;
            RestartAfterCount = 0;
            ThreadHelperClass.SetBackColor(_thisForm, IndicatorPanel, Color.Azure);
        }
 public void AppLog(string message)
 {
     if (!DebugMode)
     {
         return;
     }
     AppLogs.Add(message);
     AppLogs.Reverse();
     ThreadHelperClass.SetText(_thisForm, CommonAppLogView, string.Join(Environment.NewLine, AppLogs));
     AppLogs.Reverse();
 }
        public void OnEachLogUpdate(string logUpdate)
        {
            var updateMessage = "On OnEachLogUpdate in " + nameof(AgentLogConsumer) + "...";

            AppLog(updateMessage);
            if (logUpdate.Contains("Disassociated [akka.tcp://") && logUpdate.Contains("akka.tcp://LEAPAppActorSystem"))
            {
                RestartAfterCount++;
                var message = ">>>>>>>>>>>>>>>> RESTART COUNTER INCREMENTED NOW AT : " + RestartAfterCount;
                ThreadHelperClass.SetText(_thisForm, RichTextBox, message);
                Log.Debug(message);
                AppLog(message);
            }
            ThreadHelperClass.SetText(_thisForm, RichTextBox, logUpdate);
        }
        private void OnTimerTick()
        {
            if (Restarting)
            {
                return;
            }
            if (RestartAfterCount >= MaxRestartCount)
            {
                Restarting = true;
                OnStoped();
                const string message = "Max restart counter exceeded, application will now be restarted!!!";
                Log.Debug(message);
                ThreadHelperClass.SetBackColor(_thisForm, IndicatorPanel, Color.Red);
                try
                {
                    if (!DebugMode)
                    {
                        ExecuteWindowsShortCut(ShorCutToExecute);
                    }
                    _justRecovered = true;
                    Log.Debug("Restart executed successfully");
                    AppLog("Restart executed successfully");
                }
                catch (Exception e)
                {
                    Log.Error(e, "Error trying to execute restart command");
                    AppLog("Error trying to execute restart command " + e.Message + " - " + e.InnerException?.Message);
                }

                System.Threading.Thread.Sleep(5000);
                OnStarted();
            }
            else
            {
                if (_justRecovered)
                {
                    Log.Debug("System just restarted. Everything looks good!");
                    AppLog("System just restarted. Everything looks good!");
                    _justRecovered = false;
                }

                ThreadHelperClass.SetBackColor(_thisForm, IndicatorPanel, Color.GreenYellow);
            }
            Restarting        = false;
            RestartAfterCount = 0;
        }