Job: add Id
This commit is contained in:
parent
7614f9aad3
commit
4d1e43e7b3
@ -1,4 +1,5 @@
|
|||||||
using Tranga.MangaConnectors;
|
using System.Text;
|
||||||
|
using Tranga.MangaConnectors;
|
||||||
|
|
||||||
namespace Tranga.Jobs;
|
namespace Tranga.Jobs;
|
||||||
|
|
||||||
@ -11,6 +12,11 @@ public class DownloadChapter : Job
|
|||||||
this.chapter = chapter;
|
this.chapter = chapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override string GetId()
|
||||||
|
{
|
||||||
|
return Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Concat(this.GetType().ToString(), chapter.parentPublication.internalId, chapter.chapterNumber)));
|
||||||
|
}
|
||||||
|
|
||||||
protected override IEnumerable<Job> ExecuteReturnSubTasksInternal()
|
protected override IEnumerable<Job> ExecuteReturnSubTasksInternal()
|
||||||
{
|
{
|
||||||
Task downloadTask = new(delegate
|
Task downloadTask = new(delegate
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Tranga.MangaConnectors;
|
using System.Text;
|
||||||
|
using Tranga.MangaConnectors;
|
||||||
|
|
||||||
namespace Tranga.Jobs;
|
namespace Tranga.Jobs;
|
||||||
|
|
||||||
@ -11,6 +12,11 @@ public class DownloadNewChapters : Job
|
|||||||
this.publication = publication;
|
this.publication = publication;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override string GetId()
|
||||||
|
{
|
||||||
|
return Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Concat(this.GetType().ToString(), publication.internalId)));
|
||||||
|
}
|
||||||
|
|
||||||
protected override IEnumerable<Job> ExecuteReturnSubTasksInternal()
|
protected override IEnumerable<Job> ExecuteReturnSubTasksInternal()
|
||||||
{
|
{
|
||||||
Chapter[] chapters = mangaConnector.GetNewChapters(publication);
|
Chapter[] chapters = mangaConnector.GetNewChapters(publication);
|
||||||
|
@ -10,6 +10,7 @@ public abstract class Job : GlobalBase
|
|||||||
public TimeSpan? recurrenceTime { get; set; }
|
public TimeSpan? recurrenceTime { get; set; }
|
||||||
public DateTime? lastExecution { get; private set; }
|
public DateTime? lastExecution { get; private set; }
|
||||||
public DateTime nextExecution => NextExecution();
|
public DateTime nextExecution => NextExecution();
|
||||||
|
public string id => GetId();
|
||||||
|
|
||||||
public Job(GlobalBase clone, MangaConnector connector, bool recurring = false, TimeSpan? recurrenceTime = null) : base(clone)
|
public Job(GlobalBase clone, MangaConnector connector, bool recurring = false, TimeSpan? recurrenceTime = null) : base(clone)
|
||||||
{
|
{
|
||||||
@ -21,6 +22,8 @@ public abstract class Job : GlobalBase
|
|||||||
this.recurrenceTime = recurrenceTime;
|
this.recurrenceTime = recurrenceTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract string GetId();
|
||||||
|
|
||||||
public Job(GlobalBase clone, MangaConnector connector, ProgressToken progressToken, bool recurring = false, TimeSpan? recurrenceTime = null) : base(clone)
|
public Job(GlobalBase clone, MangaConnector connector, ProgressToken progressToken, bool recurring = false, TimeSpan? recurrenceTime = null) : base(clone)
|
||||||
{
|
{
|
||||||
this.mangaConnector = connector;
|
this.mangaConnector = connector;
|
||||||
|
Loading…
Reference in New Issue
Block a user