From 1669534044ed23cf1e2c09ea049d3b1a2b66f88c Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Sun, 28 Jan 2024 02:39:47 +0900 Subject: [PATCH] SMS full reset & Analyzer indicator --- Core/Main/PTMagic.cs | 21 +++++++ Monitor/Pages/Index.cshtml | 14 +++-- Monitor/Pages/ManageSMS.cshtml | 68 +++++++++++++++++++++- Monitor/Pages/ManageSMS.cshtml.cs | 41 ++++++++++++- Monitor/Pages/SettingsGeneral.cshtml | 12 ++-- Monitor/Pages/_Layout.cshtml | 2 +- Monitor/Pages/_get/DashboardTop.cshtml | 2 +- Monitor/Pages/_get/TickerWidgets.cshtml | 3 + Monitor/Pages/_get/TickerWidgets.cshtml.cs | 36 +++++++++++- 9 files changed, 181 insertions(+), 18 deletions(-) diff --git a/Core/Main/PTMagic.cs b/Core/Main/PTMagic.cs index 1270cd0..7ed366f 100644 --- a/Core/Main/PTMagic.cs +++ b/Core/Main/PTMagic.cs @@ -59,6 +59,7 @@ namespace Core.Main private Dictionary _singleMarketSettingsCount = new Dictionary(); Dictionary> _triggeredSingleMarketSettings = new Dictionary>(); private static volatile object _lockObj = new object(); + private Mutex mutex = new Mutex(false, "analyzerStateMutex"); public LogHelper Log { @@ -122,6 +123,22 @@ namespace Core.Main _state = value; } } + public void WriteStateToFile() + { + try + { + mutex.WaitOne(); // Acquire the mutex + + string filePath = "_data/AnalyzerState."; + File.WriteAllText(filePath, this.State.ToString()); + + } + finally + { + mutex.ReleaseMutex(); // Release the mutex even if exceptions occur + } + } + public int RunCount { @@ -840,6 +857,7 @@ namespace Core.Main { // Change state to "Running" this.State = Constants.PTMagicBotState_Running; + this.WriteStateToFile(); this.RunCount++; this.LastRuntime = DateTime.UtcNow; @@ -975,6 +993,7 @@ namespace Core.Main // Change state to Finished / Stopped this.State = Constants.PTMagicBotState_Idle; + this.WriteStateToFile(); } } } @@ -991,6 +1010,7 @@ namespace Core.Main { Log.DoLogWarn("PTMagic raid " + this.RunCount.ToString() + " is taking longer than expected. Consider increasing your IntervalMinues setting, reducing other processes on your PC, or raising PTMagic's priority."); this.State = Constants.PTMagicBotState_Idle; + this.WriteStateToFile(); Log.DoLogInfo("PTMagic status reset, waiting for the next raid to be good to go again."); } } @@ -998,6 +1018,7 @@ namespace Core.Main { Log.DoLogWarn("No LastRuntimeSummary.json found after raid " + this.RunCount.ToString() + ", trying to reset PT Magic status..."); this.State = Constants.PTMagicBotState_Idle; + this.WriteStateToFile(); Log.DoLogInfo("PTMagic status reset, waiting for the next raid to be good to go again."); } } diff --git a/Monitor/Pages/Index.cshtml b/Monitor/Pages/Index.cshtml index 25b691c..901f19f 100644 --- a/Monitor/Pages/Index.cshtml +++ b/Monitor/Pages/Index.cshtml @@ -25,7 +25,8 @@ +