This commit is contained in:
@@ -94,7 +94,7 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -20,84 +20,83 @@ namespace AyaNova.Biz
|
||||
|
||||
//Returns the biz object class that corresponds to the type presented
|
||||
//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
|
||||
case AyaType.ServerJob:
|
||||
return new JobOperationsBiz(ct, userId, roles);
|
||||
case AyaType.TrialSeeder:
|
||||
return new TrialBiz(ct, userId, roles);
|
||||
case AyaType.Translation:
|
||||
return new TranslationBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.DataListView:
|
||||
return new DataListViewBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.FormCustom:
|
||||
return new FormCustomBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.Widget:
|
||||
return new WidgetBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
//CoreBizObject add here
|
||||
case AyaType.ServerJob:
|
||||
return new JobOperationsBiz(ct, userId, roles);
|
||||
case AyaType.TrialSeeder:
|
||||
return new TrialBiz(ct, userId, roles);
|
||||
case AyaType.Translation:
|
||||
return new TranslationBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.DataListView:
|
||||
return new DataListViewBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.FormCustom:
|
||||
return new FormCustomBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.Widget:
|
||||
return new WidgetBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
|
||||
case AyaType.Customer:
|
||||
return new CustomerBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.User:
|
||||
return new UserBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.Customer:
|
||||
return new CustomerBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.User:
|
||||
return new UserBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
|
||||
|
||||
case AyaType.Contract:
|
||||
return new ContractBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.HeadOffice:
|
||||
return new HeadOfficeBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.LoanUnit:
|
||||
return new LoanUnitBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.Part:
|
||||
return new PartBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.PM:
|
||||
return new PMBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.Contract:
|
||||
return new ContractBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.HeadOffice:
|
||||
return new HeadOfficeBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.LoanUnit:
|
||||
return new LoanUnitBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.Part:
|
||||
return new PartBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.PM:
|
||||
return new PMBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
|
||||
case AyaType.PMTemplate:
|
||||
return new PMTemplateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.PMTemplate:
|
||||
return new PMTemplateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
|
||||
case AyaType.Project:
|
||||
return new ProjectBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.PurchaseOrder:
|
||||
return new PurchaseOrderBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.Quote:
|
||||
return new QuoteBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.Project:
|
||||
return new ProjectBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.PurchaseOrder:
|
||||
return new PurchaseOrderBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.Quote:
|
||||
return new QuoteBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
|
||||
case AyaType.QuoteTemplate:
|
||||
return new QuoteTemplateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.QuoteTemplate:
|
||||
return new QuoteTemplateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
|
||||
case AyaType.Unit:
|
||||
return new UnitBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.UnitModel:
|
||||
return new UnitModelBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.Vendor:
|
||||
return new VendorBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
//--- WorkOrder
|
||||
case AyaType.WorkOrder:
|
||||
case AyaType.WorkOrderItem:
|
||||
case AyaType.WorkOrderItemExpense:
|
||||
case AyaType.WorkOrderItemLabor:
|
||||
case AyaType.WorkOrderItemLoan:
|
||||
case AyaType.WorkOrderItemPart:
|
||||
case AyaType.WorkOrderItemPartRequest:
|
||||
case AyaType.WorkOrderItemScheduledUser:
|
||||
case AyaType.WorkOrderItemTask:
|
||||
case AyaType.WorkOrderItemTravel:
|
||||
case AyaType.WorkOrderItemUnit:
|
||||
return new WorkOrderBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
//---
|
||||
case AyaType.WorkOrderTemplate:
|
||||
return new WorkOrderTemplateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.Unit:
|
||||
return new UnitBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.UnitModel:
|
||||
return new UnitModelBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
case AyaType.Vendor:
|
||||
return new VendorBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
//--- WorkOrder
|
||||
case AyaType.WorkOrder:
|
||||
case AyaType.WorkOrderItem:
|
||||
case AyaType.WorkOrderItemExpense:
|
||||
case AyaType.WorkOrderItemLabor:
|
||||
case AyaType.WorkOrderItemLoan:
|
||||
case AyaType.WorkOrderItemPart:
|
||||
case AyaType.WorkOrderItemPartRequest:
|
||||
case AyaType.WorkOrderItemScheduledUser:
|
||||
case AyaType.WorkOrderItemTask:
|
||||
case AyaType.WorkOrderItemTravel:
|
||||
case AyaType.WorkOrderItemUnit:
|
||||
return new WorkOrderBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
//---
|
||||
case AyaType.WorkOrderTemplate:
|
||||
return new WorkOrderTemplateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||
|
||||
default:
|
||||
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectFactory::GetBizObject type {ayaType.ToString()} is not supported");
|
||||
}
|
||||
default:
|
||||
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectFactory::GetBizObject type {ayaType.ToString()} is not supported");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -258,31 +258,33 @@ namespace AyaNova.Biz
|
||||
await LogJobAsync(job.GId, $"Process job \"{JobDescription}\"");
|
||||
log.LogDebug($"ProcessJobAsync -> Processing job {JobDescription}");
|
||||
IJobObject o = null;
|
||||
|
||||
switch (job.JobType)
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
case JobType.Backup:
|
||||
//This is called when on demand only, normal backups are processed above with normal system jobs
|
||||
await CoreJobBackup.DoWorkAsync(true);
|
||||
await UpdateJobStatusAsync(job.GId, JobStatus.Completed);
|
||||
break;
|
||||
case JobType.TestJob:
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.ServerJob);
|
||||
break;
|
||||
case JobType.SeedTestData:
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.TrialSeeder);
|
||||
break;
|
||||
case JobType.BulkCoreBizObjectOperation:
|
||||
//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
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(job.ObjectType);
|
||||
break;
|
||||
default:
|
||||
throw new System.NotSupportedException($"ProcessJobAsync type {job.JobType.ToString()} is not supported");
|
||||
}
|
||||
switch (job.JobType)
|
||||
{
|
||||
case JobType.Backup:
|
||||
//This is called when on demand only, normal backups are processed above with normal system jobs
|
||||
await CoreJobBackup.DoWorkAsync(true);
|
||||
await UpdateJobStatusAsync(job.GId, JobStatus.Completed);
|
||||
break;
|
||||
case JobType.TestJob:
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.ServerJob, ct);
|
||||
break;
|
||||
case JobType.SeedTestData:
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.TrialSeeder, ct);
|
||||
break;
|
||||
case JobType.BulkCoreBizObjectOperation:
|
||||
//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
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(job.ObjectType, ct);
|
||||
break;
|
||||
default:
|
||||
throw new System.NotSupportedException($"ProcessJobAsync type {job.JobType.ToString()} is not supported");
|
||||
}
|
||||
|
||||
if (o != null)
|
||||
await o.HandleJobAsync(job);
|
||||
if (o != null)
|
||||
await o.HandleJobAsync(job);
|
||||
}
|
||||
log.LogDebug($"ProcessJobAsync -> Job completed {JobDescription}");
|
||||
}
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace AyaNova.Biz
|
||||
#endregion dosearch
|
||||
|
||||
#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
|
||||
//https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE
|
||||
@@ -261,7 +261,7 @@ namespace AyaNova.Biz
|
||||
PhraseItems.ToArray();
|
||||
|
||||
//get text
|
||||
ISearchAbleObject o = (ISearchAbleObject)BizObjectFactory.GetBizObject(ayaType, userId, currentUserRoles);
|
||||
ISearchAbleObject o = (ISearchAbleObject)BizObjectFactory.GetBizObject(ayaType, ct, userId, currentUserRoles);
|
||||
|
||||
//get extract
|
||||
var searchParams = await o.GetSearchResultSummary(id);
|
||||
|
||||
Reference in New Issue
Block a user