From 6a364c95e72260959c3308c9ba07cb2048b234d4 Mon Sep 17 00:00:00 2001
From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com>
Date: Thu, 14 Dec 2023 11:54:28 +0900
Subject: [PATCH 01/14] 2.7 changes
---
Core/DataObjects/PTMagicData.cs | 3 +-
Core/DataObjects/ProfitTrailerData.cs | 11 +++-
Core/Main/PTMagic.cs | 56 ++++++++---------
Core/ProfitTrailer/StrategyHelper.cs | 2 +-
Monitor/Pages/SalesAnalyzer.cshtml | 2 +-
Monitor/Pages/SettingsGeneral.cshtml | 21 ++++---
Monitor/Pages/SettingsGeneral.cshtml.cs | 5 +-
Monitor/Pages/StatusSummary.cshtml | 61 +------------------
Monitor/wwwroot/assets/css/style.css | 18 +++---
PTMagic.sln | 37 +++++++++++
.../settings.general.json | 5 +-
.../DevSettings/settings.general.json | 5 +-
12 files changed, 111 insertions(+), 115 deletions(-)
create mode 100644 PTMagic.sln
diff --git a/Core/DataObjects/PTMagicData.cs b/Core/DataObjects/PTMagicData.cs
index 25865a1..fa6f69b 100644
--- a/Core/DataObjects/PTMagicData.cs
+++ b/Core/DataObjects/PTMagicData.cs
@@ -48,7 +48,7 @@ namespace Core.Main.DataObjects.PTMagicData
public string TimezoneOffset { get; set; } = "+0:00";
public string MainFiatCurrency { get; set; } = "USD";
public string CoinMarketCapAPIKey { get; set; }
- public string FreeCurrencyConverterAPIKey { get; set; }
+ //public string FreeCurrencyConverterAPIKey { get; set; }
}
public class Monitor
@@ -64,6 +64,7 @@ namespace Core.Main.DataObjects.PTMagicData
public int RefreshSeconds { get; set; } = 30;
public int BagAnalyzerRefreshSeconds { get; set; } = 5;
public int BuyAnalyzerRefreshSeconds { get; set; } = 5;
+ public int MaxSalesRecords { get; set; } = 99999;
public int MaxTopMarkets { get; set; } = 20;
public int MaxDailySummaries { get; set; } = 10;
public int MaxMonthlySummaries { get; set; } = 10;
diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs
index df01a9a..ca04707 100644
--- a/Core/DataObjects/ProfitTrailerData.cs
+++ b/Core/DataObjects/ProfitTrailerData.cs
@@ -113,14 +113,19 @@ namespace Core.Main.DataObjects
bool exitLoop = false;
int pageIndex = 1;
- while (!exitLoop)
+ int maxPages = _systemConfiguration.GeneralSettings.Monitor.MaxSalesRecords;
+ int requestedPages = 0;
+
+ while (!exitLoop && requestedPages < maxPages)
{
- var sellDataPage = GetDataFromProfitTrailer("/api/v2/data/sales?perPage=5000&sort=SOLDDATE&sortDirection=ASCENDING&page=" + pageIndex);
+ var sellDataPage = GetDataFromProfitTrailer("/api/v2/data/sales?Page=1&perPage=1&sort=SOLDDATE&sortDirection=DESCENDING&page=" + pageIndex);
if (sellDataPage != null && sellDataPage.data.Count > 0)
{
// Add sales data page to collection
this.BuildSellLogData(sellDataPage);
pageIndex++;
+ requestedPages++;
+
}
else
{
@@ -130,7 +135,7 @@ namespace Core.Main.DataObjects
}
// Update sell log refresh time
- _sellLogRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds - 1);
+ _sellLogRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds -1);
}
}
}
diff --git a/Core/Main/PTMagic.cs b/Core/Main/PTMagic.cs
index 82460d6..9c6e1b3 100644
--- a/Core/Main/PTMagic.cs
+++ b/Core/Main/PTMagic.cs
@@ -721,14 +721,14 @@ namespace Core.Main
}
// Check for CurrencyConverterApi Key
- if (!this.PTMagicConfiguration.GeneralSettings.Application.FreeCurrencyConverterAPIKey.Equals(""))
- {
- this.Log.DoLogInfo("FreeCurrencyConverterApi KEY found");
- }
- else
- {
- this.Log.DoLogInfo("No FreeCurrencyConverterApi KEY specified. That's ok! But you can only use USD; apply for a key at: https://freecurrencyrates.com/en");
- }
+ //if (!this.PTMagicConfiguration.GeneralSettings.Application.FreeCurrencyConverterAPIKey.Equals(""))
+ //{
+ // this.Log.DoLogInfo("FreeCurrencyConverterApi KEY found");
+ //}
+ //else
+ //{
+ // this.Log.DoLogInfo("No FreeCurrencyConverterApi KEY specified. That's ok! But you can only use USD; apply for a key at: https://freecurrencyrates.com/en");
+ //}
}
catch (System.NullReferenceException)
{
@@ -1132,28 +1132,28 @@ namespace Core.Main
this.LastRuntimeSummary.MainFiatCurrency = this.LastMainFiatCurrency;
this.LastRuntimeSummary.MainFiatCurrencyExchangeRate = this.LastMainFiatCurrencyExchangeRate;
- if (this.LastFiatCurrencyCheck < DateTime.UtcNow.AddHours(-12) && !this.PTMagicConfiguration.GeneralSettings.Application.MainFiatCurrency.Equals("USD", StringComparison.InvariantCultureIgnoreCase))
- {
- try
- {
- this.LastRuntimeSummary.MainFiatCurrency = this.PTMagicConfiguration.GeneralSettings.Application.MainFiatCurrency;
- this.LastRuntimeSummary.MainFiatCurrencyExchangeRate = BaseAnalyzer.GetMainFiatCurrencyRate(this.PTMagicConfiguration.GeneralSettings.Application.MainFiatCurrency, this.PTMagicConfiguration.GeneralSettings.Application.FreeCurrencyConverterAPIKey, this.Log);
- this.LastMainFiatCurrency = this.LastRuntimeSummary.MainFiatCurrency;
- this.LastMainFiatCurrencyExchangeRate = this.LastRuntimeSummary.MainFiatCurrencyExchangeRate;
+ // if (this.LastFiatCurrencyCheck < DateTime.UtcNow.AddHours(-12) && !this.PTMagicConfiguration.GeneralSettings.Application.MainFiatCurrency.Equals("USD", StringComparison.InvariantCultureIgnoreCase))
+ // {
+ // try
+ // {
+ // this.LastRuntimeSummary.MainFiatCurrency = this.PTMagicConfiguration.GeneralSettings.Application.MainFiatCurrency;
+ // this.LastRuntimeSummary.MainFiatCurrencyExchangeRate = BaseAnalyzer.GetMainFiatCurrencyRate(this.PTMagicConfiguration.GeneralSettings.Application.MainFiatCurrency, this.PTMagicConfiguration.GeneralSettings.Application.FreeCurrencyConverterAPIKey, this.Log);
+ // this.LastMainFiatCurrency = this.LastRuntimeSummary.MainFiatCurrency;
+ // this.LastMainFiatCurrencyExchangeRate = this.LastRuntimeSummary.MainFiatCurrencyExchangeRate;
- this.LastFiatCurrencyCheck = DateTime.UtcNow;
- }
- catch (Exception ex)
- {
+ // this.LastFiatCurrencyCheck = DateTime.UtcNow;
+ // }
+ // catch (Exception ex)
+ // {
- // Fallback to USD in case something went wrong
- this.Log.DoLogError("Fixer.io exchange rate check error: " + ex.Message);
- this.LastRuntimeSummary.MainFiatCurrency = "USD";
- this.LastRuntimeSummary.MainFiatCurrencyExchangeRate = 1;
- this.LastMainFiatCurrency = "USD";
- this.LastMainFiatCurrencyExchangeRate = 1;
- }
- }
+ // // Fallback to USD in case something went wrong
+ // this.Log.DoLogError("Fixer.io exchange rate check error: " + ex.Message);
+ // this.LastRuntimeSummary.MainFiatCurrency = "USD";
+ // this.LastRuntimeSummary.MainFiatCurrencyExchangeRate = 1;
+ // this.LastMainFiatCurrency = "USD";
+ // this.LastMainFiatCurrencyExchangeRate = 1;
+ // }
+ // }
}
// Get current PT properties
diff --git a/Core/ProfitTrailer/StrategyHelper.cs b/Core/ProfitTrailer/StrategyHelper.cs
index cdd873b..1750c2e 100644
--- a/Core/ProfitTrailer/StrategyHelper.cs
+++ b/Core/ProfitTrailer/StrategyHelper.cs
@@ -437,7 +437,7 @@ namespace Core.ProfitTrailer
}
else
{
- strategyText += "FORM ";
+ strategyText += "";
}
}
else
diff --git a/Monitor/Pages/SalesAnalyzer.cshtml b/Monitor/Pages/SalesAnalyzer.cshtml
index f75c554..28240e1 100644
--- a/Monitor/Pages/SalesAnalyzer.cshtml
+++ b/Monitor/Pages/SalesAnalyzer.cshtml
@@ -25,7 +25,7 @@
totalCurrentValueString = Math.Round(Model.totalCurrentValue, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"));
}
}
-
+
diff --git a/Monitor/wwwroot/assets/css/style.css b/Monitor/wwwroot/assets/css/style.css
index a81c70b..6eb5cfe 100644
--- a/Monitor/wwwroot/assets/css/style.css
+++ b/Monitor/wwwroot/assets/css/style.css
@@ -639,7 +639,7 @@ a.text-dark:hover {
}
.bg-success {
- background-color: #81c868 !important;
+ background-color: #296a12 !important;
}
.bg-info {
@@ -647,11 +647,11 @@ a.text-dark:hover {
}
.bg-warning {
- background-color: #ffbd4a !important;
+ background-color: #563a09 !important;
}
.bg-danger {
- background-color: #f05050 !important;
+ background-color: #6e0e0e !important;
}
.bg-muted {
@@ -759,7 +759,7 @@ a.text-dark:hover {
}
.label-success {
- background-color: #81c868;
+ background-color: #3b5e2f;
}
.label-info {
@@ -767,11 +767,11 @@ a.text-dark:hover {
}
.label-warning {
- background-color: #ffbd4a;
+ background-color: #847f0a;
}
.label-danger {
- background-color: #f05050;
+ background-color: #601f1f;
}
.label-purple {
@@ -829,7 +829,7 @@ a.text-dark:hover {
}
.badge-success {
- background-color: #81c868;
+ background-color: #307516;
}
.badge-info {
@@ -837,11 +837,11 @@ a.text-dark:hover {
}
.badge-warning {
- background-color: #ffbd4a;
+ background-color: #6f5019;
}
.badge-danger {
- background-color: #f05050;
+ background-color: #6a1414;
}
.badge-purple {
diff --git a/PTMagic.sln b/PTMagic.sln
new file mode 100644
index 0000000..1f9a9e3
--- /dev/null
+++ b/PTMagic.sln
@@ -0,0 +1,37 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.5.002.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{DC985FA9-87CC-4C60-A587-E646E74A1A4A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monitor", "Monitor\Monitor.csproj", "{D967C466-E4BF-40A9-84FD-698079FAD3D5}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PTMagic", "PTMagic\PTMagic.csproj", "{D81F5541-438E-42C7-B6E7-B859875B18A8}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {DC985FA9-87CC-4C60-A587-E646E74A1A4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DC985FA9-87CC-4C60-A587-E646E74A1A4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DC985FA9-87CC-4C60-A587-E646E74A1A4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DC985FA9-87CC-4C60-A587-E646E74A1A4A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D967C466-E4BF-40A9-84FD-698079FAD3D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D967C466-E4BF-40A9-84FD-698079FAD3D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D967C466-E4BF-40A9-84FD-698079FAD3D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D967C466-E4BF-40A9-84FD-698079FAD3D5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D81F5541-438E-42C7-B6E7-B859875B18A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D81F5541-438E-42C7-B6E7-B859875B18A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D81F5541-438E-42C7-B6E7-B859875B18A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D81F5541-438E-42C7-B6E7-B859875B18A8}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {C3646F7E-91F6-4D66-9B1B-2B74317580A4}
+ EndGlobalSection
+EndGlobal
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 4f9bb22..beb9ffe 100644
--- a/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json
+++ b/PTMagic/_defaults/_default_settings_PT_2.x/settings.general.json
@@ -12,11 +12,11 @@
"Exchange": "Bittrex", // The exchange your are running Profit Trailer on
"StartBalance": 0, // The balance you had in your wallet when you started working with Profit Trailer
"TimezoneOffset": "+0:00", // Your timezone offset from UTC time
- "MainFiatCurrency": "USD", // Your main fiat currency that will be used in the monitor
+ //"MainFiatCurrency": "USD", // Your main fiat currency that will be used in the monitor
"FloodProtectionMinutes": 0, // If a price trend is just zig-zagging around its trigger, you may want to protect your settings from getting switched back and forth every minute
"InstanceName": "PT Magic", // The name of the instance of this bot. This will be used in your monitor and your Telegram messages. In case you are running more than one bot, you may set different names to separate them
"CoinMarketCapAPIKey": "", //CoinMarketCap Api
- "FreeCurrencyConverterAPIKey": "" // If "MainFiatCurrency" above is anything other than USD, you must obtain an API key from https://free.currencyconverterapi.com/free-api-key
+ //"FreeCurrencyConverterAPIKey": "" // If "MainFiatCurrency" above is anything other than USD, you must obtain an API key from https://free.currencyconverterapi.com/free-api-key
},
"Monitor": {
"IsPasswordProtected": true, // Defines if your monitor will be asking to setup a password on its first start
@@ -28,6 +28,7 @@
"GraphMaxTimeframeHours": 24, // This will enable you to define the timeframe that your graph for market trends covers
"RefreshSeconds": 30, // The refresh interval of your monitor main page
"LinkPlatform": "TradingView", // The platform to which the pair name will link if you click on it
+ "MaxSalesRecords": 99999, // The maximum number of sales records pulled from Profit Trailer. Changes require a Monitor Restart.
"MaxTopMarkets": 20, // The amount of top markets being shown in your Sales Analyzer
"MaxDailySummaries": 10, // The amount of "Last Days" being shown in your Sales Analyzer
"MaxMonthlySummaries": 10, // The amount of "Last Months" being shown in your Sales Analyzer
diff --git a/_Development/DevSettings/settings.general.json b/_Development/DevSettings/settings.general.json
index 4f9bb22..beb9ffe 100644
--- a/_Development/DevSettings/settings.general.json
+++ b/_Development/DevSettings/settings.general.json
@@ -12,11 +12,11 @@
"Exchange": "Bittrex", // The exchange your are running Profit Trailer on
"StartBalance": 0, // The balance you had in your wallet when you started working with Profit Trailer
"TimezoneOffset": "+0:00", // Your timezone offset from UTC time
- "MainFiatCurrency": "USD", // Your main fiat currency that will be used in the monitor
+ //"MainFiatCurrency": "USD", // Your main fiat currency that will be used in the monitor
"FloodProtectionMinutes": 0, // If a price trend is just zig-zagging around its trigger, you may want to protect your settings from getting switched back and forth every minute
"InstanceName": "PT Magic", // The name of the instance of this bot. This will be used in your monitor and your Telegram messages. In case you are running more than one bot, you may set different names to separate them
"CoinMarketCapAPIKey": "", //CoinMarketCap Api
- "FreeCurrencyConverterAPIKey": "" // If "MainFiatCurrency" above is anything other than USD, you must obtain an API key from https://free.currencyconverterapi.com/free-api-key
+ //"FreeCurrencyConverterAPIKey": "" // If "MainFiatCurrency" above is anything other than USD, you must obtain an API key from https://free.currencyconverterapi.com/free-api-key
},
"Monitor": {
"IsPasswordProtected": true, // Defines if your monitor will be asking to setup a password on its first start
@@ -28,6 +28,7 @@
"GraphMaxTimeframeHours": 24, // This will enable you to define the timeframe that your graph for market trends covers
"RefreshSeconds": 30, // The refresh interval of your monitor main page
"LinkPlatform": "TradingView", // The platform to which the pair name will link if you click on it
+ "MaxSalesRecords": 99999, // The maximum number of sales records pulled from Profit Trailer. Changes require a Monitor Restart.
"MaxTopMarkets": 20, // The amount of top markets being shown in your Sales Analyzer
"MaxDailySummaries": 10, // The amount of "Last Days" being shown in your Sales Analyzer
"MaxMonthlySummaries": 10, // The amount of "Last Months" being shown in your Sales Analyzer
From bde9b98f11da7c8eeb20d4cada92d9ccd1206cf2 Mon Sep 17 00:00:00 2001
From: HojouFotytu <36724681+HojouFotytu@users.noreply.github.com>
Date: Sat, 30 Dec 2023 14:46:45 +0900
Subject: [PATCH 02/14] Dashboard Bottom Sales Overview changes
---
Core/DataObjects/PTMagicData.cs | 25 +++
Core/DataObjects/ProfitTrailerData.cs | 177 +++++++++++--------
Monitor/Pages/_get/DashboardBottom.cshtml | 110 +++++++-----
Monitor/Pages/_get/DashboardBottom.cshtml.cs | 3 +
4 files changed, 195 insertions(+), 120 deletions(-)
diff --git a/Core/DataObjects/PTMagicData.cs b/Core/DataObjects/PTMagicData.cs
index fa6f69b..a7d6bde 100644
--- a/Core/DataObjects/PTMagicData.cs
+++ b/Core/DataObjects/PTMagicData.cs
@@ -431,6 +431,31 @@ namespace Core.Main.DataObjects.PTMagicData
public double TotalCost { get; set; }
public double SoldPrice { get; set; }
public double SoldValue { get; set; }
+ public double TotalSales { get; set; }
+ }
+
+ public class StatsData
+ {
+ public double SalesToday { get; set; }
+ public double ProfitToday { get; set; }
+ public double ProfitPercToday { get; set; }
+ public double SalesYesterday { get; set; }
+ public double ProfitYesterday { get; set; }
+ public double ProfitPercYesterday { get; set; }
+ public double SalesWeek { get; set; }
+ public double ProfitWeek { get; set; }
+ public double ProfitPercWeek { get; set; }
+ public double SalesMonth { get; set; }
+ public double ProfitMonth { get; set; }
+ public double ProfitPercMonth { get; set; }
+ public double TotalProfit { get; set; }
+ public double TotalSales { get; set; }
+ public double TotalProfitPerc { get; set; }
+ public double FundingToday { get; set; }
+ public double FundingYesterday { get; set; }
+ public double FundingWeek { get; set; }
+ public double FundingMonth { get; set; }
+ public double FundingTotal { get; set; }
}
public class PTStrategy
diff --git a/Core/DataObjects/ProfitTrailerData.cs b/Core/DataObjects/ProfitTrailerData.cs
index ca04707..10b8231 100644
--- a/Core/DataObjects/ProfitTrailerData.cs
+++ b/Core/DataObjects/ProfitTrailerData.cs
@@ -16,16 +16,22 @@ namespace Core.Main.DataObjects
{
private SummaryData _summary = null;
private Properties _properties = null;
+ private List _stats = null;
private List _sellLog = new List();
private List _dcaLog = new List();
private List _buyLog = new List();
private string _ptmBasePath = "";
private PTMagicConfiguration _systemConfiguration = null;
private TransactionData _transactionData = null;
- private DateTime _buyLogRefresh = DateTime.UtcNow, _sellLogRefresh = DateTime.UtcNow, _dcaLogRefresh = DateTime.UtcNow, _summaryRefresh = DateTime.UtcNow, _propertiesRefresh = DateTime.UtcNow;
- private volatile object _buyLock = new object(), _sellLock = new object(), _dcaLock = new object(), _summaryLock = new object(), _propertiesLock = new object();
+ private DateTime _statsRefresh = DateTime.UtcNow,_buyLogRefresh = DateTime.UtcNow, _sellLogRefresh = DateTime.UtcNow, _dcaLogRefresh = DateTime.UtcNow, _summaryRefresh = DateTime.UtcNow, _propertiesRefresh = DateTime.UtcNow;
+ private volatile object _statsLock = new object(),_buyLock = new object(), _sellLock = new object(), _dcaLock = new object(), _summaryLock = new object(), _propertiesLock = new object();
private TimeSpan? _offsetTimeSpan = null;
-
+
+ public void DoLog(string message)
+ {
+ // Implement your logging logic here
+ Console.WriteLine(message);
+ }
// Constructor
public ProfitTrailerData(PTMagicConfiguration systemConfiguration)
{
@@ -96,86 +102,82 @@ namespace Core.Main.DataObjects
return _properties;
}
}
+
+ public List Stats
+ {
+ get
+ {
+ if (_stats == null || DateTime.UtcNow > _statsRefresh)
+ {
+ lock (_statsLock)
+ {
+ if (_stats == null || DateTime.UtcNow > _statsRefresh)
+ {
+ dynamic statsDataJson = GetDataFromProfitTrailer("/api/v2/data/stats");
+ JObject statsDataJObject = statsDataJson as JObject;
+ JObject basicSection = (JObject)statsDataJObject["basic"];
+ _stats = new List { BuildStatsData(basicSection) };
+ _statsRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds - 1);
+ }
+ }
+ }
+ return _stats;
+ }
+ }
+
+
public List SellLog
{
get
{
+
if (_sellLog == null || (DateTime.UtcNow > _sellLogRefresh))
{
- lock (_sellLock)
- {
- // Thread double locking
- if (_sellLog == null || (DateTime.UtcNow > _sellLogRefresh))
+ lock (_sellLock)
{
- _sellLog.Clear();
-
- // Page through the sales data summarizing it.
- bool exitLoop = false;
- int pageIndex = 1;
-
- int maxPages = _systemConfiguration.GeneralSettings.Monitor.MaxSalesRecords;
- int requestedPages = 0;
-
- while (!exitLoop && requestedPages < maxPages)
+ // Thread double locking
+ if (_sellLog == null || (DateTime.UtcNow > _sellLogRefresh))
{
- var sellDataPage = GetDataFromProfitTrailer("/api/v2/data/sales?Page=1&perPage=1&sort=SOLDDATE&sortDirection=DESCENDING&page=" + pageIndex);
- if (sellDataPage != null && sellDataPage.data.Count > 0)
- {
- // Add sales data page to collection
- this.BuildSellLogData(sellDataPage);
- pageIndex++;
- requestedPages++;
+ _sellLog.Clear();
+
- }
- else
+ // Page through the sales data summarizing it.
+ bool exitLoop = false;
+ int pageIndex = 1;
+
+ // 1 record per page to allow user to set max records to retrieve
+ int maxPages = _systemConfiguration.GeneralSettings.Monitor.MaxSalesRecords;
+ int requestedPages = 0;
+
+ while (!exitLoop && requestedPages < maxPages)
{
- // All data retrieved
- exitLoop = true;
+ var sellDataPage = GetDataFromProfitTrailer("/api/v2/data/sales?Page=1&perPage=1&sort=SOLDDATE&sortDirection=DESCENDING&page=" + pageIndex);
+ if (sellDataPage != null && sellDataPage.data.Count > 0)
+ {
+ // Add sales data page to collection
+ this.BuildSellLogData(sellDataPage);
+ pageIndex++;
+ requestedPages++;
+ Console.WriteLine($"Importing sale: {pageIndex}");
+
+ }
+ else
+ {
+ // All data retrieved
+ exitLoop = true;
+ }
}
+
+ // Update sell log refresh time
+ _sellLogRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds -1);
}
-
- // Update sell log refresh time
- _sellLogRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds -1);
}
}
- }
-
return _sellLog;
}
}
- public List SellLogToday
- {
- get
- {
- return SellLog.FindAll(sl => sl.SoldDate.Date == LocalizedTime.DateTime.Date);
- }
- }
-
- public List SellLogYesterday
- {
- get
- {
- return SellLog.FindAll(sl => sl.SoldDate.Date == LocalizedTime.DateTime.AddDays(-1).Date);
- }
- }
-
- public List SellLogLast7Days
- {
- get
- {
- return SellLog.FindAll(sl => sl.SoldDate.Date >= LocalizedTime.DateTime.AddDays(-7).Date);
- }
- }
-
- public List SellLogLast30Days
- {
- get
- {
- return SellLog.FindAll(sl => sl.SoldDate.Date >= LocalizedTime.DateTime.AddDays(-30).Date);
- }
- }
-
+
public List DCALog
{
get
@@ -313,15 +315,18 @@ namespace Core.Main.DataObjects
response.Close();
- // Parse the JSON and build the data sets
+
if (!arrayReturned)
- {
- return JObject.Parse(rawBody);
- }
- else
- {
- return JArray.Parse(rawBody);
- }
+ {
+ return JObject.Parse(rawBody);
+ }
+ else
+ {
+ return JArray.Parse(rawBody);
+ }
+
+
+
}
private SummaryData BuildSummaryData(dynamic PTData)
@@ -349,6 +354,32 @@ namespace Core.Main.DataObjects
BaseUrl = PTProperties.baseUrl
};
}
+ private StatsData BuildStatsData(dynamic statsDataJson)
+ {
+ return new StatsData()
+ {
+ SalesToday = statsDataJson["totalSalesToday"],
+ ProfitToday = statsDataJson["totalProfitToday"],
+ ProfitPercToday = statsDataJson["totalProfitPercToday"],
+ SalesYesterday = statsDataJson["totalSalesYesterday"],
+ ProfitYesterday = statsDataJson["totalProfitYesterday"],
+ ProfitPercYesterday = statsDataJson["totalProfitPercYesterday"],
+ SalesWeek = statsDataJson["totalSalesWeek"],
+ ProfitWeek = statsDataJson["totalProfitWeek"],
+ ProfitPercWeek = statsDataJson["totalProfitPercWeek"],
+ SalesMonth = statsDataJson["totalSalesThisMonth"],
+ ProfitMonth = statsDataJson["totalProfitThisMonth"],
+ ProfitPercMonth = statsDataJson["totalProfitPercThisMonth"],
+ TotalProfit = statsDataJson["totalProfit"],
+ TotalSales = statsDataJson["totalSales"],
+ TotalProfitPerc = statsDataJson["totalProfitPerc"],
+ FundingToday = statsDataJson["totalFundingToday"],
+ FundingYesterday = statsDataJson["totalFundingYesterday"],
+ FundingWeek = statsDataJson["totalFundingWeek"],
+ FundingMonth = statsDataJson["totalFundingThisMonth"],
+ FundingTotal = statsDataJson["totalFunding"]
+ };
+ }
private void BuildSellLogData(dynamic rawSellLogData)
{
foreach (var rsld in rawSellLogData.data)
diff --git a/Monitor/Pages/_get/DashboardBottom.cshtml b/Monitor/Pages/_get/DashboardBottom.cshtml
index 823b6f6..d15c6d4 100644
--- a/Monitor/Pages/_get/DashboardBottom.cshtml
+++ b/Monitor/Pages/_get/DashboardBottom.cshtml
@@ -62,7 +62,7 @@