2
0

Job: add Id

This commit is contained in:
glax 2023-08-26 02:40:24 +02:00
parent 7614f9aad3
commit 4d1e43e7b3
3 changed files with 17 additions and 2 deletions

View File

@ -1,4 +1,5 @@
using Tranga.MangaConnectors; using System.Text;
using Tranga.MangaConnectors;
namespace Tranga.Jobs; namespace Tranga.Jobs;
@ -10,6 +11,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()
{ {

View File

@ -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);

View File

@ -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;