2023-05-17 23:23:01 +02:00
|
|
|
|
namespace Tranga;
|
|
|
|
|
|
|
|
|
|
public class TaskManager
|
|
|
|
|
{
|
2023-05-19 14:00:30 +02:00
|
|
|
|
private readonly Dictionary<Publication, List<Chapter>> _chapterCollection;
|
2023-05-18 19:25:46 +02:00
|
|
|
|
private readonly HashSet<TrangaTask> _allTasks;
|
2023-05-17 23:23:01 +02:00
|
|
|
|
private bool _continueRunning = true;
|
|
|
|
|
|
|
|
|
|
public TaskManager()
|
|
|
|
|
{
|
2023-05-18 19:25:46 +02:00
|
|
|
|
_chapterCollection = new();
|
|
|
|
|
_allTasks = new ();
|
2023-05-19 13:59:26 +02:00
|
|
|
|
ImportTasks();
|
2023-05-17 23:23:01 +02:00
|
|
|
|
Thread taskChecker = new(TaskCheckerThread);
|
|
|
|
|
taskChecker.Start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TaskCheckerThread()
|
|
|
|
|
{
|
|
|
|
|
while (_continueRunning)
|
|
|
|
|
{
|
2023-05-19 14:00:30 +02:00
|
|
|
|
foreach (TrangaTask task in _allTasks.Where(trangaTask => trangaTask.ShouldExecute(true)))
|
2023-05-17 23:23:01 +02:00
|
|
|
|
{
|
2023-05-19 14:00:30 +02:00
|
|
|
|
TaskExecutor.Execute(task, this._chapterCollection);
|
2023-05-17 23:23:01 +02:00
|
|
|
|
}
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Shutdown()
|
|
|
|
|
{
|
|
|
|
|
_continueRunning = false;
|
2023-05-19 13:59:26 +02:00
|
|
|
|
ExportTasks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ImportTasks()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ExportTasks()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
2023-05-17 23:23:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|