From f0a4bc3e99d9570ce46f743f4e3929c74049d70e Mon Sep 17 00:00:00 2001 From: glax Date: Fri, 19 May 2023 17:36:03 +0200 Subject: [PATCH] AddTask now takes ConnectorName instead of object --- Tranga-CLI/Tranga_Cli.cs | 2 +- Tranga/TaskManager.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Tranga-CLI/Tranga_Cli.cs b/Tranga-CLI/Tranga_Cli.cs index be2a70b..4a05265 100644 --- a/Tranga-CLI/Tranga_Cli.cs +++ b/Tranga-CLI/Tranga_Cli.cs @@ -48,7 +48,7 @@ public static class Tranga_Cli if(task != TrangaTask.Task.UpdatePublications) publication = SelectPublication(connector); TimeSpan reoccurrence = SelectReoccurence(); - taskManager.AddTask(task, connector, publication, reoccurrence, "en"); + taskManager.AddTask(task, connector.name, publication, reoccurrence, "en"); Console.WriteLine($"{task} - {connector.name} - {publication?.sortName}"); Console.WriteLine("Press any key."); Console.ReadKey(); diff --git a/Tranga/TaskManager.cs b/Tranga/TaskManager.cs index b8ee015..343165d 100644 --- a/Tranga/TaskManager.cs +++ b/Tranga/TaskManager.cs @@ -34,9 +34,13 @@ public class TaskManager } } - public void AddTask(TrangaTask.Task task, Connector connector, Publication? publication, TimeSpan reoccurrence, + public void AddTask(TrangaTask.Task task, string connectorName, Publication? publication, TimeSpan reoccurrence, string language = "") { + Connector? connector = connectors.FirstOrDefault(c => c.name == connectorName); + if (connector is null) + throw new ArgumentException($"Connector {connectorName} is not a known connector."); + if (!_allTasks.Any(trangaTask => trangaTask.task != task && trangaTask.connectorName != connector.name && trangaTask.publication?.downloadUrl != publication?.downloadUrl)) {