Fixed Capitalization
Added fields for serialization
This commit is contained in:
parent
0fc146019a
commit
1f8e8fb740
@ -14,7 +14,7 @@ public class TaskManager
|
|||||||
taskChecker.Start();
|
taskChecker.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTask(Connector connector, TrangaTask.availableTasks task, TimeSpan reoccurrence, Publication? publication = null, string language = "en")
|
public void AddTask(Connector connector, TrangaTask.AvailableTasks task, TimeSpan reoccurrence, Publication? publication = null, string language = "en")
|
||||||
{
|
{
|
||||||
this._allTasks.Add(new TrangaTask(connector, task, reoccurrence, publication, language));
|
this._allTasks.Add(new TrangaTask(connector, task, reoccurrence, publication, language));
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,36 @@
|
|||||||
namespace Tranga;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Tranga;
|
||||||
|
|
||||||
public class TrangaTask
|
public class TrangaTask
|
||||||
{
|
{
|
||||||
public TimeSpan reoccurrence { get; }
|
[JsonInclude]public TimeSpan reoccurrence { get; }
|
||||||
public DateTime lastExecuted { get; private set; }
|
[JsonInclude]public DateTime lastExecuted { get; private set; }
|
||||||
public Connector connector { get; }
|
[JsonIgnore] private Connector connector { get; }
|
||||||
public availableTasks availableTaskToExecute { get; }
|
[JsonInclude] public string connectorName;
|
||||||
public enum availableTasks
|
[JsonInclude]public AvailableTasks task { get; }
|
||||||
|
public enum AvailableTasks
|
||||||
{
|
{
|
||||||
downloadNewChapters,
|
DownloadNewChapters,
|
||||||
updateChapters,
|
UpdateChapters,
|
||||||
updatePublications
|
UpdatePublications
|
||||||
};
|
};
|
||||||
public Publication? publication { get; }
|
[JsonIgnore]public Publication? publication { get; }
|
||||||
public string language { get; }
|
[JsonInclude]public string? publicationIdentifier;
|
||||||
|
[JsonInclude]public string language { get; }
|
||||||
|
|
||||||
|
|
||||||
public TrangaTask(Connector connector, availableTasks availableTask, TimeSpan reoccurrence, Publication? publication = null, string language = "en")
|
public TrangaTask(Connector connector, AvailableTasks task, TimeSpan reoccurrence, Publication? publication = null, string language = "en")
|
||||||
{
|
{
|
||||||
this.connector = connector;
|
this.connector = connector;
|
||||||
this.availableTaskToExecute = availableTask;
|
this.connectorName = connector.name;
|
||||||
|
this.task = task;
|
||||||
this.lastExecuted = DateTime.Now.Subtract(reoccurrence);
|
this.lastExecuted = DateTime.Now.Subtract(reoccurrence);
|
||||||
this.reoccurrence = reoccurrence;
|
this.reoccurrence = reoccurrence;
|
||||||
this.publication = publication;
|
this.publication = publication;
|
||||||
|
this.publicationIdentifier = publication?.downloadUrl;
|
||||||
this.language = language;
|
this.language = language;
|
||||||
if (publication is null && availableTask is availableTasks.updateChapters or availableTasks.downloadNewChapters)
|
if (publication is null && task is AvailableTasks.UpdateChapters or AvailableTasks.DownloadNewChapters)
|
||||||
{
|
{
|
||||||
if (publication is null)
|
if (publication is null)
|
||||||
throw new ArgumentException(
|
throw new ArgumentException(
|
||||||
@ -34,15 +40,15 @@ public class TrangaTask
|
|||||||
|
|
||||||
public void Execute(ref Dictionary<Publication, Chapter[]> chapterCollection)
|
public void Execute(ref Dictionary<Publication, Chapter[]> chapterCollection)
|
||||||
{
|
{
|
||||||
switch (this.availableTaskToExecute)
|
switch (this.task)
|
||||||
{
|
{
|
||||||
case availableTasks.updateChapters:
|
case AvailableTasks.UpdateChapters:
|
||||||
UpdateChapters(ref chapterCollection);
|
UpdateChapters(ref chapterCollection);
|
||||||
break;
|
break;
|
||||||
case availableTasks.updatePublications:
|
case AvailableTasks.UpdatePublications:
|
||||||
UpdatePublications(ref chapterCollection);
|
UpdatePublications(ref chapterCollection);
|
||||||
break;
|
break;
|
||||||
case availableTasks.downloadNewChapters:
|
case AvailableTasks.DownloadNewChapters:
|
||||||
DownloadNewChapters(UpdateChapters(ref chapterCollection));
|
DownloadNewChapters(UpdateChapters(ref chapterCollection));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user