mirror of
https://github.com/C9Glax/tranga.git
synced 2025-01-12 11:27:32 +01:00
AddTask returns the created Task
This commit is contained in:
parent
3c1865de31
commit
3f72e527fa
@ -67,7 +67,7 @@ public class TaskManager
|
|||||||
/// <param name="reoccurrence">Time-Interval between Executions</param>
|
/// <param name="reoccurrence">Time-Interval between Executions</param>
|
||||||
/// <param name="language">language, should Task require parameter. Can be empty</param>
|
/// <param name="language">language, should Task require parameter. Can be empty</param>
|
||||||
/// <exception cref="ArgumentException">Is thrown when connectorName is not a available Connector</exception>
|
/// <exception cref="ArgumentException">Is thrown when connectorName is not a available Connector</exception>
|
||||||
public void AddTask(TrangaTask.Task task, string connectorName, Publication? publication, TimeSpan reoccurrence,
|
public TrangaTask AddTask(TrangaTask.Task task, string connectorName, Publication? publication, TimeSpan reoccurrence,
|
||||||
string language = "")
|
string language = "")
|
||||||
{
|
{
|
||||||
//Get appropriate Connector from available Connectors for TrangaTask
|
//Get appropriate Connector from available Connectors for TrangaTask
|
||||||
@ -75,15 +75,17 @@ public class TaskManager
|
|||||||
if (connector is null)
|
if (connector is null)
|
||||||
throw new ArgumentException($"Connector {connectorName} is not a known connector.");
|
throw new ArgumentException($"Connector {connectorName} is not a known connector.");
|
||||||
|
|
||||||
|
TrangaTask newTask = new TrangaTask(connector.name, task, publication, reoccurrence, language);
|
||||||
//Check if same task already exists
|
//Check if same task already exists
|
||||||
if (!_allTasks.Any(trangaTask => trangaTask.task != task && trangaTask.connectorName != connector.name &&
|
if (!_allTasks.Any(trangaTask => trangaTask.task != task && trangaTask.connectorName != connector.name &&
|
||||||
trangaTask.publication?.downloadUrl != publication?.downloadUrl))
|
trangaTask.publication?.downloadUrl != publication?.downloadUrl))
|
||||||
{
|
{
|
||||||
if(task != TrangaTask.Task.UpdatePublications)
|
if(task != TrangaTask.Task.UpdatePublications)
|
||||||
_chapterCollection.Add((Publication)publication!, new List<Chapter>());
|
_chapterCollection.Add((Publication)publication!, new List<Chapter>());
|
||||||
_allTasks.Add(new TrangaTask(connector.name, task, publication, reoccurrence, language));
|
_allTasks.Add(newTask);
|
||||||
ExportTasks(Directory.GetCurrentDirectory());
|
ExportTasks(Directory.GetCurrentDirectory());
|
||||||
}
|
}
|
||||||
|
return newTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user