All scraping code removed

This commit is contained in:
Robert McRackan 2019-11-05 13:42:11 -05:00
parent c61bc27a7b
commit df90fc5361
106 changed files with 666 additions and 5319 deletions

View file

@ -1,129 +0,0 @@
namespace LibationWinForm.BookLiberation
{
partial class NoLongerAvailableForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.missingBtn = new System.Windows.Forms.Button();
this.abortBtn = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(174, 39);
this.label1.TabIndex = 0;
this.label1.Text = "Book details download failed.\r\n{0} may be no longer available.\r\nVerify the book i" +
"s still available here";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(15, 51);
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(384, 20);
this.textBox1.TabIndex = 1;
//
// missingBtn
//
this.missingBtn.Location = new System.Drawing.Point(324, 77);
this.missingBtn.Name = "missingBtn";
this.missingBtn.Size = new System.Drawing.Size(75, 23);
this.missingBtn.TabIndex = 3;
this.missingBtn.Text = "Missing";
this.missingBtn.UseVisualStyleBackColor = true;
this.missingBtn.Click += new System.EventHandler(this.missingBtn_Click);
//
// abortBtn
//
this.abortBtn.Location = new System.Drawing.Point(324, 126);
this.abortBtn.Name = "abortBtn";
this.abortBtn.Size = new System.Drawing.Size(75, 23);
this.abortBtn.TabIndex = 5;
this.abortBtn.Text = "Abort";
this.abortBtn.UseVisualStyleBackColor = true;
this.abortBtn.Click += new System.EventHandler(this.abortBtn_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 74);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(306, 26);
this.label2.TabIndex = 2;
this.label2.Text = "If the book is not available, click here to mark it as missing\r\nNo further book d" +
"etails download will be attempted for this book";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 123);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(204, 26);
this.label3.TabIndex = 4;
this.label3.Text = "If the book is actually available, click here\r\nto abort and try again later";
//
// NoLongerAvailableForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(411, 161);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.abortBtn);
this.Controls.Add(this.missingBtn);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "NoLongerAvailableForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "No Longer Available";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button missingBtn;
private System.Windows.Forms.Button abortBtn;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
}
}

View file

@ -1,28 +0,0 @@
using System;
using System.Windows.Forms;
using ScrapingDomainServices;
namespace LibationWinForm.BookLiberation
{
public partial class NoLongerAvailableForm : Form
{
public ScrapeBookDetails.NoLongerAvailableEnum EnumResult { get; private set; }
public NoLongerAvailableForm(string title, string url) : this()
{
this.Text += ": " + title;
this.label1.Text = string.Format(this.label1.Text, title);
this.textBox1.Text = url;
}
public NoLongerAvailableForm() => InitializeComponent();
private void missingBtn_Click(object sender, EventArgs e) => complete(ScrapeBookDetails.NoLongerAvailableEnum.MarkAsMissing);
private void abortBtn_Click(object sender, EventArgs e) => complete(ScrapeBookDetails.NoLongerAvailableEnum.Abort);
private void complete(ScrapeBookDetails.NoLongerAvailableEnum nlaEnum)
{
EnumResult = nlaEnum;
Close();
}
}
}

View file

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -3,7 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DataLayer;
using ScrapingDomainServices;
using Dinah.Core.ErrorHandling;
using FileLiberator;
namespace LibationWinForm.BookLiberation
{
@ -24,11 +25,18 @@ namespace LibationWinForm.BookLiberation
var backupBook = new BackupBook();
backupBook.Download.Completed += SetBackupCountsAsync;
backupBook.Decrypt.Completed += SetBackupCountsAsync;
await backupBook.ProcessValidateLibraryBookAsync(libraryBook);
}
await ProcessValidateLibraryBookAsync(backupBook, libraryBook);
}
// Download First Book (Download encrypted/DRM file)
async Task DownloadFirstBookAsync()
static async Task<StatusHandler> ProcessValidateLibraryBookAsync(IProcessable processable, LibraryBook libraryBook)
{
if (!await processable.ValidateAsync(libraryBook))
return new StatusHandler { "Validation failed" };
return await processable.ProcessAsync(libraryBook);
}
// Download First Book (Download encrypted/DRM file)
async Task DownloadFirstBookAsync()
{
var downloadBook = ProcessorAutomationController.GetWiredUpDownloadBook();
downloadBook.Completed += SetBackupCountsAsync;

View file

@ -1,6 +1,6 @@
using System;
using System.Threading.Tasks;
using ScrapingDomainServices;
using FileLiberator;
namespace LibationWinForm.BookLiberation
{
@ -39,21 +39,6 @@ namespace LibationWinForm.BookLiberation
downloadPdf.Begin += (_, __) => wireUpDownloadable(downloadPdf);
return downloadPdf;
}
public static ScrapeBookDetails GetWiredUpScrapeBookDetails()
{
var scrapeBookDetails = new ScrapeBookDetails();
scrapeBookDetails.Begin += (_, __) => wireUpDownloadable(scrapeBookDetails);
scrapeBookDetails.NoLongerAvailableAction = noLongerAvailableUI;
return scrapeBookDetails;
}
static ScrapeBookDetails.NoLongerAvailableEnum noLongerAvailableUI(string title, string url)
{
var nla = new NoLongerAvailableForm(title, url);
nla.ShowDialog();
return nla.EnumResult;
}
// subscribed to Begin event because a new form should be created+processed+closed on each iteration
private static void wireUpDownloadable(IDownloadable downloadable)

View file

@ -7,7 +7,7 @@ using System.Windows.Forms;
namespace LibationWinForm
{
public interface IRunnableDialog : IValidatable
public interface IRunnableDialog
{
IButtonControl AcceptButton { get; set; }
Control.ControlCollection Controls { get; }

View file

@ -36,26 +36,6 @@ namespace LibationWinForm
public static async Task Run(this IRunnableDialog dialog)
{
// validate children
// OfType<T>() -- skips items which aren't of the required type
// Cast<T>() -- throws an exception
var errorStrings = dialog
// get children
.Controls
.GetControlListRecursive()
.OfType<IValidatable>()
// and self
.Append(dialog)
// validate. get errors
.Select(c => c.StringBasedValidate())
// ignore successes
.Where(e => e != null);
if (errorStrings.Any())
{
MessageBox.Show(errorStrings.Aggregate((a, b) => a + "\r\n" + b));
return;
}
// get top level controls only. If Enabled, disable and push on stack
var disabledStack = disable(dialog);

View file

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibationWinForm
{
public interface IValidatable
{
// forms has a framework for ValidateChildren and ErrorProvider.s
// i don't feel like setting it up right now. doing this instead
string StringBasedValidate();
}
}

View file

@ -1,78 +0,0 @@
namespace LibationWinForm
{
partial class ScanLibraryDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.websiteProcessorControl1 = new LibationWinForm.WebsiteProcessorControl();
this.BeginScanBtn = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// websiteProcessorControl1
//
this.websiteProcessorControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.websiteProcessorControl1.Location = new System.Drawing.Point(12, 12);
this.websiteProcessorControl1.Name = "websiteProcessorControl1";
this.websiteProcessorControl1.Size = new System.Drawing.Size(324, 137);
this.websiteProcessorControl1.TabIndex = 0;
//
// BeginScanBtn
//
this.BeginScanBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.BeginScanBtn.Location = new System.Drawing.Point(12, 155);
this.BeginScanBtn.Name = "BeginScanBtn";
this.BeginScanBtn.Size = new System.Drawing.Size(324, 23);
this.BeginScanBtn.TabIndex = 1;
this.BeginScanBtn.Text = "BEGIN SCAN";
this.BeginScanBtn.UseVisualStyleBackColor = true;
//
// ScanLibraryDialog
//
this.AcceptButton = this.BeginScanBtn;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(348, 190);
this.Controls.Add(this.BeginScanBtn);
this.Controls.Add(this.websiteProcessorControl1);
this.Name = "ScanLibraryDialog";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Scan Library";
this.ResumeLayout(false);
}
#endregion
private WebsiteProcessorControl websiteProcessorControl1;
private System.Windows.Forms.Button BeginScanBtn;
}
}

View file

@ -1,41 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
using Dinah.Core;
using ScrapingDomainServices;
namespace LibationWinForm
{
public partial class ScanLibraryDialog : Form, IIndexLibraryDialog
{
public ScanLibraryDialog()
{
InitializeComponent();
}
public string StringBasedValidate() => null;
List<string> successMessages { get; } = new List<string>();
public string SuccessMessage => string.Join("\r\n", successMessages);
public int NewBooksAdded { get; private set; }
public int TotalBooksProcessed { get; private set; }
public async Task DoMainWorkAsync()
{
using var pageRetriever = websiteProcessorControl1.GetPageRetriever();
var jsonFilepaths = await DownloadLibrary.DownloadLibraryAsync(pageRetriever).ConfigureAwait(false);
successMessages.Add($"Downloaded {"library page".PluralizeWithCount(jsonFilepaths.Count)}");
(TotalBooksProcessed, NewBooksAdded) = await Indexer
.IndexLibraryAsync(jsonFilepaths)
.ConfigureAwait(false);
successMessages.Add($"Total processed: {TotalBooksProcessed}");
successMessages.Add($"New: {NewBooksAdded}");
}
}
}

View file

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -1,161 +0,0 @@
namespace LibationWinForm
{
partial class WebsiteProcessorControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.AuthGb = new System.Windows.Forms.GroupBox();
this.AuthRb_Browserless = new System.Windows.Forms.RadioButton();
this.AuthRb_UseCanonicalChrome = new System.Windows.Forms.RadioButton();
this.label3 = new System.Windows.Forms.Label();
this.AuthRb_ManualLogin = new System.Windows.Forms.RadioButton();
this.label2 = new System.Windows.Forms.Label();
this.PasswordTb = new System.Windows.Forms.TextBox();
this.UsernameTb = new System.Windows.Forms.TextBox();
this.AuthGb.SuspendLayout();
this.SuspendLayout();
//
// AuthGb
//
this.AuthGb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.AuthGb.Controls.Add(this.AuthRb_Browserless);
this.AuthGb.Controls.Add(this.AuthRb_UseCanonicalChrome);
this.AuthGb.Controls.Add(this.label3);
this.AuthGb.Controls.Add(this.AuthRb_ManualLogin);
this.AuthGb.Controls.Add(this.label2);
this.AuthGb.Controls.Add(this.PasswordTb);
this.AuthGb.Controls.Add(this.UsernameTb);
this.AuthGb.Location = new System.Drawing.Point(0, 0);
this.AuthGb.Name = "AuthGb";
this.AuthGb.Size = new System.Drawing.Size(324, 137);
this.AuthGb.TabIndex = 1;
this.AuthGb.TabStop = false;
this.AuthGb.Text = "Authentication";
//
// AuthRb_Browserless
//
this.AuthRb_Browserless.AutoSize = true;
this.AuthRb_Browserless.Checked = true;
this.AuthRb_Browserless.Location = new System.Drawing.Point(6, 19);
this.AuthRb_Browserless.Name = "AuthRb_Browserless";
this.AuthRb_Browserless.Size = new System.Drawing.Size(143, 17);
this.AuthRb_Browserless.TabIndex = 0;
this.AuthRb_Browserless.TabStop = true;
this.AuthRb_Browserless.Text = "Browserless with cookies";
this.AuthRb_Browserless.UseVisualStyleBackColor = true;
//
// AuthRb_UseCanonicalChrome
//
this.AuthRb_UseCanonicalChrome.AutoSize = true;
this.AuthRb_UseCanonicalChrome.Location = new System.Drawing.Point(6, 114);
this.AuthRb_UseCanonicalChrome.Name = "AuthRb_UseCanonicalChrome";
this.AuthRb_UseCanonicalChrome.Size = new System.Drawing.Size(216, 17);
this.AuthRb_UseCanonicalChrome.TabIndex = 6;
this.AuthRb_UseCanonicalChrome.Text = "Use Canonical Chrome. SEE WARNING";
this.AuthRb_UseCanonicalChrome.UseVisualStyleBackColor = true;
this.AuthRb_UseCanonicalChrome.CheckedChanged += new System.EventHandler(this.AuthRb_UseCanonicalChrome_CheckedChanged);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(27, 91);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 13);
this.label3.TabIndex = 4;
this.label3.Text = "Password";
//
// AuthRb_ManualLogin
//
this.AuthRb_ManualLogin.AutoSize = true;
this.AuthRb_ManualLogin.Location = new System.Drawing.Point(6, 42);
this.AuthRb_ManualLogin.Name = "AuthRb_ManualLogin";
this.AuthRb_ManualLogin.Size = new System.Drawing.Size(89, 17);
this.AuthRb_ManualLogin.TabIndex = 1;
this.AuthRb_ManualLogin.Text = "Manual Login";
this.AuthRb_ManualLogin.UseVisualStyleBackColor = true;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(27, 65);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(85, 13);
this.label2.TabIndex = 2;
this.label2.Text = "Username/Email";
//
// PasswordTb
//
this.PasswordTb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.PasswordTb.Location = new System.Drawing.Point(118, 88);
this.PasswordTb.Name = "PasswordTb";
this.PasswordTb.PasswordChar = '*';
this.PasswordTb.Size = new System.Drawing.Size(200, 20);
this.PasswordTb.TabIndex = 5;
this.PasswordTb.TextChanged += new System.EventHandler(this.UserIsEnteringLoginInfo);
this.PasswordTb.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.UsernamePasswordTb_KeyPress);
this.PasswordTb.MouseUp += new System.Windows.Forms.MouseEventHandler(this.UserIsEnteringLoginInfo);
//
// UsernameTb
//
this.UsernameTb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.UsernameTb.Location = new System.Drawing.Point(118, 62);
this.UsernameTb.Name = "UsernameTb";
this.UsernameTb.Size = new System.Drawing.Size(200, 20);
this.UsernameTb.TabIndex = 3;
this.UsernameTb.TextChanged += new System.EventHandler(this.UserIsEnteringLoginInfo);
this.UsernameTb.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.UsernamePasswordTb_KeyPress);
this.UsernameTb.MouseUp += new System.Windows.Forms.MouseEventHandler(this.UserIsEnteringLoginInfo);
//
// WebsiteProcessorControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.AuthGb);
this.Name = "WebsiteProcessorControl";
this.Size = new System.Drawing.Size(324, 137);
this.AuthGb.ResumeLayout(false);
this.AuthGb.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox AuthGb;
private System.Windows.Forms.RadioButton AuthRb_UseCanonicalChrome;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.RadioButton AuthRb_ManualLogin;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox PasswordTb;
private System.Windows.Forms.TextBox UsernameTb;
private System.Windows.Forms.RadioButton AuthRb_Browserless;
}
}

View file

@ -1,47 +0,0 @@
using System;
using System.Windows.Forms;
using AudibleDotComAutomation;
namespace LibationWinForm
{
public partial class WebsiteProcessorControl : UserControl, IValidatable
{
public event EventHandler<KeyPressEventArgs> KeyPressSubmit;
public WebsiteProcessorControl()
{
InitializeComponent();
}
public IPageRetriever GetPageRetriever()
=> AuthRb_UseCanonicalChrome.Checked ? new UserDataSeleniumRetriever()
: AuthRb_Browserless.Checked ? (IPageRetriever)new BrowserlessRetriever()
: new ManualLoginSeleniumRetriever(UsernameTb.Text, PasswordTb.Text);
public string StringBasedValidate()
{
if (AuthRb_ManualLogin.Checked && (string.IsNullOrWhiteSpace(UsernameTb.Text) || string.IsNullOrWhiteSpace(PasswordTb.Text)))
return "must fill in username and password";
return null;
}
private void UsernamePasswordTb_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Return)
{
KeyPressSubmit?.Invoke(sender, e);
// call your method for action on enter
e.Handled = true; // suppress default handling
}
}
private void UserIsEnteringLoginInfo(object sender, EventArgs e) => AuthRb_ManualLogin.Checked = true;
private void AuthRb_UseCanonicalChrome_CheckedChanged(object sender, EventArgs e)
{
if (AuthRb_UseCanonicalChrome.Checked)
MessageBox.Show(@"A canonical version of Chrome will be used including User Data, cookies. etc. Selenium chromedriver won't launch URL if another Chrome instance is open");
}
}
}

View file

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Forms;
using ApplicationService;
using ApplicationServices;
namespace LibationWinForm
{
@ -22,8 +22,6 @@ namespace LibationWinForm
this.Shown += (_, __) => AcceptButton.PerformClick();
}
public string StringBasedValidate() => null;
List<string> successMessages { get; } = new List<string>();
public string SuccessMessage => string.Join("\r\n", successMessages);
@ -33,8 +31,8 @@ namespace LibationWinForm
public async Task DoMainWorkAsync()
{
var callback = new Login.WinformResponder();
var refresher = new LibraryIndexer();
(TotalBooksProcessed, NewBooksAdded) = await refresher.IndexAsync(callback);
var indexer = new LibraryIndexer();
(TotalBooksProcessed, NewBooksAdded) = await indexer.IndexAsync(callback);
successMessages.Add($"Total processed: {TotalBooksProcessed}");
successMessages.Add($"New: {NewBooksAdded}");

View file

@ -34,10 +34,8 @@
this.filterBtn = new System.Windows.Forms.Button();
this.filterSearchTb = new System.Windows.Forms.TextBox();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.indexToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.scanLibraryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.reimportMostRecentLibraryScanToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.beginImportingBookDetailsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.liberateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.beginBookBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.beginPdfBackupsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -100,7 +98,7 @@
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.indexToolStripMenuItem,
this.importToolStripMenuItem,
this.liberateToolStripMenuItem,
this.quickFiltersToolStripMenuItem,
this.settingsToolStripMenuItem});
@ -110,38 +108,21 @@
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// indexToolStripMenuItem
// importToolStripMenuItem
//
this.indexToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.scanLibraryToolStripMenuItem,
this.reimportMostRecentLibraryScanToolStripMenuItem,
this.beginImportingBookDetailsToolStripMenuItem});
this.indexToolStripMenuItem.Name = "indexToolStripMenuItem";
this.indexToolStripMenuItem.Size = new System.Drawing.Size(47, 20);
this.indexToolStripMenuItem.Text = "&Index";
this.indexToolStripMenuItem.DropDownOpening += new System.EventHandler(this.indexToolStripMenuItem_DropDownOpening);
this.importToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.scanLibraryToolStripMenuItem});
this.importToolStripMenuItem.Name = "importToolStripMenuItem";
this.importToolStripMenuItem.Size = new System.Drawing.Size(47, 20);
this.importToolStripMenuItem.Text = "&Import";
//
// scanLibraryToolStripMenuItem
//
this.scanLibraryToolStripMenuItem.Name = "scanLibraryToolStripMenuItem";
this.scanLibraryToolStripMenuItem.Size = new System.Drawing.Size(277, 22);
this.scanLibraryToolStripMenuItem.Text = "Scan &Library...";
this.scanLibraryToolStripMenuItem.Text = "Scan &Library";
this.scanLibraryToolStripMenuItem.Click += new System.EventHandler(this.scanLibraryToolStripMenuItem_Click);
//
// reimportMostRecentLibraryScanToolStripMenuItem
//
this.reimportMostRecentLibraryScanToolStripMenuItem.Name = "reimportMostRecentLibraryScanToolStripMenuItem";
this.reimportMostRecentLibraryScanToolStripMenuItem.Size = new System.Drawing.Size(277, 22);
this.reimportMostRecentLibraryScanToolStripMenuItem.Text = "Re-&import most recent library scan: {0}";
this.reimportMostRecentLibraryScanToolStripMenuItem.Click += new System.EventHandler(this.reimportMostRecentLibraryScanToolStripMenuItem_Click);
//
// beginImportingBookDetailsToolStripMenuItem
//
this.beginImportingBookDetailsToolStripMenuItem.Name = "beginImportingBookDetailsToolStripMenuItem";
this.beginImportingBookDetailsToolStripMenuItem.Size = new System.Drawing.Size(277, 22);
this.beginImportingBookDetailsToolStripMenuItem.Text = "Begin importing book details: {0}";
this.beginImportingBookDetailsToolStripMenuItem.Click += new System.EventHandler(this.beginImportingBookDetailsToolStripMenuItem_Click);
//
// liberateToolStripMenuItem
//
this.liberateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -277,7 +258,7 @@
#endregion
private System.Windows.Forms.Panel gridPanel;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem indexToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem importToolStripMenuItem;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel springLbl;
private System.Windows.Forms.ToolStripStatusLabel visibleCountLbl;
@ -291,8 +272,6 @@
private System.Windows.Forms.Button filterHelpBtn;
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem scanLibraryToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem reimportMostRecentLibraryScanToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem beginImportingBookDetailsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem quickFiltersToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem firstFilterIsDefaultToolStripMenuItem;
private System.Windows.Forms.Button addFilterBtn;

View file

@ -8,7 +8,6 @@ using Dinah.Core;
using Dinah.Core.Collections.Generic;
using Dinah.Core.Windows.Forms;
using FileManager;
using ScrapingDomainServices;
namespace LibationWinForm
{
@ -21,9 +20,6 @@ namespace LibationWinForm
private string pdfsCountsLbl_Format { get; }
private string visibleCountLbl_Format { get; }
private string reimportMostRecentLibraryScanToolStripMenuItem_format { get; }
private string beginImportingBookDetailsToolStripMenuItem_format { get; }
private string beginBookBackupsToolStripMenuItem_format { get; }
private string beginPdfBackupsToolStripMenuItem_format { get; }
@ -36,9 +32,6 @@ namespace LibationWinForm
pdfsCountsLbl_Format = pdfsCountsLbl.Text;
visibleCountLbl_Format = visibleCountLbl.Text;
reimportMostRecentLibraryScanToolStripMenuItem_format = reimportMostRecentLibraryScanToolStripMenuItem.Text;
beginImportingBookDetailsToolStripMenuItem_format = beginImportingBookDetailsToolStripMenuItem.Text;
beginBookBackupsToolStripMenuItem_format = beginBookBackupsToolStripMenuItem.Text;
beginPdfBackupsToolStripMenuItem_format = beginPdfBackupsToolStripMenuItem.Text;
}
@ -258,150 +251,22 @@ namespace LibationWinForm
doFilter();
}
}
#endregion
#region index menu
//
// IMPORTANT
//
// IRunnableDialog.Run() extension method contains work flow
//
#region // example code: chaining multiple dialogs
public class MyDialog1 : IRunnableDialog
{
public IEnumerable<string> Files;
public IButtonControl AcceptButton { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public Control.ControlCollection Controls => throw new NotImplementedException();
public string SuccessMessage => throw new NotImplementedException();
public DialogResult DialogResult { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public void Close() => throw new NotImplementedException();
public Task DoMainWorkAsync() => throw new NotImplementedException();
public DialogResult ShowDialog() => throw new NotImplementedException();
public string StringBasedValidate() => throw new NotImplementedException();
}
public class MyDialog2 : Form, IIndexLibraryDialog
{
public MyDialog2(IEnumerable<string> files) { }
Button BeginFileImportBtn = new Button();
public void Begin() => BeginFileImportBtn.PerformClick();
public int TotalBooksProcessed => throw new NotImplementedException();
public int NewBooksAdded => throw new NotImplementedException();
public string SuccessMessage => throw new NotImplementedException();
public Task DoMainWorkAsync() => throw new NotImplementedException();
public string StringBasedValidate() => throw new NotImplementedException();
}
private async void downloadPagesToFile(object sender, EventArgs e)
{
var dialog1 = new MyDialog1();
if (dialog1.RunDialog() != DialogResult.OK || !dialog1.Files.Any())
return;
if (MessageBox.Show("Index from these files?", "Index?", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
var dialog2 = new MyDialog2(dialog1.Files);
dialog2.Shown += (_, __) => dialog2.Begin();
await indexDialog(dialog2);
}
}
#endregion
private void indexToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
{
#region label: Re-import most recent library scan
{
var libDir = WebpageStorage.GetMostRecentLibraryDir();
if (libDir == null)
{
reimportMostRecentLibraryScanToolStripMenuItem.Enabled = false;
reimportMostRecentLibraryScanToolStripMenuItem.Text = string.Format(reimportMostRecentLibraryScanToolStripMenuItem_format, "No previous scans");
}
else
{
reimportMostRecentLibraryScanToolStripMenuItem.Enabled = true;
var now = DateTime.Now;
var span = now - libDir.CreationTime;
var ago
// less than 1 min
= (int)span.TotalSeconds < 60 ? $"{(int)span.TotalSeconds} sec ago"
// less than 1 hr
: (int)span.TotalMinutes < 60 ? $"{(int)span.TotalMinutes} min ago"
// today. eg: 4:25 PM
: now.Date == libDir.CreationTime.Date ? libDir.CreationTime.ToString("h:mm tt")
// else date and time
: libDir.CreationTime.ToString("MM/dd/yyyy h:mm tt");
reimportMostRecentLibraryScanToolStripMenuItem.Text = string.Format(reimportMostRecentLibraryScanToolStripMenuItem_format, ago);
}
}
#endregion
#region label: Begin importing book details
{
var noDetails = BookQueries.BooksWithoutDetailsCount();
if (noDetails == 0)
{
beginImportingBookDetailsToolStripMenuItem.Enabled = false;
beginImportingBookDetailsToolStripMenuItem.Text = string.Format(beginImportingBookDetailsToolStripMenuItem_format, "No books without details");
}
else
{
beginImportingBookDetailsToolStripMenuItem.Enabled = true;
beginImportingBookDetailsToolStripMenuItem.Text = string.Format(beginImportingBookDetailsToolStripMenuItem_format, $"{noDetails} remaining");
}
}
#endregion
}
#endregion
#region index menu
private async void scanLibraryToolStripMenuItem_Click(object sender, EventArgs e)
{
// legacy/scraping method
//await indexDialog(new ScanLibraryDialog());
// new/api method
await indexDialog(new IndexLibraryDialog());
}
var dialog = new IndexLibraryDialog();
private async void reimportMostRecentLibraryScanToolStripMenuItem_Click(object sender, EventArgs e)
{
// DO NOT ConfigureAwait(false)
// this would result in index() => reloadGrid() => setGrid() => "gridPanel.Controls.Remove(currProductsGrid);"
// throwing 'Cross-thread operation not valid: Control 'ProductsGrid' accessed from a thread other than the thread it was created on.'
var (TotalBooksProcessed, NewBooksAdded) = await Indexer.IndexLibraryAsync(WebpageStorage.GetMostRecentLibraryDir());
if (dialog.RunDialog().In(DialogResult.Abort, DialogResult.Cancel, DialogResult.None))
return;
MessageBox.Show($"Total processed: {TotalBooksProcessed}\r\nNew: {NewBooksAdded}");
await indexComplete(TotalBooksProcessed, NewBooksAdded);
}
private async Task indexDialog(IIndexLibraryDialog dialog)
{
if (!dialog.RunDialog().In(DialogResult.Abort, DialogResult.Cancel, DialogResult.None))
await indexComplete(dialog.TotalBooksProcessed, dialog.NewBooksAdded);
}
private async Task indexComplete(int totalBooksProcessed, int newBooksAdded)
{
// update backup counts if we have new library items
if (newBooksAdded > 0)
if (dialog.NewBooksAdded > 0)
await setBackupCountsAsync();
// skip reload if:
// - no grid is loaded
// - none indexed
if (currProductsGrid == null || totalBooksProcessed == 0)
return;
reloadGrid();
}
private void updateGridRow(object _, string productId) => currProductsGrid?.UpdateRow(productId);
private async void beginImportingBookDetailsToolStripMenuItem_Click(object sender, EventArgs e)
{
var scrapeBookDetails = BookLiberation.ProcessorAutomationController.GetWiredUpScrapeBookDetails();
scrapeBookDetails.BookSuccessfullyImported += updateGridRow;
await BookLiberation.ProcessorAutomationController.RunAutomaticDownload(scrapeBookDetails);
if (dialog.TotalBooksProcessed > 0)
reloadGrid();
}
#endregion

View file

@ -208,7 +208,7 @@ namespace LibationWinForm
{
book.UserDefinedItem.Tags = newTags;
var qtyChanges = ScrapingDomainServices.Indexer.IndexChangedTags(book);
var qtyChanges = ApplicationServices.TagUpdater.IndexChangedTags(book);
return qtyChanges;
}