book liberation status Error:
* show system error icon in grid instead of stoplight * list error count in bottom right #s * SearchEngine bool: LiberatedError
This commit is contained in:
parent
722c33bf61
commit
e723467ca6
@ -190,7 +190,7 @@ namespace ApplicationServices
|
|||||||
|
|
||||||
// below are queries, not commands. maybe I should make a LibraryQueries. except there's already one of those...
|
// below are queries, not commands. maybe I should make a LibraryQueries. except there's already one of those...
|
||||||
|
|
||||||
public record LibraryStats(int booksFullyBackedUp, int booksDownloadedOnly, int booksNoProgress, int pdfsDownloaded, int pdfsNotDownloaded) { }
|
public record LibraryStats(int booksFullyBackedUp, int booksDownloadedOnly, int booksNoProgress, int booksError, int pdfsDownloaded, int pdfsNotDownloaded) { }
|
||||||
public static LibraryStats GetCounts()
|
public static LibraryStats GetCounts()
|
||||||
{
|
{
|
||||||
var libraryBooks = DbContexts.GetContext().GetLibrary_Flat_NoTracking();
|
var libraryBooks = DbContexts.GetContext().GetLibrary_Flat_NoTracking();
|
||||||
@ -202,8 +202,9 @@ namespace ApplicationServices
|
|||||||
var booksFullyBackedUp = results.Count(r => r == LiberatedStatus.Liberated);
|
var booksFullyBackedUp = results.Count(r => r == LiberatedStatus.Liberated);
|
||||||
var booksDownloadedOnly = results.Count(r => r == LiberatedStatus.PartialDownload);
|
var booksDownloadedOnly = results.Count(r => r == LiberatedStatus.PartialDownload);
|
||||||
var booksNoProgress = results.Count(r => r == LiberatedStatus.NotLiberated);
|
var booksNoProgress = results.Count(r => r == LiberatedStatus.NotLiberated);
|
||||||
|
var booksError = results.Count(r => r == LiberatedStatus.Error);
|
||||||
|
|
||||||
Log.Logger.Information("Book counts. {@DebugInfo}", new { total = results.Count, booksFullyBackedUp, booksDownloadedOnly, booksNoProgress });
|
Log.Logger.Information("Book counts. {@DebugInfo}", new { total = results.Count, booksFullyBackedUp, booksDownloadedOnly, booksNoProgress, booksError });
|
||||||
|
|
||||||
var boolResults = libraryBooks
|
var boolResults = libraryBooks
|
||||||
.AsParallel()
|
.AsParallel()
|
||||||
@ -215,7 +216,7 @@ namespace ApplicationServices
|
|||||||
|
|
||||||
Log.Logger.Information("PDF counts. {@DebugInfo}", new { total = boolResults.Count, pdfsDownloaded, pdfsNotDownloaded });
|
Log.Logger.Information("PDF counts. {@DebugInfo}", new { total = boolResults.Count, pdfsDownloaded, pdfsNotDownloaded });
|
||||||
|
|
||||||
return new(booksFullyBackedUp, booksDownloadedOnly, booksNoProgress, pdfsDownloaded, pdfsNotDownloaded);
|
return new(booksFullyBackedUp, booksDownloadedOnly, booksNoProgress, booksError, pdfsDownloaded, pdfsNotDownloaded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>5.5.8.3</Version>
|
<Version>5.5.9.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
@ -9,24 +9,24 @@ using Lucene.Net.Search;
|
|||||||
namespace LibationSearchEngine
|
namespace LibationSearchEngine
|
||||||
{
|
{
|
||||||
// field names are case specific and, due to StandardAnalyzer, content is case INspecific
|
// field names are case specific and, due to StandardAnalyzer, content is case INspecific
|
||||||
public static class LuceneExtensions
|
internal static class LuceneExtensions
|
||||||
{
|
{
|
||||||
public static void AddRaw(this Document document, string name, string value)
|
internal static void AddRaw(this Document document, string name, string value)
|
||||||
=> document.Add(new Field(name, value, Field.Store.YES, Field.Index.NOT_ANALYZED));
|
=> document.Add(new Field(name, value, Field.Store.YES, Field.Index.NOT_ANALYZED));
|
||||||
|
|
||||||
public static void AddAnalyzed(this Document document, string name, string value)
|
internal static void AddAnalyzed(this Document document, string name, string value)
|
||||||
{
|
{
|
||||||
if (value != null)
|
if (value != null)
|
||||||
document.Add(new Field(name.ToLowerInvariant(), value, Field.Store.YES, Field.Index.ANALYZED));
|
document.Add(new Field(name.ToLowerInvariant(), value, Field.Store.YES, Field.Index.ANALYZED));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddNotAnalyzed(this Document document, string name, string value)
|
internal static void AddNotAnalyzed(this Document document, string name, string value)
|
||||||
=> document.Add(new Field(name.ToLowerInvariant(), value, Field.Store.YES, Field.Index.NOT_ANALYZED));
|
=> document.Add(new Field(name.ToLowerInvariant(), value, Field.Store.YES, Field.Index.NOT_ANALYZED));
|
||||||
|
|
||||||
public static void AddBool(this Document document, string name, bool value)
|
internal static void AddBool(this Document document, string name, bool value)
|
||||||
=> document.Add(new Field(name.ToLowerInvariant(), value.ToString(), Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));
|
=> document.Add(new Field(name.ToLowerInvariant(), value.ToString(), Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));
|
||||||
|
|
||||||
public static Query GetQuery(this Analyzer analyzer, string defaultField, string searchString)
|
internal static Query GetQuery(this Analyzer analyzer, string defaultField, string searchString)
|
||||||
=> new QueryParser(SearchEngine.Version, defaultField.ToLowerInvariant(), analyzer).Parse(searchString);
|
=> new QueryParser(SearchEngine.Version, defaultField.ToLowerInvariant(), analyzer).Parse(searchString);
|
||||||
|
|
||||||
// put all numbers, including dates, into this format:
|
// put all numbers, including dates, into this format:
|
||||||
|
|||||||
@ -77,7 +77,6 @@ Purchase Date: {_libraryBook.DateAdded.ToString("d")}
|
|||||||
if (status == LiberatedStatus.Error)
|
if (status == LiberatedStatus.Error)
|
||||||
this.bookLiberatedCb.Items.Add(new liberatedComboBoxItem { Status = LiberatedStatus.Error, Text = "Error" });
|
this.bookLiberatedCb.Items.Add(new liberatedComboBoxItem { Status = LiberatedStatus.Error, Text = "Error" });
|
||||||
|
|
||||||
|
|
||||||
setDefaultComboBox(this.bookLiberatedCb, status);
|
setDefaultComboBox(this.bookLiberatedCb, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,6 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
// also applies filter. ONLY call AFTER loading grid
|
// also applies filter. ONLY call AFTER loading grid
|
||||||
loadInitialQuickFilterState();
|
loadInitialQuickFilterState();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
@ -172,26 +171,26 @@ namespace LibationWinForms
|
|||||||
#region bottom: backup counts
|
#region bottom: backup counts
|
||||||
private async void setBackupCountsAsync(object _, object __)
|
private async void setBackupCountsAsync(object _, object __)
|
||||||
{
|
{
|
||||||
LibraryCommands.LibraryStats libraryStats = null;
|
var libraryStats = await Task.Run(() => LibraryCommands.GetCounts());
|
||||||
await Task.Run(() => libraryStats = LibraryCommands.GetCounts());
|
|
||||||
|
|
||||||
setBookBackupCounts(libraryStats.booksFullyBackedUp, libraryStats.booksDownloadedOnly, libraryStats.booksNoProgress);
|
setBookBackupCounts(libraryStats);
|
||||||
setPdfBackupCounts(libraryStats.pdfsDownloaded, libraryStats.pdfsNotDownloaded);
|
setPdfBackupCounts(libraryStats);
|
||||||
}
|
}
|
||||||
private void setBookBackupCounts(int booksFullyBackedUp, int booksDownloadedOnly, int booksNoProgress)
|
private void setBookBackupCounts(LibraryCommands.LibraryStats libraryStats)
|
||||||
{
|
{
|
||||||
var backupsCountsLbl_Format = "BACKUPS: No progress: {0} Encrypted: {1} Fully backed up: {2}";
|
var backupsCountsLbl_Format = "BACKUPS: No progress: {0} Encrypted: {1} Fully backed up: {2}";
|
||||||
|
|
||||||
// enable/disable export
|
// enable/disable export
|
||||||
var hasResults = 0 < (booksFullyBackedUp + booksDownloadedOnly + booksNoProgress);
|
var hasResults = 0 < (libraryStats.booksFullyBackedUp + libraryStats.booksDownloadedOnly + libraryStats.booksNoProgress + libraryStats.booksError);
|
||||||
exportLibraryToolStripMenuItem.Enabled = hasResults;
|
exportLibraryToolStripMenuItem.Enabled = hasResults;
|
||||||
|
|
||||||
// update bottom numbers
|
// update bottom numbers
|
||||||
var pending = booksNoProgress + booksDownloadedOnly;
|
var pending = libraryStats.booksNoProgress + libraryStats.booksDownloadedOnly;
|
||||||
var statusStripText
|
var statusStripText
|
||||||
= !hasResults ? "No books. Begin by importing your library"
|
= !hasResults ? "No books. Begin by importing your library"
|
||||||
: pending > 0 ? string.Format(backupsCountsLbl_Format, booksNoProgress, booksDownloadedOnly, booksFullyBackedUp)
|
: libraryStats.booksError > 0 ? string.Format(backupsCountsLbl_Format + " Errors: {3}", libraryStats.booksNoProgress, libraryStats.booksDownloadedOnly, libraryStats.booksFullyBackedUp, libraryStats.booksError)
|
||||||
: $"All {"book".PluralizeWithCount(booksFullyBackedUp)} backed up";
|
: pending > 0 ? string.Format(backupsCountsLbl_Format, libraryStats.booksNoProgress, libraryStats.booksDownloadedOnly, libraryStats.booksFullyBackedUp)
|
||||||
|
: $"All {"book".PluralizeWithCount(libraryStats.booksFullyBackedUp)} backed up";
|
||||||
|
|
||||||
// update menu item
|
// update menu item
|
||||||
var menuItemText
|
var menuItemText
|
||||||
@ -204,26 +203,26 @@ namespace LibationWinForms
|
|||||||
menuStrip1.UIThread(() => beginBookBackupsToolStripMenuItem.Enabled = pending > 0);
|
menuStrip1.UIThread(() => beginBookBackupsToolStripMenuItem.Enabled = pending > 0);
|
||||||
menuStrip1.UIThread(() => beginBookBackupsToolStripMenuItem.Text = string.Format(beginBookBackupsToolStripMenuItem_format, menuItemText));
|
menuStrip1.UIThread(() => beginBookBackupsToolStripMenuItem.Text = string.Format(beginBookBackupsToolStripMenuItem_format, menuItemText));
|
||||||
}
|
}
|
||||||
private void setPdfBackupCounts(int pdfsDownloaded, int pdfsNotDownloaded)
|
private void setPdfBackupCounts(LibraryCommands.LibraryStats libraryStats)
|
||||||
{
|
{
|
||||||
var pdfsCountsLbl_Format = "| PDFs: NOT d/l\'ed: {0} Downloaded: {1}";
|
var pdfsCountsLbl_Format = "| PDFs: NOT d/l\'ed: {0} Downloaded: {1}";
|
||||||
|
|
||||||
// update bottom numbers
|
// update bottom numbers
|
||||||
var hasResults = 0 < (pdfsNotDownloaded + pdfsDownloaded);
|
var hasResults = 0 < (libraryStats.pdfsNotDownloaded + libraryStats.pdfsDownloaded);
|
||||||
var statusStripText
|
var statusStripText
|
||||||
= !hasResults ? ""
|
= !hasResults ? ""
|
||||||
: pdfsNotDownloaded > 0 ? string.Format(pdfsCountsLbl_Format, pdfsNotDownloaded, pdfsDownloaded)
|
: libraryStats.pdfsNotDownloaded > 0 ? string.Format(pdfsCountsLbl_Format, libraryStats.pdfsNotDownloaded, libraryStats.pdfsDownloaded)
|
||||||
: $"| All {pdfsDownloaded} PDFs downloaded";
|
: $"| All {libraryStats.pdfsDownloaded} PDFs downloaded";
|
||||||
|
|
||||||
// update menu item
|
// update menu item
|
||||||
var menuItemText
|
var menuItemText
|
||||||
= pdfsNotDownloaded > 0
|
= libraryStats.pdfsNotDownloaded > 0
|
||||||
? $"{pdfsNotDownloaded} remaining"
|
? $"{libraryStats.pdfsNotDownloaded} remaining"
|
||||||
: "All PDFs have been downloaded";
|
: "All PDFs have been downloaded";
|
||||||
|
|
||||||
// update UI
|
// update UI
|
||||||
statusStrip1.UIThread(() => pdfsCountsLbl.Text = statusStripText);
|
statusStrip1.UIThread(() => pdfsCountsLbl.Text = statusStripText);
|
||||||
menuStrip1.UIThread(() => beginPdfBackupsToolStripMenuItem.Enabled = pdfsNotDownloaded > 0);
|
menuStrip1.UIThread(() => beginPdfBackupsToolStripMenuItem.Enabled = libraryStats.pdfsNotDownloaded > 0);
|
||||||
menuStrip1.UIThread(() => beginPdfBackupsToolStripMenuItem.Text = string.Format(beginPdfBackupsToolStripMenuItem_format, menuItemText));
|
menuStrip1.UIThread(() => beginPdfBackupsToolStripMenuItem.Text = string.Format(beginPdfBackupsToolStripMenuItem_format, menuItemText));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -35,12 +35,14 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
private static (string mouseoverText, Bitmap buttonImage) GetLiberateDisplay(LiberatedStatus liberatedStatus, LiberatedStatus? pdfStatus)
|
private static (string mouseoverText, Bitmap buttonImage) GetLiberateDisplay(LiberatedStatus liberatedStatus, LiberatedStatus? pdfStatus)
|
||||||
{
|
{
|
||||||
|
if (liberatedStatus == LiberatedStatus.Error)
|
||||||
|
return ("Book downloaded ERROR", SystemIcons.Error.ToBitmap());
|
||||||
|
|
||||||
(string libState, string image_lib) = liberatedStatus switch
|
(string libState, string image_lib) = liberatedStatus switch
|
||||||
{
|
{
|
||||||
LiberatedStatus.Liberated => ("Liberated", "green"),
|
LiberatedStatus.Liberated => ("Liberated", "green"),
|
||||||
LiberatedStatus.PartialDownload => ("File has been at least\r\npartially downloaded", "yellow"),
|
LiberatedStatus.PartialDownload => ("File has been at least\r\npartially downloaded", "yellow"),
|
||||||
LiberatedStatus.NotLiberated => ("Book NOT downloaded", "red"),
|
LiberatedStatus.NotLiberated => ("Book NOT downloaded", "red"),
|
||||||
LiberatedStatus.Error => ("Book downloaded ERROR", "red"),
|
|
||||||
_ => throw new Exception("Unexpected liberation state")
|
_ => throw new Exception("Unexpected liberation state")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user