This commit is contained in:
@@ -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));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,84 +20,83 @@ 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
|
||||||
{
|
case AyaType.ServerJob:
|
||||||
//CoreBizObject add here
|
return new JobOperationsBiz(ct, userId, roles);
|
||||||
case AyaType.ServerJob:
|
case AyaType.TrialSeeder:
|
||||||
return new JobOperationsBiz(ct, userId, roles);
|
return new TrialBiz(ct, userId, roles);
|
||||||
case AyaType.TrialSeeder:
|
case AyaType.Translation:
|
||||||
return new TrialBiz(ct, userId, roles);
|
return new TranslationBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.Translation:
|
case AyaType.DataListView:
|
||||||
return new TranslationBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new DataListViewBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.DataListView:
|
case AyaType.FormCustom:
|
||||||
return new DataListViewBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new FormCustomBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.FormCustom:
|
case AyaType.Widget:
|
||||||
return new FormCustomBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new WidgetBiz(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:
|
case AyaType.Customer:
|
||||||
return new CustomerBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new CustomerBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.User:
|
case AyaType.User:
|
||||||
return new UserBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new UserBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
|
|
||||||
|
|
||||||
case AyaType.Contract:
|
case AyaType.Contract:
|
||||||
return new ContractBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new ContractBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.HeadOffice:
|
case AyaType.HeadOffice:
|
||||||
return new HeadOfficeBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new HeadOfficeBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.LoanUnit:
|
case AyaType.LoanUnit:
|
||||||
return new LoanUnitBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new LoanUnitBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.Part:
|
case AyaType.Part:
|
||||||
return new PartBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new PartBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.PM:
|
case AyaType.PM:
|
||||||
return new PMBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new PMBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
|
|
||||||
case AyaType.PMTemplate:
|
case AyaType.PMTemplate:
|
||||||
return new PMTemplateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new PMTemplateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
|
|
||||||
case AyaType.Project:
|
case AyaType.Project:
|
||||||
return new ProjectBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new ProjectBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.PurchaseOrder:
|
case AyaType.PurchaseOrder:
|
||||||
return new PurchaseOrderBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new PurchaseOrderBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.Quote:
|
case AyaType.Quote:
|
||||||
return new QuoteBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new QuoteBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
|
|
||||||
case AyaType.QuoteTemplate:
|
case AyaType.QuoteTemplate:
|
||||||
return new QuoteTemplateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new QuoteTemplateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
|
|
||||||
case AyaType.Unit:
|
case AyaType.Unit:
|
||||||
return new UnitBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new UnitBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.UnitModel:
|
case AyaType.UnitModel:
|
||||||
return new UnitModelBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new UnitModelBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.Vendor:
|
case AyaType.Vendor:
|
||||||
return new VendorBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new VendorBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
//--- WorkOrder
|
//--- WorkOrder
|
||||||
case AyaType.WorkOrder:
|
case AyaType.WorkOrder:
|
||||||
case AyaType.WorkOrderItem:
|
case AyaType.WorkOrderItem:
|
||||||
case AyaType.WorkOrderItemExpense:
|
case AyaType.WorkOrderItemExpense:
|
||||||
case AyaType.WorkOrderItemLabor:
|
case AyaType.WorkOrderItemLabor:
|
||||||
case AyaType.WorkOrderItemLoan:
|
case AyaType.WorkOrderItemLoan:
|
||||||
case AyaType.WorkOrderItemPart:
|
case AyaType.WorkOrderItemPart:
|
||||||
case AyaType.WorkOrderItemPartRequest:
|
case AyaType.WorkOrderItemPartRequest:
|
||||||
case AyaType.WorkOrderItemScheduledUser:
|
case AyaType.WorkOrderItemScheduledUser:
|
||||||
case AyaType.WorkOrderItemTask:
|
case AyaType.WorkOrderItemTask:
|
||||||
case AyaType.WorkOrderItemTravel:
|
case AyaType.WorkOrderItemTravel:
|
||||||
case AyaType.WorkOrderItemUnit:
|
case AyaType.WorkOrderItemUnit:
|
||||||
return new WorkOrderBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new WorkOrderBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
//---
|
//---
|
||||||
case AyaType.WorkOrderTemplate:
|
case AyaType.WorkOrderTemplate:
|
||||||
return new WorkOrderTemplateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new WorkOrderTemplateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
|
|
||||||
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");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -258,31 +258,33 @@ 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)
|
|
||||||
{
|
{
|
||||||
case JobType.Backup:
|
switch (job.JobType)
|
||||||
//This is called when on demand only, normal backups are processed above with normal system jobs
|
{
|
||||||
await CoreJobBackup.DoWorkAsync(true);
|
case JobType.Backup:
|
||||||
await UpdateJobStatusAsync(job.GId, JobStatus.Completed);
|
//This is called when on demand only, normal backups are processed above with normal system jobs
|
||||||
break;
|
await CoreJobBackup.DoWorkAsync(true);
|
||||||
case JobType.TestJob:
|
await UpdateJobStatusAsync(job.GId, JobStatus.Completed);
|
||||||
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.ServerJob);
|
break;
|
||||||
break;
|
case JobType.TestJob:
|
||||||
case JobType.SeedTestData:
|
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.ServerJob, ct);
|
||||||
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.TrialSeeder);
|
break;
|
||||||
break;
|
case JobType.SeedTestData:
|
||||||
case JobType.BulkCoreBizObjectOperation:
|
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.TrialSeeder, ct);
|
||||||
//bulk op, hand off to biz object to deal with
|
break;
|
||||||
//note, convention is that there is an idList in job.jobinfo json if preselected else it's all objects of type
|
case JobType.BulkCoreBizObjectOperation:
|
||||||
o = (IJobObject)BizObjectFactory.GetBizObject(job.ObjectType);
|
//bulk op, hand off to biz object to deal with
|
||||||
break;
|
//note, convention is that there is an idList in job.jobinfo json if preselected else it's all objects of type
|
||||||
default:
|
o = (IJobObject)BizObjectFactory.GetBizObject(job.ObjectType, ct);
|
||||||
throw new System.NotSupportedException($"ProcessJobAsync type {job.JobType.ToString()} is not supported");
|
break;
|
||||||
}
|
default:
|
||||||
|
throw new System.NotSupportedException($"ProcessJobAsync type {job.JobType.ToString()} is not supported");
|
||||||
|
}
|
||||||
|
|
||||||
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}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user