From 24c58e9e222ce9f582293e392a1776e286618bb6 Mon Sep 17 00:00:00 2001 From: glax Date: Fri, 19 May 2023 14:15:17 +0200 Subject: [PATCH] Added methods to Add/Remove tasks --- Tranga/TaskManager.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Tranga/TaskManager.cs b/Tranga/TaskManager.cs index bd39dd8..3637c88 100644 --- a/Tranga/TaskManager.cs +++ b/Tranga/TaskManager.cs @@ -28,6 +28,21 @@ public class TaskManager } } + public bool AddTask(TrangaTask.Task task, Connector connector, Publication publication, TimeSpan reoccurrence, + string language = "") + { + if(!_allTasks.Any(trangaTask => trangaTask.task != task && trangaTask.publication.downloadUrl != publication.downloadUrl)) + return _allTasks.Add(new TrangaTask(connector, task, publication, reoccurrence, language)); + return false; + } + + public bool RemoveTask(TrangaTask.Task task, Publication publication) + { + return (_allTasks.RemoveWhere(trangaTask => + trangaTask.task == task && trangaTask.publication.downloadUrl == publication.downloadUrl) + > 0); + } + public void Shutdown() { _continueRunning = false;