Compare commits
4 Commits
3c1865de31
...
2b18dc9d4f
Author | SHA1 | Date | |
---|---|---|---|
2b18dc9d4f | |||
247c06872e | |||
854bb71771 | |||
3f72e527fa |
@ -55,8 +55,8 @@ public static class Tranga_Cli
|
||||
if(task != TrangaTask.Task.UpdatePublications)
|
||||
publication = SelectPublication(connector);
|
||||
TimeSpan reoccurrence = SelectReoccurrence();
|
||||
taskManager.AddTask(task, connector.name, publication, reoccurrence, "en");
|
||||
Console.WriteLine($"{task} - {reoccurrence} - {publication?.sortName} - {connector.name}");
|
||||
TrangaTask newTask = taskManager.AddTask(task, connector.name, publication, reoccurrence, "en");
|
||||
Console.WriteLine(newTask);
|
||||
Console.WriteLine("Press any key.");
|
||||
Console.ReadKey();
|
||||
menu = 0;
|
||||
@ -160,7 +160,7 @@ public static class Tranga_Cli
|
||||
int tIndex = 0;
|
||||
Console.WriteLine($"Tasks (Running/Total): {taskRunningCount}/{taskCount}");
|
||||
foreach(TrangaTask trangaTask in tasks)
|
||||
Console.WriteLine($"{tIndex++}: {trangaTask.task} - {trangaTask.reoccurrence} - {trangaTask.publication?.sortName} - {trangaTask.connectorName} - {trangaTask.lastExecuted} - {(trangaTask.isBeingExecuted ? "Running" : "Waiting")}");
|
||||
Console.WriteLine($"{tIndex++:000}: {trangaTask.ToString()}");
|
||||
}
|
||||
|
||||
private static void ExecuteTaskNow(TaskManager taskManager)
|
||||
|
@ -67,7 +67,7 @@ public class TaskManager
|
||||
/// <param name="reoccurrence">Time-Interval between Executions</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>
|
||||
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 = "")
|
||||
{
|
||||
//Get appropriate Connector from available Connectors for TrangaTask
|
||||
@ -75,15 +75,17 @@ public class TaskManager
|
||||
if (connector is null)
|
||||
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
|
||||
if (!_allTasks.Any(trangaTask => trangaTask.task != task && trangaTask.connectorName != connector.name &&
|
||||
trangaTask.publication?.downloadUrl != publication?.downloadUrl))
|
||||
{
|
||||
if(task != TrangaTask.Task.UpdatePublications)
|
||||
_chapterCollection.Add((Publication)publication!, new List<Chapter>());
|
||||
_allTasks.Add(new TrangaTask(connector.name, task, publication, reoccurrence, language));
|
||||
_allTasks.Add(newTask);
|
||||
ExportTasks(Directory.GetCurrentDirectory());
|
||||
}
|
||||
return newTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -42,4 +42,9 @@ public class TrangaTask
|
||||
UpdateChapters,
|
||||
DownloadNewChapters
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{task}\t{lastExecuted}\t{reoccurrence}\t{(isBeingExecuted ? "running" : "waiting")}\t{connectorName}\t{publication?.sortName}";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user