From 42c2210c16b7d5efd504681eaee8428814a3c667 Mon Sep 17 00:00:00 2001 From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com> Date: Wed, 9 Sep 2020 15:39:26 +0900 Subject: [PATCH] Manage SMS changes --- Monitor/Pages/ManageSMS.cshtml | 295 ++++++++++++++++-------------- Monitor/Pages/ManageSMS.cshtml.cs | 15 ++ PTMagic/Program.cs | 2 +- 3 files changed, 173 insertions(+), 139 deletions(-) diff --git a/Monitor/Pages/ManageSMS.cshtml b/Monitor/Pages/ManageSMS.cshtml index 9daf170..d9200d3 100644 --- a/Monitor/Pages/ManageSMS.cshtml +++ b/Monitor/Pages/ManageSMS.cshtml @@ -11,157 +11,176 @@
- -

Applied Single Market Setting Details

- +

Applied Single Market Settings

+ +


+ + @{ + Model.CreateSmsList(); + foreach (string sms in Model.smsList) + { + int smsCount = 0; + foreach (Core.Main.DataObjects.PTMagicData.SingleMarketSettingSummary smsSummary in Model.SingleMarketSettingSummaries) + { + if (smsSummary.SingleMarketSetting.SettingName == sms) + { + smsCount = smsCount + 1; + } + } + @sms: @smsCount     + } + } + +

+ +
- - - - - - + + + + + + - - @{ - string lastMarket = ""; - } - @foreach (Core.Main.DataObjects.PTMagicData.SingleMarketSettingSummary smsSummary in Model.SingleMarketSettingSummaries.OrderBy(s => s.Market)) { - Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null; - if (Model.Summary.MarketSummary.ContainsKey(smsSummary.Market)) { - mps = Model.Summary.MarketSummary[smsSummary.Market]; - } else { - mps = new Core.Main.DataObjects.PTMagicData.MarketPairSummary(); - } + + @{ + string lastMarket = ""; + } + @foreach (Core.Main.DataObjects.PTMagicData.SingleMarketSettingSummary smsSummary in Model.SingleMarketSettingSummaries.OrderBy(s => s.Market)) { + Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null; + if (Model.Summary.MarketSummary.ContainsKey(smsSummary.Market)) { + mps = Model.Summary.MarketSummary[smsSummary.Market]; + } else { + mps = new Core.Main.DataObjects.PTMagicData.MarketPairSummary(); + } - bool settingHasOffTriggers = false; - if (smsSummary.SingleMarketSetting.OffTriggers.Count > 0) { - settingHasOffTriggers = true; - } + bool settingHasOffTriggers = false; + if (smsSummary.SingleMarketSetting.OffTriggers.Count > 0) { + settingHasOffTriggers = true; + } - int activeSeconds = (int)Math.Floor(DateTime.UtcNow.Subtract(smsSummary.ActivationDateTimeUTC).TotalSeconds); - int activeHours = (int)Math.Floor(DateTime.UtcNow.Subtract(smsSummary.ActivationDateTimeUTC).TotalHours); - - + + + + + + - - - - - + - - - lastMarket = smsSummary.Market; - } - -
Market NameLast PriceVolumeActive SettingTriggered timeOff TriggersCurrent ValuesVolumeLast PriceActive Setting Triggered timeOff TriggersCurrent Value
- @if (!lastMarket.Equals(smsSummary.Market)) { - @smsSummary.Market + int activeSeconds = (int)Math.Floor(DateTime.UtcNow.Subtract(smsSummary.ActivationDateTimeUTC).TotalSeconds); + int activeHours = (int)Math.Floor(DateTime.UtcNow.Subtract(smsSummary.ActivationDateTimeUTC).TotalHours); +
+ @if (!lastMarket.Equals(smsSummary.Market)) { + @smsSummary.Market + } + + @if (!lastMarket.Equals(smsSummary.Market)) { + @Math.Round(mps.Latest24hVolume, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket + } + + @if (!lastMarket.Equals(smsSummary.Market)) { + @mps.LatestPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket + } + + @Core.Helper.SystemHelper.SplitCamelCase(smsSummary.SingleMarketSetting.SettingName) + + @Core.Helper.SystemHelper.GetProperDurationTime(activeSeconds) + + @if (settingHasOffTriggers) { + foreach (Core.Main.DataObjects.PTMagicData.OffTrigger ot in smsSummary.SingleMarketSetting.OffTriggers) { + string triggerTextClass = "text-danger"; + if (ot.HoursSinceTriggered > 0) { + triggerTextClass = (activeHours >= ot.HoursSinceTriggered) ? "text-success" : "text-danger"; +

Hours Since Triggered@ot.HoursSinceTriggered

} - -
- @if (!lastMarket.Equals(smsSummary.Market)) { - @mps.LatestPrice.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket - } - - @if (!lastMarket.Equals(smsSummary.Market)) { - @Math.Round(mps.Latest24hVolume, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket - } - - @Core.Helper.SystemHelper.SplitCamelCase(smsSummary.SingleMarketSetting.SettingName) - - @Core.Helper.SystemHelper.GetProperDurationTime(activeSeconds) - - @if (settingHasOffTriggers) { - foreach (Core.Main.DataObjects.PTMagicData.OffTrigger ot in smsSummary.SingleMarketSetting.OffTriggers) { - string triggerTextClass = "text-danger"; - if (ot.HoursSinceTriggered > 0) { - triggerTextClass = (activeHours >= ot.HoursSinceTriggered) ? "text-success" : "text-danger"; -

Hours Since Triggered@ot.HoursSinceTriggered

- } - if (ot.Min24hVolume > 0 || ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { - triggerTextClass = (mps.Latest24hVolume >= ot.Min24hVolume && mps.Latest24hVolume <= ot.Max24hVolume) ? "text-success" : "text-danger"; -

- Volume - - @if (ot.Min24hVolume > 0) { - @("min: " + ot.Min24hVolume.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) + " " + Model.Summary.MainMarket) - } - @if (ot.Min24hVolume > 0 && ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { - @(", ") - } - @if (ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { - @("max: " + ot.Max24hVolume.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) + " " + Model.Summary.MainMarket) - } - -

- } - if (ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { - triggerTextClass = (mps.Latest24hVolume <= ot.Max24hVolume) ? "text-success" : "text-danger"; -

Max 24h Volume@ot.Max24hVolume.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket

- } - if (!ot.MarketTrendName.Equals("")) { - double trendChange = Model.GetTrendChange(ot.MarketTrendName, mps, smsSummary.TriggerSnapshot, ot.MarketTrendRelation); - triggerTextClass = (trendChange >= ot.MinChange && trendChange <= ot.MaxChange) ? "text-success" : "text-danger"; -

- @Core.Helper.SystemHelper.SplitCamelCase(ot.MarketTrendName) (@Core.Helper.SystemHelper.SplitCamelCase(ot.MarketTrendRelation)) - - @if (ot.MinChange > Core.Main.Constants.MinTrendChange) { - @("min: " + ot.MinChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%") - } - @if (ot.MinChange > Core.Main.Constants.MinTrendChange && ot.MaxChange < Core.Main.Constants.MaxTrendChange) { - @(", ") - } - @if (ot.MaxChange < Core.Main.Constants.MaxTrendChange) { - @("max: " + ot.MaxChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%") - } - -

- } - } - } else { - Not specified - } -
- @if (settingHasOffTriggers) { - foreach (Core.Main.DataObjects.PTMagicData.OffTrigger ot in smsSummary.SingleMarketSetting.OffTriggers) { - string triggerTextClass = "text-danger"; - if (ot.HoursSinceTriggered > 0) { - triggerTextClass = (activeHours >= ot.HoursSinceTriggered) ? "text-success" : "text-danger"; -

@activeHours.ToString(new System.Globalization.CultureInfo("en-US"))

- } - if (ot.Min24hVolume > 0) { - triggerTextClass = (mps.Latest24hVolume >= ot.Min24hVolume) ? "text-success" : "text-danger"; -

@Math.Round(mps.Latest24hVolume, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket

- } - if (ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { - triggerTextClass = (mps.Latest24hVolume <= ot.Max24hVolume) ? "text-success" : "text-danger"; -

@Math.Round(mps.Latest24hVolume, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket

- } - if (!ot.MarketTrendName.Equals("")) { - if (mps.MarketTrendChanges.ContainsKey(ot.MarketTrendName)) { - double trendChange = Model.GetTrendChange(ot.MarketTrendName, mps, smsSummary.TriggerSnapshot, ot.MarketTrendRelation); - triggerTextClass = (trendChange >= ot.MinChange && trendChange <= ot.MaxChange) ? "text-success" : "text-danger"; - string trendChangeOutput = trendChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")); -

@trendChangeOutput%

+ if (ot.Min24hVolume > 0 || ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { + triggerTextClass = (mps.Latest24hVolume >= ot.Min24hVolume && mps.Latest24hVolume <= ot.Max24hVolume) ? "text-success" : "text-danger"; +

+ Volume + + @if (ot.Min24hVolume > 0) { + @("min: " + ot.Min24hVolume.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) + " " + Model.Summary.MainMarket) } - } + @if (ot.Min24hVolume > 0 && ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { + @(", ") + } + @if (ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { + @("max: " + ot.Max24hVolume.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) + " " + Model.Summary.MainMarket) + } + +

+ } + if (ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { + triggerTextClass = (mps.Latest24hVolume <= ot.Max24hVolume) ? "text-success" : "text-danger"; +

Max 24h Volume@ot.Max24hVolume.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket

+ } + if (!ot.MarketTrendName.Equals("")) { + double trendChange = Model.GetTrendChange(ot.MarketTrendName, mps, smsSummary.TriggerSnapshot, ot.MarketTrendRelation); + triggerTextClass = (trendChange >= ot.MinChange && trendChange <= ot.MaxChange) ? "text-success" : "text-danger"; +

+ @Core.Helper.SystemHelper.SplitCamelCase(ot.MarketTrendName) (@Core.Helper.SystemHelper.SplitCamelCase(ot.MarketTrendRelation)) + + @if (ot.MinChange > Core.Main.Constants.MinTrendChange) { + @("min: " + ot.MinChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%") + } + @if (ot.MinChange > Core.Main.Constants.MinTrendChange && ot.MaxChange < Core.Main.Constants.MaxTrendChange) { + @(", ") + } + @if (ot.MaxChange < Core.Main.Constants.MaxTrendChange) { + @("max: " + ot.MaxChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%") + } + +

+ } + } + } else { + Not specified + } +
+ @if (settingHasOffTriggers) { + foreach (Core.Main.DataObjects.PTMagicData.OffTrigger ot in smsSummary.SingleMarketSetting.OffTriggers) { + string triggerTextClass = "text-danger"; + if (ot.HoursSinceTriggered > 0) { + triggerTextClass = (activeHours >= ot.HoursSinceTriggered) ? "text-success" : "text-danger"; +

@activeHours.ToString(new System.Globalization.CultureInfo("en-US"))

+ } + if (ot.Min24hVolume > 0) { + triggerTextClass = (mps.Latest24hVolume >= ot.Min24hVolume) ? "text-success" : "text-danger"; +

@Math.Round(mps.Latest24hVolume, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket

+ } + if (ot.Max24hVolume < Core.Main.Constants.Max24hVolume) { + triggerTextClass = (mps.Latest24hVolume <= ot.Max24hVolume) ? "text-success" : "text-danger"; +

@Math.Round(mps.Latest24hVolume, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")) @Model.Summary.MainMarket

+ } + if (!ot.MarketTrendName.Equals("")) { + if (mps.MarketTrendChanges.ContainsKey(ot.MarketTrendName)) { + double trendChange = Model.GetTrendChange(ot.MarketTrendName, mps, smsSummary.TriggerSnapshot, ot.MarketTrendRelation); + triggerTextClass = (trendChange >= ot.MinChange && trendChange <= ot.MaxChange) ? "text-success" : "text-danger"; + string trendChangeOutput = trendChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")); +

@trendChangeOutput%

} } -
- @if (settingHasOffTriggers) { - @if (Model.PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected) { - Reset - } else { - Reset - } - } -
- + } + } + + + @if (settingHasOffTriggers) { + @if (Model.PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected) { + Reset + } else { + Reset + } + } + + + lastMarket = smsSummary.Market; + } + +
diff --git a/Monitor/Pages/ManageSMS.cshtml.cs b/Monitor/Pages/ManageSMS.cshtml.cs index f18a520..2153e5b 100644 --- a/Monitor/Pages/ManageSMS.cshtml.cs +++ b/Monitor/Pages/ManageSMS.cshtml.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; @@ -20,6 +21,20 @@ namespace Monitor.Pages BindData(); } + public List smsList = new List(); + + public void CreateSmsList () + { + + foreach (Core.Main.DataObjects.PTMagicData.SingleMarketSettingSummary smsSummary in SingleMarketSettingSummaries) + { + if (!smsList.Contains(smsSummary.SingleMarketSetting.SettingName)) + { + smsList.Add(smsSummary.SingleMarketSetting.SettingName); + } + } + } + private void BindData() { if (System.IO.File.Exists(PTMagicBasePath + Constants.PTMagicPathData + Path.DirectorySeparatorChar + "SingleMarketSettingSummary.json")) diff --git a/PTMagic/Program.cs b/PTMagic/Program.cs index cb5a388..3eb1a30 100644 --- a/PTMagic/Program.cs +++ b/PTMagic/Program.cs @@ -6,7 +6,7 @@ using Core.Helper; using Microsoft.Extensions.DependencyInjection; -[assembly: AssemblyVersion("2.4.5")] +[assembly: AssemblyVersion("2.4.6")] [assembly: AssemblyProduct("PT Magic")] namespace PTMagic