Merge pull request #311 from djbadders/develop
Paged access to sales data for PT 2.5.x combability + bug fix
This commit is contained in:
commit
78132fafb6
|
@ -108,7 +108,28 @@ namespace Core.Main.DataObjects
|
|||
if (_sellLog == null || (DateTime.UtcNow > _sellLogRefresh))
|
||||
{
|
||||
_sellLog.Clear();
|
||||
this.BuildSellLogData(GetDataFromProfitTrailer("/api/v2/data/sales"));
|
||||
|
||||
// Page through the sales data summarizing it.
|
||||
bool exitLoop = false;
|
||||
int pageIndex = 1;
|
||||
|
||||
while (!exitLoop)
|
||||
{
|
||||
var sellDataPage = GetDataFromProfitTrailer("/api/v2/data/sales?perPage=5000&sort=SOLDDATE&sortDirection=ASCENDING&page=" + pageIndex);
|
||||
if (sellDataPage != null && sellDataPage.data.Count > 0)
|
||||
{
|
||||
// Add sales data page to collection
|
||||
this.BuildSellLogData(sellDataPage);
|
||||
pageIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// All data retrieved
|
||||
exitLoop = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Update sell log refresh time
|
||||
_sellLogRefresh = DateTime.UtcNow.AddSeconds(_systemConfiguration.GeneralSettings.Monitor.RefreshSeconds - 1);
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +286,10 @@ namespace Core.Main.DataObjects
|
|||
private dynamic GetDataFromProfitTrailer(string callPath, bool arrayReturned = false)
|
||||
{
|
||||
string rawBody = "";
|
||||
string url = string.Format("{0}{1}?token={2}", _systemConfiguration.GeneralSettings.Application.ProfitTrailerMonitorURL, callPath, _systemConfiguration.GeneralSettings.Application.ProfitTrailerServerAPIToken);
|
||||
string url = string.Format("{0}{1}{2}token={3}", _systemConfiguration.GeneralSettings.Application.ProfitTrailerMonitorURL,
|
||||
callPath,
|
||||
callPath.Contains("?") ? "&" : "?",
|
||||
_systemConfiguration.GeneralSettings.Application.ProfitTrailerServerAPIToken);
|
||||
|
||||
// Get the data from PT
|
||||
Debug.WriteLine(String.Format("{0} - Calling '{1}'", DateTime.UtcNow, url));
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
@ -79,7 +80,23 @@ namespace Monitor._Internal
|
|||
IServiceProvider logProvider = ServiceHelper.BuildLoggerService(PTMagicBasePath);
|
||||
Log = logProvider.GetRequiredService<LogHelper>();
|
||||
|
||||
bool exitLoop = false;
|
||||
|
||||
while (!exitLoop)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Try to read the current runtime summary, but may be being written, so retry if necessary.
|
||||
Summary = JsonConvert.DeserializeObject<Summary>(System.IO.File.ReadAllText(PTMagicBasePath + Constants.PTMagicPathData + Path.DirectorySeparatorChar + "LastRuntimeSummary.json"));
|
||||
exitLoop = true;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Squash exception and try again, as file was locked.
|
||||
Thread.Sleep(250);
|
||||
}
|
||||
}
|
||||
|
||||
if (Summary.CurrentGlobalSetting == null) Summary.CurrentGlobalSetting = PTMagicConfiguration.AnalyzerSettings.GlobalSettings.Find(s => s.SettingName.IndexOf("default", StringComparison.InvariantCultureIgnoreCase) > -1);
|
||||
|
||||
MainFiatCurrencySymbol = SystemHelper.GetCurrencySymbol(Summary.MainFiatCurrency);
|
||||
|
|
Loading…
Reference in New Issue