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 //REPORT DATA
//Data fetched to return to report designer for Client report design usage //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"); var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::GetReportData");
AuthorizationRoles effectiveRoles = CurrentUserRoles; AuthorizationRoles effectiveRoles = CurrentUserRoles;
@@ -357,7 +357,7 @@ namespace AyaNova.Biz
return null; 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"); AddError(ApiErrorCode.NOT_AUTHORIZED, null, $"User not authorized for {selectedRequest.AType} type object");
return null; return null;
@@ -385,16 +385,16 @@ namespace AyaNova.Biz
var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::RenderReport"); var log = AyaNova.Util.ApplicationLogging.CreateLogger("ReportBiz::RenderReport");
//Customer User Report? //Customer User Report?
bool RequestIsCustomerWorkOrderReport=false; bool RequestIsCustomerWorkOrderReport = false;
if (reportRequest.ReportId == -100) if (reportRequest.ReportId == -100)
{ {
//get the user and workorder data and set the actual report id or return null if not found //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(); 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); var cr = await UserBiz.CustomerUserEffectiveRightsAsync(UserId, woTags);
if(cr.ThisWOEffectiveWOReportId==null) return null; if (cr.ThisWOEffectiveWOReportId == null) return null;
reportRequest.ReportId=(long)cr.ThisWOEffectiveWOReportId; reportRequest.ReportId = (long)cr.ThisWOEffectiveWOReportId;
RequestIsCustomerWorkOrderReport=true; RequestIsCustomerWorkOrderReport = true;
} }
//get report, vet security, see what we need before init in case of issue //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; reportRequest.IncludeWoItemDescendants = report.IncludeWoItemDescendants;
//Get data //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 GetReportData errored then will return null so need to return that as well here
if (ReportData == null) if (ReportData == null)
{ {