This commit is contained in:
@@ -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"]);
|
||||
|
||||
Reference in New Issue
Block a user