case 4568

This commit is contained in:
2024-01-25 23:03:23 +00:00
parent 2906cde6bc
commit ddc6258411
2 changed files with 37 additions and 3 deletions

View File

@@ -310,9 +310,24 @@ namespace AyaNova.Biz
if (selectedRequest.SelectedRowIds.Length == 0)
selectedRequest.SelectedRowIds = await DataListSelectedProcessingOptions.RehydrateIdList(selectedRequest, ct, effectiveRoles, log, UserId, UserTranslationId);
//case 4568 get translation id ultimately without failing so as to not affect any existing callers that this might not work with
long RequestorUserTranslationId = UserTranslationId;
try
{
JToken clientMeta = ((DataListReportRequest)selectedRequest).ClientMeta;
if (clientMeta["UserId"] != null)
{
RequestorUserTranslationId = await ct.User.AsNoTracking().Where(a => a.Id == clientMeta["UserId"].ToObject<long>()).Select(m => m.UserOptions.TranslationId).FirstAsync();//m => new { roles = m.Roles, name = m.Name, m.UserType, id = m.Id, translationId = m.UserOptions.TranslationId, currentAuthToken = m.CurrentAuthToken }).FirstAsync();
}
}
catch (Exception exx)
{
log.LogDebug(exx, $"Failed to get RequestionUserTranslationId from ClientMeta");
};
log.LogDebug($"Instantiating biz object handler for {selectedRequest.AType}");
var biz = BizObjectFactory.GetBizObject(selectedRequest.AType, ct, UserId, CurrentUserRoles, UserTranslationId);
var biz = BizObjectFactory.GetBizObject(selectedRequest.AType, ct, UserId, CurrentUserRoles, RequestorUserTranslationId);
log.LogDebug($"Fetching data for {selectedRequest.SelectedRowIds.Length} {selectedRequest.AType} items");
return await ((IReportAbleObject)biz).GetReportData(selectedRequest, Guid.Empty);//Guid.empty signifies it's not a job calling it
}
@@ -342,8 +357,25 @@ namespace AyaNova.Biz
if (!ReportRenderManager.KeepGoing(jobId))
return null;
//case 4568 get translation id ultimately without failing so as to not affect any existing callers that this might not work with
long RequestorUserTranslationId = UserTranslationId;
try
{
JToken clientMeta = ((DataListReportRequest)selectedRequest).ClientMeta;
if (clientMeta["UserId"] != null)
{
RequestorUserTranslationId = await ct.User.AsNoTracking().Where(a => a.Id == clientMeta["UserId"].ToObject<long>()).Select(m => m.UserOptions.TranslationId).FirstAsync();//m => new { roles = m.Roles, name = m.Name, m.UserType, id = m.Id, translationId = m.UserOptions.TranslationId, currentAuthToken = m.CurrentAuthToken }).FirstAsync();
}
}
catch (Exception exx)
{
log.LogDebug(exx, $"Failed to get RequestionUserTranslationId from ClientMeta");
};
log.LogDebug($"Instantiating biz object handler for {selectedRequest.AType}");
var biz = BizObjectFactory.GetBizObject(selectedRequest.AType, ct, UserId, CurrentUserRoles, UserTranslationId);
var biz = BizObjectFactory.GetBizObject(selectedRequest.AType, ct, UserId, CurrentUserRoles, RequestorUserTranslationId);
log.LogDebug($"Fetching data for {selectedRequest.SelectedRowIds.Length} {selectedRequest.AType} items");
return await ((IReportAbleObject)biz).GetReportData(selectedRequest, jobId);
}