From f8573661c9325d34ec7a24601ea8e693a6fc22f1 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Sat, 3 Feb 2024 02:22:39 +0900 Subject: [PATCH] Monitor DashboardRefreshSeconds --- Core/DataObjects/PTMagicData.cs | 2 +- Core/DataObjects/ProfitTrailerData.cs | 16 ++++---- Monitor/Pages/Index.cshtml | 2 +- Monitor/Pages/SettingsGeneral.cshtml | 2 +- Monitor/Pages/SettingsGeneral.cshtml.cs | 2 +- Monitor/Pages/_get/DashboardBottom.cshtml | 6 +-- Monitor/Pages/_get/DashboardBottom.cshtml.cs | 2 +- Monitor/Pages/_get/TickerWidgets.cshtml.cs | 40 ++++++++++--------- .../settings.general.json | 2 +- .../DevSettings/settings.general.json | 2 +- 10 files changed, 40 insertions(+), 36 deletions(-) diff --git a/Core/DataObjects/PTMagicData.cs b/Core/DataObjects/PTMagicData.cs index 245199a..3b1a668 100644 --- a/Core/DataObjects/PTMagicData.cs +++ b/Core/DataObjects/PTMagicData.cs @@ -59,7 +59,7 @@ namespace Core.Main.DataObjects.PTMagicData public int GraphIntervalMinutes { get; set; } = 60; public int GraphMaxTimeframeHours { get; set; } = 24; public int ProfitsMaxTimeframeDays { get; set; } = 60; - public int RefreshSeconds { get; set; } = 30; + public int DashboardChartsRefreshSeconds { get; set; } = 30; public int BagAnalyzerRefreshSeconds { get; set; } = 5; public int BuyAnalyzerRefreshSeconds { get; set; } = 5; public int MaxTopMarkets { get; set; } = 20; diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs index 13c2050..c4008b1 100644 --- a/Core/DataObjects/ProfitTrailerData.cs +++ b/Core/DataObjects/ProfitTrailerData.cs @@ -114,7 +114,7 @@ namespace Core.Main.DataObjects if (_misc == null || (DateTime.UtcNow > _miscRefresh)) { _misc = BuildMiscData(GetDataFromProfitTrailer("api/v2/data/misc")); - _miscRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds - 1); + _miscRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds - 1); } } } @@ -185,7 +185,7 @@ namespace Core.Main.DataObjects { JArray dailyStatsSection = (JArray)extraSection["dailyStats"]; _dailyStats = dailyStatsSection.Select(j => BuildDailyStatsData(j as JObject)).ToList(); - _dailyStatsRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds - 1); + _dailyStatsRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds - 1); } } } @@ -220,7 +220,7 @@ namespace Core.Main.DataObjects if (_properties == null || (DateTime.UtcNow > _propertiesRefresh)) { _properties = BuildProptertiesData(GetDataFromProfitTrailer("api/v2/data/properties")); - _propertiesRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds - 1); + _propertiesRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds - 1); } } } @@ -263,7 +263,7 @@ namespace Core.Main.DataObjects jsonReader.Read(); // Move to the value of the "basic" property JObject basicSection = JObject.Load(jsonReader); _stats = BuildStatsData(basicSection); - _statsRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds - 1); + _statsRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds - 1); break; } } @@ -360,7 +360,7 @@ namespace Core.Main.DataObjects { JArray dailyPNLSection = (JArray)extraSection["dailyPNLStats"]; _dailyPNL = dailyPNLSection.Select(j => BuildDailyPNLData(j as JObject)).ToList(); - _dailyPNLRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds - 1); + _dailyPNLRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds - 1); } } } @@ -434,7 +434,7 @@ namespace Core.Main.DataObjects _profitablePairs.Add(BuildProfitablePairs(profitablePair)); counter++; } - _profitablePairsRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds - 1); + _profitablePairsRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds - 1); } } } @@ -500,7 +500,7 @@ namespace Core.Main.DataObjects { JArray dailyTCVSection = (JArray)extraSection["dailyTCVStats"]; _dailyTCV = dailyTCVSection.Select(j => BuildDailyTCVData(j as JObject)).ToList(); - _dailyTCVRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds - 1); + _dailyTCVRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds - 1); } } } @@ -568,7 +568,7 @@ namespace Core.Main.DataObjects { JArray monthlyStatsSection = (JArray)extraSection["monthlyStats"]; _monthlyStats = monthlyStatsSection.Select(j => BuildMonthlyStatsData(j as JObject)).ToList(); - _monthlyStatsRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds - 1); + _monthlyStatsRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds - 1); } } } diff --git a/Monitor/Pages/Index.cshtml b/Monitor/Pages/Index.cshtml index 08f3ac9..2ff2ffe 100644 --- a/Monitor/Pages/Index.cshtml +++ b/Monitor/Pages/Index.cshtml @@ -107,7 +107,7 @@ } // Reinstate the interval. - intervalDashboardBottom = setInterval(function () { loadDashboardBottom(); }, @Model.PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds * 1000); + intervalDashboardBottom = setInterval(function () { loadDashboardBottom(); }, @Model.PTMagicConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds * 1000); }); }; diff --git a/Monitor/Pages/SettingsGeneral.cshtml b/Monitor/Pages/SettingsGeneral.cshtml index 0918b6f..f01ef9b 100644 --- a/Monitor/Pages/SettingsGeneral.cshtml +++ b/Monitor/Pages/SettingsGeneral.cshtml @@ -225,7 +225,7 @@
- +
diff --git a/Monitor/Pages/SettingsGeneral.cshtml.cs b/Monitor/Pages/SettingsGeneral.cshtml.cs index e601e69..83f297f 100644 --- a/Monitor/Pages/SettingsGeneral.cshtml.cs +++ b/Monitor/Pages/SettingsGeneral.cshtml.cs @@ -62,7 +62,7 @@ namespace Monitor.Pages PTMagicConfiguration.GeneralSettings.Monitor.GraphIntervalMinutes = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_GraphIntervalMinutes"], PTMagicConfiguration.GeneralSettings.Monitor.GraphIntervalMinutes); PTMagicConfiguration.GeneralSettings.Monitor.GraphMaxTimeframeHours = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_GraphMaxTimeframeHours"], PTMagicConfiguration.GeneralSettings.Monitor.GraphMaxTimeframeHours); PTMagicConfiguration.GeneralSettings.Monitor.ProfitsMaxTimeframeDays = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_ProfitsMaxTimeframeDays"], PTMagicConfiguration.GeneralSettings.Monitor.ProfitsMaxTimeframeDays); - PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_RefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds); + PTMagicConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_RefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds); PTMagicConfiguration.GeneralSettings.Monitor.BagAnalyzerRefreshSeconds = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_BagAnalyzerRefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.BagAnalyzerRefreshSeconds); PTMagicConfiguration.GeneralSettings.Monitor.BuyAnalyzerRefreshSeconds = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_BuyAnalyzerRefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.BuyAnalyzerRefreshSeconds); PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform = HttpContext.Request.Form["Monitor_LinkPlatform"]; diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml b/Monitor/Pages/_get/DashboardBottom.cshtml index 0a7f8ca..6b66682 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml +++ b/Monitor/Pages/_get/DashboardBottom.cshtml @@ -13,8 +13,8 @@
-
+
@{ string totalCurrentValueString = Model.totalCurrentValue.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")); if (Model.totalCurrentValue > 100) { @@ -87,7 +87,7 @@ @*

*@

Live Market Trends - + ANALYZER

diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml.cs b/Monitor/Pages/_get/DashboardBottom.cshtml.cs index 4582728..8fdb9b0 100644 --- a/Monitor/Pages/_get/DashboardBottom.cshtml.cs +++ b/Monitor/Pages/_get/DashboardBottom.cshtml.cs @@ -75,7 +75,7 @@ namespace Monitor.Pages public void StartUpdatingTotalCurrentValueLive() { - int liveTCVInterval = PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds; + int liveTCVInterval = PTMagicConfiguration.GeneralSettings.Monitor.DashboardChartsRefreshSeconds; if (timer != null) { // Timer is already running diff --git a/Monitor/Pages/_get/TickerWidgets.cshtml.cs b/Monitor/Pages/_get/TickerWidgets.cshtml.cs index 4d16b0a..b11d08a 100644 --- a/Monitor/Pages/_get/TickerWidgets.cshtml.cs +++ b/Monitor/Pages/_get/TickerWidgets.cshtml.cs @@ -27,26 +27,30 @@ namespace Monitor.Pages { } public bool IsAnalyzerRunning() { - // Acquire the mutex before accessing the file - try - { - mutex.WaitOne(0); - - string webRootParent = Directory.GetParent(_hostingEnvironment.WebRootPath).FullName; - string ptMagicRoot = Directory.GetParent(webRootParent).FullName; - string analyzerStatePath = Path.Combine(ptMagicRoot, "_data", "AnalyzerState"); - if (System.IO.File.Exists(analyzerStatePath)) + bool ownsMutex = false; + try { - string state = System.IO.File.ReadAllText(analyzerStatePath); - return state == "1"; - } - return false; + // Try to acquire the mutex. + ownsMutex = mutex.WaitOne(0); - } - finally - { - mutex.ReleaseMutex(); // Always release the mutex - } + string webRootParent = Directory.GetParent(_hostingEnvironment.WebRootPath).FullName; + string ptMagicRoot = Directory.GetParent(webRootParent).FullName; + string analyzerStatePath = Path.Combine(ptMagicRoot, "_data", "AnalyzerState"); + if (System.IO.File.Exists(analyzerStatePath)) + { + string state = System.IO.File.ReadAllText(analyzerStatePath); + return state == "1"; + } + return false; + } + finally + { + // Only release the mutex if this thread owns it. + if (ownsMutex) + { + mutex.ReleaseMutex(); + } + } } private void BindData() { diff --git a/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json b/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json index 103d21d..3e13de7 100644 --- a/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json +++ b/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json @@ -26,7 +26,7 @@ "GraphIntervalMinutes": 60, // The interval for the monitor market trend graph to draw points in minutes "GraphMaxTimeframeHours": 24, // This will enable you to define the timeframe that your graph for market trends covers in hours "ProfitsMaxTimeframeDays": 30, // This will enable you to define the timeframe for your dashboard profits graph in days - "RefreshSeconds": 30, // The refresh interval of your monitor main page + "DashboardChartsRefreshSeconds": 30, // The refresh interval of your dashboard charts in seconds "BagAnalyzerRefreshSeconds": 60, "BuyAnalyzerRefreshSeconds": 60, "MaxDashboardBuyEntries": 5, // The number of coins in your Possible Buy List on the dashboard. Set to 0 to hide the list completely diff --git a/_Development/DevSettings/settings.general.json b/_Development/DevSettings/settings.general.json index 103d21d..3e13de7 100644 --- a/_Development/DevSettings/settings.general.json +++ b/_Development/DevSettings/settings.general.json @@ -26,7 +26,7 @@ "GraphIntervalMinutes": 60, // The interval for the monitor market trend graph to draw points in minutes "GraphMaxTimeframeHours": 24, // This will enable you to define the timeframe that your graph for market trends covers in hours "ProfitsMaxTimeframeDays": 30, // This will enable you to define the timeframe for your dashboard profits graph in days - "RefreshSeconds": 30, // The refresh interval of your monitor main page + "DashboardChartsRefreshSeconds": 30, // The refresh interval of your dashboard charts in seconds "BagAnalyzerRefreshSeconds": 60, "BuyAnalyzerRefreshSeconds": 60, "MaxDashboardBuyEntries": 5, // The number of coins in your Possible Buy List on the dashboard. Set to 0 to hide the list completely