diff --git a/FileLiberator/BackupBook.cs b/FileLiberator/BackupBook.cs
deleted file mode 100644
index c7050b4c..00000000
--- a/FileLiberator/BackupBook.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using DataLayer;
-using Dinah.Core.ErrorHandling;
-
-namespace FileLiberator
-{
- ///
- /// Download DRM book and decrypt audiobook files
- ///
- /// Processes:
- /// Download: download aax file: the DRM encrypted audiobook
- /// Decrypt: remove DRM encryption from audiobook. Store final book
- /// Backup: perform all steps (downloaded, decrypt) still needed to get final book
- ///
- public class BackupBook : IProcessable
- {
- public event EventHandler Begin;
- public event EventHandler StatusUpdate;
- public event EventHandler Completed;
-
- public DownloadDecryptBook DownloadDecryptBook { get; }
- public DownloadPdf DownloadPdf { get; }
-
- public BackupBook(DownloadDecryptBook downloadDecryptBook, DownloadPdf downloadPdf)
- {
- DownloadDecryptBook = downloadDecryptBook;
- DownloadPdf = downloadPdf;
- }
-
- public bool Validate(LibraryBook libraryBook)
- => !ApplicationServices.TransitionalFileLocator.Audio_Exists(libraryBook.Book);
-
- // do NOT use ConfigureAwait(false) on ProcessAsync()
- // often calls events which prints to forms in the UI context
- public async Task ProcessAsync(LibraryBook libraryBook)
- {
- Begin?.Invoke(this, libraryBook);
-
- try
- {
- {
- var statusHandler = await DownloadDecryptBook.TryProcessAsync(libraryBook);
- if (statusHandler.HasErrors)
- return statusHandler;
- }
-
- {
- var statusHandler = await DownloadPdf.TryProcessAsync(libraryBook);
- if (statusHandler.HasErrors)
- return statusHandler;
- }
-
- return new StatusHandler();
- }
- finally
- {
- Completed?.Invoke(this, libraryBook);
- }
- }
- }
-}
diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj
index b55ca588..577fdaa2 100644
--- a/LibationLauncher/LibationLauncher.csproj
+++ b/LibationLauncher/LibationLauncher.csproj
@@ -13,7 +13,7 @@
win-x64
- 5.4.9.239
+ 5.4.9.252
diff --git a/LibationWinForms/BookLiberation/AudioConvertForm.cs b/LibationWinForms/BookLiberation/AudioConvertForm.cs
index 0dde6860..82a586f1 100644
--- a/LibationWinForms/BookLiberation/AudioConvertForm.cs
+++ b/LibationWinForms/BookLiberation/AudioConvertForm.cs
@@ -1,9 +1,5 @@
using DataLayer;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace LibationWinForms.BookLiberation
{
@@ -16,12 +12,12 @@ namespace LibationWinForms.BookLiberation
#region IProcessable event handler overrides
public override void OnBegin(object sender, LibraryBook libraryBook)
{
- InfoLogAction($"Convert Step, Begin: {libraryBook.Book}");
+ LogMe.Info($"Convert Step, Begin: {libraryBook.Book}");
base.OnBegin(sender, libraryBook);
}
public override void OnCompleted(object sender, LibraryBook libraryBook)
- => InfoLogAction($"Convert Step, Completed: {libraryBook.Book}{Environment.NewLine}");
+ => LogMe.Info($"Convert Step, Completed: {libraryBook.Book}{Environment.NewLine}");
#endregion
}
diff --git a/LibationWinForms/BookLiberation/AudioDecryptForm.cs b/LibationWinForms/BookLiberation/AudioDecryptForm.cs
index 45b6b5c8..a27b936d 100644
--- a/LibationWinForms/BookLiberation/AudioDecryptForm.cs
+++ b/LibationWinForms/BookLiberation/AudioDecryptForm.cs
@@ -12,12 +12,12 @@ namespace LibationWinForms.BookLiberation
#region IProcessable event handler overrides
public override void OnBegin(object sender, LibraryBook libraryBook)
{
- InfoLogAction($"Download & Decrypt Step, Begin: {libraryBook.Book}");
+ LogMe.Info($"Download & Decrypt Step, Begin: {libraryBook.Book}");
base.OnBegin(sender, libraryBook);
}
public override void OnCompleted(object sender, LibraryBook libraryBook)
- => InfoLogAction($"Download & Decrypt Step, Completed: {libraryBook.Book}{Environment.NewLine}");
+ => LogMe.Info($"Download & Decrypt Step, Completed: {libraryBook.Book}{Environment.NewLine}");
#endregion
}
diff --git a/LibationWinForms/BookLiberation/BaseForms/AudioDecodeBaseForm.cs b/LibationWinForms/BookLiberation/BaseForms/AudioDecodeBaseForm.cs
index a2691eec..8225c16f 100644
--- a/LibationWinForms/BookLiberation/BaseForms/AudioDecodeBaseForm.cs
+++ b/LibationWinForms/BookLiberation/BaseForms/AudioDecodeBaseForm.cs
@@ -19,9 +19,9 @@ namespace LibationWinForms.BookLiberation
private string narratorNames;
#region ProcessBaseForm overrides
- public override void SetProcessable(IStreamable streamProcessable, Action infoLog)
+ public override void SetProcessable(IStreamable streamProcessable, LogMe logMe)
{
- base.SetProcessable(streamProcessable, infoLog);
+ base.SetProcessable(streamProcessable, logMe);
if (Streamable is not null && Streamable is IAudioDecodable audioDecodable)
{
@@ -35,7 +35,6 @@ namespace LibationWinForms.BookLiberation
Disposed += OnUnsubscribeAll;
}
-
}
#endregion
diff --git a/LibationWinForms/BookLiberation/BaseForms/ProcessBaseForm.cs b/LibationWinForms/BookLiberation/BaseForms/ProcessBaseForm.cs
index 24d80acf..f8f89613 100644
--- a/LibationWinForms/BookLiberation/BaseForms/ProcessBaseForm.cs
+++ b/LibationWinForms/BookLiberation/BaseForms/ProcessBaseForm.cs
@@ -8,10 +8,10 @@ namespace LibationWinForms.BookLiberation
{
public class ProcessBaseForm : StreamBaseForm
{
- protected Action InfoLogAction { get; private set; }
- public virtual void SetProcessable(IStreamable streamable, Action infoLog)
+ protected LogMe LogMe { get; private set; }
+ public virtual void SetProcessable(IStreamable streamable, LogMe logMe)
{
- InfoLogAction = infoLog;
+ LogMe = logMe;
SetStreamable(streamable);
if (Streamable is not null && Streamable is IProcessable processable)
@@ -38,9 +38,9 @@ namespace LibationWinForms.BookLiberation
}
#region IProcessable event handlers
- public virtual void OnBegin(object sender, LibraryBook libraryBook) => InfoLogAction($"Begin: {libraryBook.Book}");
- public virtual void OnStatusUpdate(object sender, string statusUpdate) => InfoLogAction("- " + statusUpdate);
- public virtual void OnCompleted(object sender, LibraryBook libraryBook) => InfoLogAction($"Completed: {libraryBook.Book}{Environment.NewLine}");
+ public virtual void OnBegin(object sender, LibraryBook libraryBook) => LogMe.Info($"Begin: {libraryBook.Book}");
+ public virtual void OnStatusUpdate(object sender, string statusUpdate) => LogMe.Info("- " + statusUpdate);
+ public virtual void OnCompleted(object sender, LibraryBook libraryBook) => LogMe.Info($"Completed: {libraryBook.Book}{Environment.NewLine}");
#endregion
}
}
diff --git a/LibationWinForms/BookLiberation/PdfDownloadForm.cs b/LibationWinForms/BookLiberation/PdfDownloadForm.cs
index 870871e9..3def88c2 100644
--- a/LibationWinForms/BookLiberation/PdfDownloadForm.cs
+++ b/LibationWinForms/BookLiberation/PdfDownloadForm.cs
@@ -1,16 +1,10 @@
using DataLayer;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace LibationWinForms.BookLiberation
{
internal class PdfDownloadForm : DownloadForm
{
- public override void OnBegin(object sender, LibraryBook libraryBook) => InfoLogAction($"PDF Step, Begin: {libraryBook.Book}");
- public override void OnCompleted(object sender, LibraryBook libraryBook) => InfoLogAction($"PDF Step, Completed: {libraryBook.Book}");
-
+ public override void OnBegin(object sender, LibraryBook libraryBook) => LogMe.Info($"PDF Step, Begin: {libraryBook.Book}");
+ public override void OnCompleted(object sender, LibraryBook libraryBook) => LogMe.Info($"PDF Step, Completed: {libraryBook.Book}");
}
}
diff --git a/LibationWinForms/BookLiberation/ProcessorAutomationController.cs b/LibationWinForms/BookLiberation/ProcessorAutomationController.cs
index d43613e1..e397378f 100644
--- a/LibationWinForms/BookLiberation/ProcessorAutomationController.cs
+++ b/LibationWinForms/BookLiberation/ProcessorAutomationController.cs
@@ -86,11 +86,20 @@ namespace LibationWinForms.BookLiberation
await new BackupLoop(logMe, convertBook, automatedBackupsForm).RunBackupAsync();
}
- private static BackupBook CreateBackupBook(EventHandler completedAction, LogMe logMe)
+ private static IProcessable CreateBackupBook(EventHandler completedAction, LogMe logMe)
{
- var downloadPdf = CreateStreamProcessable(completedAction, logMe);
- var downloadDecryptBook = CreateStreamProcessable(completedAction, logMe);
- return new BackupBook(downloadDecryptBook, downloadPdf);
+ var downloadPdf = CreateStreamProcessable(null, logMe);
+
+ //Chain pdf download on DownloadDecryptBook.Completed
+ async void onDownloadDecryptBookCompleted(object sender, LibraryBook e)
+ {
+ await downloadPdf.TryProcessAsync(e);
+
+ completedAction(sender, e);
+ }
+
+ var downloadDecryptBook = CreateStreamProcessable(onDownloadDecryptBookCompleted, logMe);
+ return downloadDecryptBook;
}
public static async Task BackupAllPdfsAsync(EventHandler completedAction = null)
@@ -122,7 +131,7 @@ namespace LibationWinForms.BookLiberation
}
///
- /// Create a new and which creates a new on .
+ /// Create a new and links it to a new .
///
/// The derrived type to create.
/// The derrived form to create on and and be Shown on
@@ -138,7 +147,7 @@ namespace LibationWinForms.BookLiberation
{
var processForm = new TForm();
Action logAction = logMe is null ? (s) => { } : logMe.Info;
- processForm.SetProcessable(strProc, logAction);
+ processForm.SetProcessable(strProc, logMe);
processForm.OnBegin(sender, libraryBook);
};