AddTask now takes ConnectorName instead of object

This commit is contained in:
glax 2023-05-19 17:36:03 +02:00
parent b0f6441599
commit f0a4bc3e99
2 changed files with 6 additions and 2 deletions

View File

@ -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();

View File

@ -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))
{