This commit is contained in:
2022-09-27 23:06:28 +00:00
parent 1d706b4bb7
commit 153978785c
9 changed files with 142 additions and 7 deletions

View File

@@ -73,6 +73,16 @@ namespace AyaNova.Biz
}
}
/// <summary>
/// Request the cancellation of a job, not all jobs honour this
/// </summary>
/// <param name="jobId"></param>
internal static async Task RequestCancelAsync(Guid jobId)
{
await UpdateJobStatusAsync(jobId, JobStatus.CancelRequested);
await LogJobAsync(jobId, "LT:Cancel");
}
/// <summary>
/// Remove the job and it's logs
@@ -152,6 +162,37 @@ namespace AyaNova.Biz
return o.JobStatus;
}
}
/// <summary>
/// Update the progress of a job
/// </summary>
/// <param name="jobId"></param>
/// <param name="progress"></param>
internal static async Task UpdateJobProgressAsync(Guid jobId, string progress)
{
using (AyContext ct = ServiceProviderProvider.DBContext)
{
var oFromDb = await ct.OpsJob.SingleOrDefaultAsync(z => z.GId == jobId);
if (oFromDb == null) return;
oFromDb.Progress = progress;
await ct.SaveChangesAsync();
}
}
/// <summary>
/// Get the progress and status of a job
/// </summary>
/// <param name="jobId"></param>
internal static async Task<JobProgress> GetJobProgressAsync(Guid jobId)
{
using (AyContext ct = ServiceProviderProvider.DBContext)
{
var o = await ct.OpsJob.AsNoTracking().SingleOrDefaultAsync(z => z.GId == jobId);
if (o == null) return new JobProgress() { JobStatus = JobStatus.Absent, Progress = string.Empty };
return new JobProgress() { JobStatus = o.JobStatus, Progress = o.Progress };
}
}
#endregion Job ops
#region PROCESSOR