2023-05-19 16:23:37 +02:00
|
|
|
|
namespace Tranga;
|
2023-05-18 21:08:09 +02:00
|
|
|
|
|
2023-05-19 14:00:30 +02:00
|
|
|
|
public struct TrangaTask
|
|
|
|
|
{
|
2023-05-19 16:23:37 +02:00
|
|
|
|
public TimeSpan reoccurrence { get; }
|
|
|
|
|
public DateTime lastExecuted { get; set; }
|
|
|
|
|
public string connectorName { get; }
|
|
|
|
|
public Task task { get; }
|
|
|
|
|
public Publication? publication { get; }
|
|
|
|
|
public string language { get; }
|
2023-05-19 14:00:30 +02:00
|
|
|
|
|
|
|
|
|
public TrangaTask(Connector connector, Task task, Publication publication, TimeSpan reoccurrence, string language = "")
|
2023-05-17 23:23:01 +02:00
|
|
|
|
{
|
2023-05-18 21:08:09 +02:00
|
|
|
|
this.reoccurrence = reoccurrence;
|
2023-05-19 14:00:30 +02:00
|
|
|
|
this.lastExecuted = DateTime.Now.Subtract(reoccurrence);
|
|
|
|
|
this.connector = connector;
|
|
|
|
|
this.task = task;
|
|
|
|
|
this.publication = publication;
|
|
|
|
|
this.language = language;
|
2023-05-18 21:08:09 +02:00
|
|
|
|
}
|
2023-05-17 23:23:01 +02:00
|
|
|
|
|
2023-05-19 14:00:30 +02:00
|
|
|
|
public bool ShouldExecute(bool willBeExecuted)
|
2023-05-17 23:23:01 +02:00
|
|
|
|
{
|
2023-05-19 14:00:30 +02:00
|
|
|
|
bool ret = (DateTime.Now - lastExecuted) > reoccurrence;
|
|
|
|
|
if (ret && willBeExecuted)
|
|
|
|
|
lastExecuted = DateTime.Now;
|
|
|
|
|
return ret;
|
2023-05-17 23:23:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 14:00:30 +02:00
|
|
|
|
public enum Task
|
2023-05-17 23:23:01 +02:00
|
|
|
|
{
|
2023-05-19 14:00:30 +02:00
|
|
|
|
UpdatePublications,
|
|
|
|
|
UpdateChapters,
|
|
|
|
|
DownloadNewChapters
|
2023-05-17 23:23:01 +02:00
|
|
|
|
}
|
|
|
|
|
}
|