Revert "Added count of items removed from library."

This reverts commit 771d992da718da66319fadf129655137f4e8b6c3.
This commit is contained in:
Michael Bucari-Tovo 2021-07-02 15:23:26 -06:00
parent 771d992da7
commit 35fc3581b3
4 changed files with 10 additions and 14 deletions

View File

@ -13,10 +13,10 @@ namespace ApplicationServices
{ {
public static class LibraryCommands public static class LibraryCommands
{ {
public static async Task<(int totalCount, int newCount, int removedCount)> ImportAccountAsync(Func<Account, ILoginCallback> loginCallbackFactoryFunc, params Account[] accounts) public static async Task<(int totalCount, int newCount)> ImportAccountAsync(Func<Account, ILoginCallback> loginCallbackFactoryFunc, params Account[] accounts)
{ {
if (accounts is null || accounts.Length == 0) if (accounts is null || accounts.Length == 0)
return (0, 0, 0); return (0, 0);
try try
{ {
@ -25,13 +25,13 @@ namespace ApplicationServices
var totalCount = importItems.Count; var totalCount = importItems.Count;
Log.Logger.Information($"GetAllLibraryItems: Total count {totalCount}"); Log.Logger.Information($"GetAllLibraryItems: Total count {totalCount}");
(var newCount, var removedCount) = await importIntoDbAsync(importItems); var newCount = await importIntoDbAsync(importItems);
Log.Logger.Information($"Import: New count {newCount}"); Log.Logger.Information($"Import: New count {newCount}");
await Task.Run(() => SearchEngineCommands.FullReIndex()); await Task.Run(() => SearchEngineCommands.FullReIndex());
Log.Logger.Information("FullReIndex: success"); Log.Logger.Information("FullReIndex: success");
return (totalCount, newCount, removedCount); return (totalCount, newCount);
} }
catch (AudibleApi.Authentication.LoginFailedException lfEx) catch (AudibleApi.Authentication.LoginFailedException lfEx)
{ {
@ -90,16 +90,14 @@ namespace ApplicationServices
return dtoItems.Select(d => new ImportItem { DtoItem = d, AccountId = account.AccountId, LocaleName = account.Locale?.Name }).ToList(); return dtoItems.Select(d => new ImportItem { DtoItem = d, AccountId = account.AccountId, LocaleName = account.Locale?.Name }).ToList();
} }
private static async Task<(ushort newCount, ushort removedCount)> importIntoDbAsync(List<ImportItem> importItems) private static async Task<int> importIntoDbAsync(List<ImportItem> importItems)
{ {
using var context = DbContexts.GetContext(); using var context = DbContexts.GetContext();
var libraryImporter = new LibraryImporter(context); var libraryImporter = new LibraryImporter(context);
var newAndRemoved = await Task.Run(() => libraryImporter.Import(importItems)); var newCount = await Task.Run(() => libraryImporter.Import(importItems));
context.SaveChanges(); context.SaveChanges();
var newCount = (ushort)(newAndRemoved >> 0x10); return newCount;
var removedCount = (ushort)(newAndRemoved & 0xffff);
return (newCount, removedCount);
} }
public static int UpdateTags(this LibationContext context, Book book, string newTags) public static int UpdateTags(this LibationContext context, Book book, string newTags)

View File

@ -62,7 +62,7 @@ namespace DtoImporterService
var qtyNew = newItems.Count(); var qtyNew = newItems.Count();
var qtyRemoved = removedItems.Count(); var qtyRemoved = removedItems.Count();
return (qtyNew << 0x10) | (qtyRemoved & 0xffff); return qtyNew;
} }
} }
} }

View File

@ -11,7 +11,6 @@ namespace LibationWinForms.Dialogs
private Account[] _accounts { get; } private Account[] _accounts { get; }
public int NewBooksAdded { get; private set; } public int NewBooksAdded { get; private set; }
public int OldBooksRemoved { get; private set; }
public int TotalBooksProcessed { get; private set; } public int TotalBooksProcessed { get; private set; }
public IndexLibraryDialog(params Account[] accounts) public IndexLibraryDialog(params Account[] accounts)
@ -32,7 +31,7 @@ namespace LibationWinForms.Dialogs
try try
{ {
(TotalBooksProcessed, NewBooksAdded, OldBooksRemoved) = await LibraryCommands.ImportAccountAsync((account) => new WinformResponder(account), _accounts); (TotalBooksProcessed, NewBooksAdded) = await LibraryCommands.ImportAccountAsync((account) => new WinformResponder(account), _accounts);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -284,9 +284,8 @@ namespace LibationWinForms
var totalProcessed = dialog.TotalBooksProcessed; var totalProcessed = dialog.TotalBooksProcessed;
var newAdded = dialog.NewBooksAdded; var newAdded = dialog.NewBooksAdded;
var oldRemoved = dialog.OldBooksRemoved;
MessageBox.Show($"Total processed: {totalProcessed}\r\nNew: {newAdded}\r\nRemoved: {oldRemoved}"); MessageBox.Show($"Total processed: {totalProcessed}\r\nNew: {newAdded}");
if (totalProcessed > 0) if (totalProcessed > 0)
reloadGrid(); reloadGrid();