Compare commits

..

No commits in common. "cb6482ebaece7b03477d3b3e8adbd385bc934b03" and "c1aa4cf6b57f5a765f1949cb3a2be47fdf40a06f" have entirely different histories.

View File

@ -14,7 +14,6 @@ public class JobBoss : GlobalBase
this.jobs = new(); this.jobs = new();
LoadJobsList(connectors); LoadJobsList(connectors);
this.mangaConnectorJobQueue = new(); this.mangaConnectorJobQueue = new();
Log($"Next job in {jobs.MinBy(job => job.nextExecution)?.nextExecution.Subtract(DateTime.Now)} {jobs.MinBy(job => job.nextExecution)?.id}");
} }
public void AddJob(Job job) public void AddJob(Job job)
@ -162,21 +161,18 @@ public class JobBoss : GlobalBase
cachedPublications.Add(ncJob.manga); cachedPublications.Add(ncJob.manga);
} }
public void ExportJob(Job job)
{
string jobFilePath = Path.Join(settings.jobsFolderPath, $"{job.id}.json");
string jobStr = JsonConvert.SerializeObject(job);
while(IsFileInUse(jobFilePath))
Thread.Sleep(10);
Log($"Exporting Job {jobFilePath}");
File.WriteAllText(jobFilePath, jobStr);
}
public void ExportJobsList() public void ExportJobsList()
{ {
Log("Exporting Jobs"); Log("Exporting Jobs");
foreach (Job job in this.jobs) foreach (Job job in this.jobs)
ExportJob(job); {
string jobFilePath = Path.Join(settings.jobsFolderPath, $"{job.id}.json");
string jobStr = JsonConvert.SerializeObject(job);
while(IsFileInUse(jobFilePath))
Thread.Sleep(10);
Log($"Exporting Job {jobFilePath}");
File.WriteAllText(jobFilePath, jobStr);
}
//Remove files with jobs not in this.jobs-list //Remove files with jobs not in this.jobs-list
Regex idRex = new (@"(.*)\.json"); Regex idRex = new (@"(.*)\.json");
@ -223,13 +219,14 @@ public class JobBoss : GlobalBase
} }
queueHead.ResetProgress(); queueHead.ResetProgress();
jobQueue.Dequeue(); jobQueue.Dequeue();
ExportJob(queueHead); ExportJobsList();
Log($"Next job in {jobs.MinBy(job => job.nextExecution)?.nextExecution.Subtract(DateTime.Now)} {jobs.MinBy(job => job.nextExecution)?.id}"); Log($"Next job in {jobs.MinBy(job => job.nextExecution)?.nextExecution.Subtract(DateTime.Now)} {jobs.MinBy(job => job.nextExecution)?.id}");
}else if (queueHead.progressToken.state is ProgressToken.State.Standby) }else if (queueHead.progressToken.state is ProgressToken.State.Standby)
{ {
Job[] subJobs = jobQueue.Peek().ExecuteReturnSubTasks().ToArray(); Job[] subJobs = jobQueue.Peek().ExecuteReturnSubTasks().ToArray();
AddJobs(subJobs); AddJobs(subJobs);
AddJobsToQueue(subJobs); AddJobsToQueue(subJobs);
ExportJobsList();
} }
} }
} }