This commit is contained in:
2020-06-05 21:19:59 +00:00
parent 4115688ffd
commit f1fe350af9
4 changed files with 93 additions and 92 deletions

View File

@@ -94,7 +94,7 @@ namespace AyaNova.Api.Controllers
} }
var res = await Search.GetInfoAsync(UserTranslationIdFromContext.Id(HttpContext.Items), var res = await Search.GetInfoAsync(UserTranslationIdFromContext.Id(HttpContext.Items),
UserRolesFromContext.Roles(HttpContext.Items), UserIdFromContext.Id(HttpContext.Items), phrase, max, ayaType, id); UserRolesFromContext.Roles(HttpContext.Items), UserIdFromContext.Id(HttpContext.Items), phrase, max, ayaType, id, ct);
return Ok(ApiOkResponse.Response(res)); return Ok(ApiOkResponse.Response(res));
} }

View File

@@ -20,10 +20,9 @@ namespace AyaNova.Biz
//Returns the biz object class that corresponds to the type presented //Returns the biz object class that corresponds to the type presented
//Used by SEARCH and objects with JOBS //Used by SEARCH and objects with JOBS
internal static BizObject GetBizObject(AyaType ayaType, long userId = 1, AuthorizationRoles roles = AuthorizationRoles.All) internal static BizObject GetBizObject(AyaType ayaType, AyContext ct, long userId = 1, AuthorizationRoles roles = AuthorizationRoles.All)
{
using (AyContext ct = ServiceProviderProvider.DBContext)
{ {
switch (ayaType) switch (ayaType)
{ {
//CoreBizObject add here //CoreBizObject add here
@@ -96,7 +95,7 @@ namespace AyaNova.Biz
default: default:
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectFactory::GetBizObject type {ayaType.ToString()} is not supported"); throw new System.NotSupportedException($"AyaNova.BLL.BizObjectFactory::GetBizObject type {ayaType.ToString()} is not supported");
} }
}
} }

View File

@@ -258,7 +258,8 @@ namespace AyaNova.Biz
await LogJobAsync(job.GId, $"Process job \"{JobDescription}\""); await LogJobAsync(job.GId, $"Process job \"{JobDescription}\"");
log.LogDebug($"ProcessJobAsync -> Processing job {JobDescription}"); log.LogDebug($"ProcessJobAsync -> Processing job {JobDescription}");
IJobObject o = null; IJobObject o = null;
using (AyContext ct = ServiceProviderProvider.DBContext)
{
switch (job.JobType) switch (job.JobType)
{ {
case JobType.Backup: case JobType.Backup:
@@ -267,15 +268,15 @@ namespace AyaNova.Biz
await UpdateJobStatusAsync(job.GId, JobStatus.Completed); await UpdateJobStatusAsync(job.GId, JobStatus.Completed);
break; break;
case JobType.TestJob: case JobType.TestJob:
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.ServerJob); o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.ServerJob, ct);
break; break;
case JobType.SeedTestData: case JobType.SeedTestData:
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.TrialSeeder); o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.TrialSeeder, ct);
break; break;
case JobType.BulkCoreBizObjectOperation: case JobType.BulkCoreBizObjectOperation:
//bulk op, hand off to biz object to deal with //bulk op, hand off to biz object to deal with
//note, convention is that there is an idList in job.jobinfo json if preselected else it's all objects of type //note, convention is that there is an idList in job.jobinfo json if preselected else it's all objects of type
o = (IJobObject)BizObjectFactory.GetBizObject(job.ObjectType); o = (IJobObject)BizObjectFactory.GetBizObject(job.ObjectType, ct);
break; break;
default: default:
throw new System.NotSupportedException($"ProcessJobAsync type {job.JobType.ToString()} is not supported"); throw new System.NotSupportedException($"ProcessJobAsync type {job.JobType.ToString()} is not supported");
@@ -283,6 +284,7 @@ namespace AyaNova.Biz
if (o != null) if (o != null)
await o.HandleJobAsync(job); await o.HandleJobAsync(job);
}
log.LogDebug($"ProcessJobAsync -> Job completed {JobDescription}"); log.LogDebug($"ProcessJobAsync -> Job completed {JobDescription}");
} }

View File

@@ -246,7 +246,7 @@ namespace AyaNova.Biz
#endregion dosearch #endregion dosearch
#region Get info (excerpt) #region Get info (excerpt)
public static async Task<string> GetInfoAsync(long translationId, AuthorizationRoles currentUserRoles, long userId, string phrase, int max, AyaType ayaType, long id) public static async Task<string> GetInfoAsync(long translationId, AuthorizationRoles currentUserRoles, long userId, string phrase, int max, AyaType ayaType, long id, AyContext ct)
{ {
//escape literal percentage signs first just in case they are searching for 50% off or something //escape literal percentage signs first just in case they are searching for 50% off or something
//https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE //https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE
@@ -261,7 +261,7 @@ namespace AyaNova.Biz
PhraseItems.ToArray(); PhraseItems.ToArray();
//get text //get text
ISearchAbleObject o = (ISearchAbleObject)BizObjectFactory.GetBizObject(ayaType, userId, currentUserRoles); ISearchAbleObject o = (ISearchAbleObject)BizObjectFactory.GetBizObject(ayaType, ct, userId, currentUserRoles);
//get extract //get extract
var searchParams = await o.GetSearchResultSummary(id); var searchParams = await o.GetSearchResultSummary(id);