mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-07-02 08:54:17 +02:00
Rewrite of Task-System for serialization.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
public class TaskManager
|
||||
{
|
||||
private readonly Dictionary<Publication, Chapter[]> _chapterCollection;
|
||||
private Dictionary<Publication, Chapter[]> _chapterCollection;
|
||||
private readonly HashSet<TrangaTask> _allTasks;
|
||||
private bool _continueRunning = true;
|
||||
|
||||
@ -14,18 +14,18 @@ public class TaskManager
|
||||
taskChecker.Start();
|
||||
}
|
||||
|
||||
public void AddTask(Connector connector, TrangaTask.availableTasks task, TimeSpan reoccurrence, Publication? publication = null, string language = "en")
|
||||
{
|
||||
this._allTasks.Add(new TrangaTask(connector, task, reoccurrence, publication, language));
|
||||
}
|
||||
|
||||
private void TaskCheckerThread()
|
||||
{
|
||||
while (_continueRunning)
|
||||
{
|
||||
foreach (TrangaTask task in _allTasks.Where(trangaTask => (DateTime.Now - trangaTask.lastExecuted) > trangaTask.reoccurrence))
|
||||
{
|
||||
if (!task.lastExecutedSuccessfully)
|
||||
{
|
||||
task.Abort();
|
||||
//Add logging that task has failed
|
||||
}
|
||||
task.Execute();
|
||||
task.Execute(ref _chapterCollection);
|
||||
}
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
@ -39,7 +39,7 @@ public class TaskManager
|
||||
|
||||
public Publication[] GetAddedPublications()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return this._chapterCollection.Keys.ToArray();
|
||||
}
|
||||
|
||||
public TrangaTask[] GetTasks()
|
||||
|
Reference in New Issue
Block a user