This commit is contained in:
@@ -295,6 +295,12 @@ namespace AyaNova.Biz
|
||||
await CoreIntegrationLogSweeper.DoWorkAsync();
|
||||
if (!KeepOnWorking()) return;
|
||||
|
||||
#if !SUBSCRIPTION_BUILD
|
||||
//CHECK IF NEW VERSION AVAILABLE
|
||||
//this will alert users on login for perpetual server instances
|
||||
await CoreJobVersionCheck.DoWorkAsync();
|
||||
#endif
|
||||
|
||||
|
||||
log.LogTrace("Processing exclusive dynamic jobs");
|
||||
|
||||
@@ -374,58 +380,61 @@ namespace AyaNova.Biz
|
||||
/// <returns></returns>
|
||||
internal static async Task ProcessJobAsync(OpsJob job)
|
||||
{
|
||||
|
||||
|
||||
var JobDescription = $"{job.Name} - {job.JobType.ToString()}";
|
||||
if (job.SubType != JobSubType.NotSet)
|
||||
JobDescription += $":{job.SubType}";
|
||||
await LogJobAsync(job.GId, $"LT:ProcessingJob \"{JobDescription}\"");
|
||||
log.LogDebug($"ProcessJobAsync -> Processing job {JobDescription}");
|
||||
IJobObject o = null;
|
||||
try{
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
try
|
||||
{
|
||||
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, ct, 1, AuthorizationRoles.BizAdmin);
|
||||
break;
|
||||
case JobType.SeedTestData:
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.TrialSeeder, ct, 1, AuthorizationRoles.BizAdmin);
|
||||
break;
|
||||
case JobType.AttachmentMaintenance:
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.FileAttachment, ct, 1, AuthorizationRoles.BizAdmin);
|
||||
break;
|
||||
case JobType.BatchCoreObjectOperation:
|
||||
//batch 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
|
||||
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, 1, AuthorizationRoles.BizAdmin);
|
||||
break;
|
||||
case JobType.SeedTestData:
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.TrialSeeder, ct, 1, AuthorizationRoles.BizAdmin);
|
||||
break;
|
||||
case JobType.AttachmentMaintenance:
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.FileAttachment, ct, 1, AuthorizationRoles.BizAdmin);
|
||||
break;
|
||||
case JobType.BatchCoreObjectOperation:
|
||||
//batch 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
|
||||
|
||||
//case 4357
|
||||
var tempObject=BizObjectFactory.GetBizObject(job.AType, ct, 1, AuthorizationRoles.BizAdmin);
|
||||
if(! (tempObject is IJobObject)){
|
||||
throw new System.NotSupportedException($"ProcessJobAsync type {job.JobType.ToString()} is not supported for Batch operations");
|
||||
}
|
||||
o = (IJobObject)tempObject;
|
||||
break;
|
||||
case JobType.RenderReport:
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.Report, ct, 1, AuthorizationRoles.BizAdmin);
|
||||
break;
|
||||
default:
|
||||
throw new System.NotSupportedException($"ProcessJobAsync type {job.JobType.ToString()} is not supported");
|
||||
//case 4357
|
||||
var tempObject = BizObjectFactory.GetBizObject(job.AType, ct, 1, AuthorizationRoles.BizAdmin);
|
||||
if (!(tempObject is IJobObject))
|
||||
{
|
||||
throw new System.NotSupportedException($"ProcessJobAsync type {job.JobType.ToString()} is not supported for Batch operations");
|
||||
}
|
||||
o = (IJobObject)tempObject;
|
||||
break;
|
||||
case JobType.RenderReport:
|
||||
o = (IJobObject)BizObjectFactory.GetBizObject(AyaType.Report, ct, 1, AuthorizationRoles.BizAdmin);
|
||||
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}");
|
||||
}
|
||||
log.LogDebug($"ProcessJobAsync -> Job completed {JobDescription}");
|
||||
}
|
||||
catch(Exception ex){
|
||||
catch (Exception ex)
|
||||
{
|
||||
await LogJobAsync(job.GId, $"LT:BatchJob \"{JobDescription}\" - LT:Failed ");
|
||||
log.LogError(ex,$"ProcessJobAsync -> job failed {JobDescription}");
|
||||
log.LogError(ex, $"ProcessJobAsync -> job failed {JobDescription}");
|
||||
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Failed);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user