This commit is contained in:
2021-11-19 19:16:37 +00:00
parent fa856a33d1
commit 48a067bb5e

View File

@@ -346,7 +346,7 @@ namespace AyaNova.Biz
//REPORT DATA
//Data fetched to return to report designer for Client report design usage
public async Task<Newtonsoft.Json.Linq.JArray> GetReportData(DataListSelectedRequest selectedRequest)
public async Task<Newtonsoft.Json.Linq.JArray> GetReportData(DataListSelectedRequest selectedRequest, bool requestIsCustomerWorkOrderReport = false)
{
var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::GetReportData");
AuthorizationRoles effectiveRoles = CurrentUserRoles;
@@ -357,7 +357,7 @@ namespace AyaNova.Biz
return null;
}
if (!AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, selectedRequest.AType))
if (!requestIsCustomerWorkOrderReport && !AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(effectiveRoles, selectedRequest.AType))
{
AddError(ApiErrorCode.NOT_AUTHORIZED, null, $"User not authorized for {selectedRequest.AType} type object");
return null;
@@ -385,16 +385,16 @@ namespace AyaNova.Biz
var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::RenderReport");
//Customer User Report?
bool RequestIsCustomerWorkOrderReport=false;
bool RequestIsCustomerWorkOrderReport = false;
if (reportRequest.ReportId == -100)
{
//get the user and workorder data and set the actual report id or return null if not found
var woTags = await ct.WorkOrder.AsNoTracking().Where(x => x.Id == reportRequest.SelectedRowIds[0]).Select(x => x.Tags).FirstOrDefaultAsync();
if(woTags==null) return null;
if (woTags == null) return null;
var cr = await UserBiz.CustomerUserEffectiveRightsAsync(UserId, woTags);
if(cr.ThisWOEffectiveWOReportId==null) return null;
reportRequest.ReportId=(long)cr.ThisWOEffectiveWOReportId;
RequestIsCustomerWorkOrderReport=true;
if (cr.ThisWOEffectiveWOReportId == null) return null;
reportRequest.ReportId = (long)cr.ThisWOEffectiveWOReportId;
RequestIsCustomerWorkOrderReport = true;
}
//get report, vet security, see what we need before init in case of issue
@@ -436,7 +436,7 @@ namespace AyaNova.Biz
reportRequest.IncludeWoItemDescendants = report.IncludeWoItemDescendants;
//Get data
var ReportData = await GetReportData(reportRequest);//###### TODO: SLOW NEEDS TIMEOUT HERE ONCE IT WORKS IS SUPPORTED
var ReportData = await GetReportData(reportRequest, RequestIsCustomerWorkOrderReport);//###### TODO: SLOW NEEDS TIMEOUT HERE ONCE IT WORKS IS SUPPORTED
//if GetReportData errored then will return null so need to return that as well here
if (ReportData == null)
{