Merge pull request #5576 from W6HBR/dev

fix job status issue for disabled jobs
This commit is contained in:
Shaun Walker
2025-09-05 11:07:52 -04:00
committed by GitHub
3 changed files with 23 additions and 12 deletions

View File

@ -114,18 +114,26 @@ else
private async Task StartJob(int jobId)
{
try
Job _job = await JobService.GetJobAsync(jobId);
if (!_job.IsEnabled)
{
await JobService.StartJobAsync(jobId);
await logger.LogInformation("Job Started {JobId}", jobId);
AddModuleMessage(Localizer["Message.Job.Start"], MessageType.Success);
_jobs = await JobService.GetJobsAsync();
StateHasChanged();
AddModuleMessage(Localizer["Message.Job.Disabled"], MessageType.Warning);
}
catch (Exception ex)
else
{
await logger.LogError(ex, "Error Starting Job {JobId} {Error}", jobId, ex.Message);
AddModuleMessage(Localizer["Error.Job.Start"], MessageType.Error);
try
{
await JobService.StartJobAsync(jobId);
await logger.LogInformation("Job Started {JobId}", jobId);
AddModuleMessage(Localizer["Message.Job.Start"], MessageType.Success);
_jobs = await JobService.GetJobsAsync();
StateHasChanged();
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Starting Job {JobId} {Error}", jobId, ex.Message);
AddModuleMessage(Localizer["Error.Job.Start"], MessageType.Error);
}
}
}

View File

@ -183,4 +183,7 @@
<data name="Refresh.Text" xml:space="preserve">
<value>Refresh</value>
</data>
</root>
<data name="Message.Job.Disabled" xml:space="preserve">
<value>The job cannot be started while in the disabled state.</value>
</data>
</root>

View File

@ -252,8 +252,8 @@ namespace Oqtane.Infrastructure
Job job = jobs.GetJobs().Where(item => item.JobType == jobTypeName).FirstOrDefault();
if (job != null)
{
// reset in case this job was forcefully terminated previously
job.IsStarted = true;
// reset in case this job was enabled and forcefully terminated previously
job.IsStarted = job.IsEnabled;
job.IsExecuting = false;
jobs.UpdateJob(job);
}