mirror of
https://github.com/C9Glax/tranga.git
synced 2025-05-21 21:53:01 +02:00
Let Job update itself in its own context
This commit is contained in:
parent
cb1c68f295
commit
8ecbdb91b2
@ -78,7 +78,8 @@ public abstract class Job
|
||||
this.state = JobState.Running;
|
||||
context.SaveChanges();
|
||||
ret = RunInternal(context).ToArray();
|
||||
this.state = JobState.Completed;
|
||||
this.state = this.RecurrenceMs > 0 ? JobState.CompletedWaiting : JobState.Completed;
|
||||
this.LastExecution = DateTime.UtcNow;
|
||||
context.Jobs.AddRange(ret);
|
||||
Log.Info($"Job {JobId} completed. Generated {ret.Length} new jobs.");
|
||||
context.SaveChanges();
|
||||
@ -88,6 +89,8 @@ public abstract class Job
|
||||
if (e is not DbUpdateException)
|
||||
{
|
||||
this.state = JobState.Failed;
|
||||
this.Enabled = false;
|
||||
this.LastExecution = DateTime.UtcNow;
|
||||
Log.Error($"Failed to run job {JobId}", e);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user