This commit is contained in:
2023-04-21 18:01:43 +00:00
parent 7cc59e329a
commit a296bc9b4f
2 changed files with 31 additions and 11 deletions

View File

@@ -590,23 +590,23 @@ namespace Sockeye.Biz
//Add Handlebars JS for compiling and presenting
//https://handlebarsjs.com/
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "sock-hb.js") });
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-hb.js") });
//add Marked for markdown processing
//https://github.com/markedjs/marked
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "sock-md.js") });
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-md.js") });
//add DOM Purify for markdown template sanitization processing
//https://github.com/cure53/DOMPurify
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "sock-pf.js") });
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-pf.js") });
//add Bar code library if our bar code helper is referenced
//https://github.com/metafloor/bwip-js
if (report.Template.Contains("ayBC ") || report.JsHelpers.Contains("ayBC "))
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "sock-bc.js") });
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-bc.js") });
//add stock helpers
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "sock-report.js") });
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-report.js") });
//execute to add to handlebars
await page.EvaluateExpressionAsync("ayRegisterHelpers();");

View File

@@ -66,11 +66,12 @@ namespace Sockeye.Biz
////////////////////////////////////////////////////////////////////////////////////////////////
//GET
//
internal async Task<Subscription> GetAsync(long id, bool logTheGetEvent = true, bool populateForReporting = false)
internal async Task<Subscription> GetAsync(long id, bool logTheGetEvent = true)
{
var ret = await ct.Subscription.Include(z => z.Items.OrderByDescending(x=>x.Active).ThenBy(x => x.ExpireDate)).AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
var ret = await ct.Subscription.Include(z => z.Items.OrderByDescending(x => x.Active).ThenBy(x => x.ExpireDate)).AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
if (logTheGetEvent && ret != null)
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, SockEvent.Retrieved), ct);
await PopulateVizFields(ret);
return ret;
}
@@ -236,6 +237,20 @@ namespace Sockeye.Biz
await Task.CompletedTask;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//
//
//
internal async Task<Subscription> SubscriptionGetForReportingAsync(SockType sType, long id)
{
//if it's the entire workorder just get, populate and return as normal
if (sType == SockType.Subscription)
return await GetAsync(id, false);
var subId = await ct.SubscriptionItem.AsNoTracking().Where(z => z.Id == id).Select(z => z.SubscriptionId).FirstOrDefaultAsync();
return await GetAsync(subId, false);
}
////////////////////////////////////////////////////////////////////////////////////////////////
//REPORTING
@@ -244,13 +259,19 @@ namespace Sockeye.Biz
{
var idList = dataListSelectedRequest.SelectedRowIds;
JArray ReportData = new JArray();
List<Subscription> batchResults = new List<Subscription>();
while (idList.Any())
{
if (!ReportRenderManager.KeepGoing(jobId)) return null;
var batch = idList.Take(IReportAbleObject.REPORT_DATA_BATCH_SIZE);
idList = idList.Skip(IReportAbleObject.REPORT_DATA_BATCH_SIZE).ToArray();
//query for this batch, comes back in db natural order unfortunately
var batchResults = await ct.Subscription.AsNoTracking().Where(z => batch.Contains(z.Id)).ToArrayAsync();
batchResults.Clear();
foreach (long batchId in batch)
{
if (!ReportRenderManager.KeepGoing(jobId)) return null;
batchResults.Add(await SubscriptionGetForReportingAsync(dataListSelectedRequest.SockType, batchId));
}
//order the results back into original
//What is happening here:
@@ -265,7 +286,6 @@ namespace Sockeye.Biz
foreach (Subscription w in orderedList)
{
if (!ReportRenderManager.KeepGoing(jobId)) return null;
await PopulateVizFields(w);
var jo = JObject.FromObject(w);
if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"]))
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);