Moved libraryManagers, notificationManagers and logger to commonObjects class.

This commit is contained in:
2023-07-30 23:31:25 +02:00
parent f9b5e05974
commit 3d6657b483
11 changed files with 229 additions and 133 deletions

View File

@ -32,10 +32,10 @@ public class DownloadChapterTask : TrangaTask
HttpStatusCode downloadSuccess = connector.DownloadChapter(this.publication, this.chapter, this, cancellationToken);
if ((int)downloadSuccess >= 200 && (int)downloadSuccess < 300)
{
foreach(NotificationManager nm in taskManager.settings.notificationManagers)
foreach(NotificationManager nm in taskManager.commonObjects.notificationManagers)
nm.SendNotification("Chapter downloaded", $"{this.publication.sortName} {this.chapter.chapterNumber} {this.chapter.name}");
foreach (LibraryManager lm in taskManager.settings.libraryManagers)
foreach (LibraryManager lm in taskManager.commonObjects.libraryManagers)
lm.UpdateLibrary();
}
return downloadSuccess;

View File

@ -66,7 +66,7 @@ public abstract class TrangaTask
/// <param name="cancellationToken"></param>
public void Execute(TaskManager taskManager, CancellationToken? cancellationToken = null)
{
taskManager.settings.logger?.WriteLine(this.GetType().ToString(), $"Executing Task {this}");
taskManager.commonObjects.logger?.WriteLine(this.GetType().ToString(), $"Executing Task {this}");
this.state = ExecutionState.Running;
this.executionStarted = DateTime.Now;
this.lastChange = DateTime.Now;
@ -89,7 +89,7 @@ public abstract class TrangaTask
if (this is DownloadChapterTask)
taskManager.DeleteTask(this);
taskManager.settings.logger?.WriteLine(this.GetType().ToString(), $"Finished Executing Task {this}");
taskManager.commonObjects.logger?.WriteLine(this.GetType().ToString(), $"Finished Executing Task {this}");
}
public void AddChildTask(TrangaTask childTask)