This commit is contained in:
MBucari 2023-03-25 16:33:00 -06:00
parent fc6f494f0d
commit 397a516dc1
11 changed files with 60 additions and 10 deletions

View File

@ -229,7 +229,7 @@ namespace ApplicationServices
{
var tasks = new List<Task<List<ImportItem>>>();
await using LogArchiver archiver
await using LogArchiver archiver
= Log.Logger.IsDebugEnabled()
? new LogArchiver(System.IO.Path.Combine(Configuration.Instance.LibationFiles, "LibraryScans.zip"))
: default;
@ -238,16 +238,24 @@ namespace ApplicationServices
foreach (var account in accounts)
{
// get APIs in serial b/c of logins. do NOT move inside of parallel (Task.WhenAll)
var apiExtended = await apiExtendedfunc(account);
try
{
// get APIs in serial b/c of logins. do NOT move inside of parallel (Task.WhenAll)
var apiExtended = await apiExtendedfunc(account);
// add scanAccountAsync as a TASK: do not await
tasks.Add(scanAccountAsync(apiExtended, account, libraryOptions, archiver));
// add scanAccountAsync as a TASK: do not await
tasks.Add(scanAccountAsync(apiExtended, account, libraryOptions, archiver));
}
catch(Exception ex)
{
//Catch to allow other accounts to continue scanning.
Log.Logger.Error(ex, "Failed to scan account");
}
}
// import library in parallel
var arrayOfLists = await Task.WhenAll(tasks);
var importItems = arrayOfLists.SelectMany(a => a).ToList();
var importItems = arrayOfLists.SelectMany(a => a).ToList();
return importItems;
}

View File

@ -25,7 +25,7 @@ namespace LibationAvalonia.Dialogs.Login
{
var dialog = new LoginChoiceEagerDialog(_account);
if (await dialog.ShowDialogAsync() is not DialogResult.OK)
if (await dialog.ShowDialogAsync() is not DialogResult.OK || string.IsNullOrWhiteSpace(dialog.Password))
return null;
switch (dialog.LoginMethod)

View File

@ -4,6 +4,7 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using System.Linq;
using System.Threading.Tasks;
namespace LibationAvalonia.Dialogs.Login
{
@ -31,6 +32,17 @@ namespace LibationAvalonia.Dialogs.Login
DataContext = this;
}
protected override async Task SaveAndCloseAsync()
{
if (string.IsNullOrWhiteSpace(Password))
{
await MessageBox.Show(this, "Please enter your password");
return;
}
await base.SaveAndCloseAsync();
}
public async void ExternalLoginLink_Tapped(object sender, Avalonia.Input.TappedEventArgs e)
{
LoginMethod = LoginMethod.External;

View File

@ -427,6 +427,10 @@ namespace LibationAvalonia.ViewModels
foreach (var r in removable)
r.Remove = true;
}
catch (OperationCanceledException)
{
Serilog.Log.Information("Audible login attempt cancelled by user");
}
catch (Exception ex)
{
await MessageBox.ShowAdminAlert(

View File

@ -32,6 +32,10 @@ namespace LibationAvalonia.Views
{
await LibraryCommands.ImportAccountAsync(Dialogs.Login.AvaloniaLoginChoiceEager.ApiExtendedFunc, accounts);
}
catch (OperationCanceledException)
{
Serilog.Log.Information("Audible login attempt cancelled by user");
}
catch (Exception ex)
{
Serilog.Log.Logger.Error(ex, "Error invoking auto-scan");

View File

@ -69,6 +69,10 @@ namespace LibationAvalonia.Views
if (Configuration.Instance.ShowImportedStats && newAdded > 0)
await MessageBox.Show($"Total processed: {totalProcessed}\r\nNew: {newAdded}");
}
catch(OperationCanceledException)
{
Serilog.Log.Information("Audible login attempt cancelled by user");
}
catch (Exception ex)
{
await MessageBox.ShowAdminAlert(

View File

@ -37,6 +37,12 @@ namespace LibationWinForms.Dialogs.Login
Email = accountId;
Password = this.passwordTb.Text;
if (string.IsNullOrWhiteSpace(Password))
{
MessageBox.Show("Please enter your password");
return;
}
Serilog.Log.Logger.Information("Submit button clicked: {@DebugInfo}", new { email = Email?.ToMask(), passwordLength = Password.Length });
LoginMethod = AudibleApi.LoginMethod.Api;

View File

@ -25,7 +25,7 @@ namespace LibationWinForms.Login
{
using var dialog = new LoginChoiceEagerDialog(_account);
if (!ShowDialog(dialog))
if (!ShowDialog(dialog) || string.IsNullOrWhiteSpace(dialog.Password))
return null;
switch (dialog.LoginMethod)

View File

@ -38,7 +38,11 @@ namespace LibationWinForms
else
await importAsync();
}
catch (Exception ex)
catch (OperationCanceledException)
{
Serilog.Log.Information("Audible login attempt cancelled by user");
}
catch (Exception ex)
{
Serilog.Log.Logger.Error(ex, "Error invoking auto-scan");
}

View File

@ -80,6 +80,10 @@ namespace LibationWinForms
if (Configuration.Instance.ShowImportedStats && newAdded > 0)
MessageBox.Show($"Total processed: {totalProcessed}\r\nNew: {newAdded}");
}
catch (OperationCanceledException)
{
Serilog.Log.Information("Audible login attempt cancelled by user");
}
catch (Exception ex)
{
MessageBoxLib.ShowAdminAlert(

View File

@ -288,6 +288,10 @@ namespace LibationWinForms.GridView
productsGrid_RemovableCountChanged(this, null);
}
catch (OperationCanceledException)
{
Serilog.Log.Information("Audible login attempt cancelled by user");
}
catch (Exception ex)
{
MessageBoxLib.ShowAdminAlert(