* #396 New feature : match download status to files
* UI: Visible Books \> Set 'Downloaded' status automatically. Visible books. Prompts before saving changes * CLI: Full library. No prompt
This commit is contained in:
parent
a54516b4f5
commit
c4cebbebe7
@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<Version>8.5.1.1</Version>
|
<Version>8.6.0.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Octokit" Version="4.0.1" />
|
<PackageReference Include="Octokit" Version="4.0.1" />
|
||||||
|
|||||||
78
Source/ApplicationServices/BulkSetDownloadStatus.cs
Normal file
78
Source/ApplicationServices/BulkSetDownloadStatus.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DataLayer;
|
||||||
|
using Dinah.Core;
|
||||||
|
using LibationFileManager;
|
||||||
|
|
||||||
|
namespace ApplicationServices
|
||||||
|
{
|
||||||
|
public class BulkSetDownloadStatus
|
||||||
|
{
|
||||||
|
private List<(string message, LiberatedStatus newStatus, IEnumerable<Book> Books)> actionSets { get; } = new();
|
||||||
|
|
||||||
|
public int Count => actionSets.Count;
|
||||||
|
|
||||||
|
public IEnumerable<string> Messages => actionSets.Select(a => a.message);
|
||||||
|
public string AggregateMessage => $"Are you sure you want to set {Messages.Aggregate((a, b) => $"{a} and {b}")}?";
|
||||||
|
|
||||||
|
private List<LibraryBook> _libraryBooks;
|
||||||
|
private bool _setDownloaded;
|
||||||
|
private bool _setNotDownloaded;
|
||||||
|
|
||||||
|
public BulkSetDownloadStatus(List<LibraryBook> libraryBooks, bool setDownloaded, bool setNotDownloaded)
|
||||||
|
{
|
||||||
|
_libraryBooks = libraryBooks;
|
||||||
|
_setDownloaded = setDownloaded;
|
||||||
|
_setNotDownloaded = setNotDownloaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Discover()
|
||||||
|
{
|
||||||
|
var bookExistsList = _libraryBooks
|
||||||
|
.Select(libraryBook => new
|
||||||
|
{
|
||||||
|
libraryBook.Book,
|
||||||
|
FileExists = AudibleFileStorage.Audio.GetPath(libraryBook.Book.AudibleProductId) is not null
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (_setDownloaded)
|
||||||
|
{
|
||||||
|
var books2change = bookExistsList
|
||||||
|
.Where(a => a.FileExists && a.Book.UserDefinedItem.BookStatus != LiberatedStatus.Liberated)
|
||||||
|
.Select(a => a.Book)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (books2change.Any())
|
||||||
|
actionSets.Add((
|
||||||
|
$"{"book".PluralizeWithCount(books2change.Count)} to 'Downloaded'",
|
||||||
|
LiberatedStatus.Liberated,
|
||||||
|
books2change));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_setNotDownloaded)
|
||||||
|
{
|
||||||
|
var books2change = bookExistsList
|
||||||
|
.Where(a => !a.FileExists && a.Book.UserDefinedItem.BookStatus != LiberatedStatus.NotLiberated)
|
||||||
|
.Select(a => a.Book)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (books2change.Any())
|
||||||
|
actionSets.Add((
|
||||||
|
$"{"book".PluralizeWithCount(books2change.Count)} to 'Not Downloaded'",
|
||||||
|
LiberatedStatus.NotLiberated,
|
||||||
|
books2change));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Execute()
|
||||||
|
{
|
||||||
|
foreach (var a in actionSets)
|
||||||
|
a.Books.UpdateBookStatus(a.newStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,6 +9,7 @@ using Dinah.Core;
|
|||||||
using DtoImporterService;
|
using DtoImporterService;
|
||||||
using LibationFileManager;
|
using LibationFileManager;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using static System.Reflection.Metadata.BlobBuilder;
|
||||||
using static DtoImporterService.PerfLogger;
|
using static DtoImporterService.PerfLogger;
|
||||||
|
|
||||||
namespace ApplicationServices
|
namespace ApplicationServices
|
||||||
@ -366,74 +367,101 @@ namespace ApplicationServices
|
|||||||
public static event EventHandler<IEnumerable<Book>> BookUserDefinedItemCommitted;
|
public static event EventHandler<IEnumerable<Book>> BookUserDefinedItemCommitted;
|
||||||
|
|
||||||
#region Update book details
|
#region Update book details
|
||||||
public static int UpdateBookStatus(this Book book, LiberatedStatus bookStatus)
|
public static int UpdateUserDefinedItem(
|
||||||
{
|
|
||||||
book.UserDefinedItem.BookStatus = bookStatus;
|
|
||||||
return UpdateUserDefinedItem(book);
|
|
||||||
}
|
|
||||||
public static int UpdatePdfStatus(this Book book, LiberatedStatus pdfStatus)
|
|
||||||
{
|
|
||||||
book.UserDefinedItem.PdfStatus = pdfStatus;
|
|
||||||
return UpdateUserDefinedItem(book);
|
|
||||||
}
|
|
||||||
public static int UpdateBook(
|
|
||||||
this Book book,
|
this Book book,
|
||||||
string tags = null,
|
string tags = null,
|
||||||
LiberatedStatus? bookStatus = null,
|
LiberatedStatus? bookStatus = null,
|
||||||
LiberatedStatus? pdfStatus = null)
|
LiberatedStatus? pdfStatus = null)
|
||||||
=> UpdateBooks(tags, bookStatus, pdfStatus, book);
|
=> new[] { book }.UpdateUserDefinedItem(tags, bookStatus, pdfStatus);
|
||||||
public static int UpdateBooks(
|
|
||||||
|
public static int UpdateUserDefinedItem(
|
||||||
|
this IEnumerable<Book> books,
|
||||||
string tags = null,
|
string tags = null,
|
||||||
LiberatedStatus? bookStatus = null,
|
LiberatedStatus? bookStatus = null,
|
||||||
LiberatedStatus? pdfStatus = null,
|
LiberatedStatus? pdfStatus = null)
|
||||||
params Book[] books)
|
=> updateUserDefinedItem(
|
||||||
|
books,
|
||||||
|
udi => {
|
||||||
|
// blank tags are expected. null tags are not
|
||||||
|
if (tags is not null && udi.Tags != tags)
|
||||||
|
udi.Tags = tags;
|
||||||
|
|
||||||
|
if (bookStatus is not null && udi.BookStatus != bookStatus.Value)
|
||||||
|
udi.BookStatus = bookStatus.Value;
|
||||||
|
|
||||||
|
// even though PdfStatus is nullable, there's no case where we'd actually overwrite with null
|
||||||
|
if (pdfStatus is not null && udi.PdfStatus != pdfStatus.Value)
|
||||||
|
udi.PdfStatus = pdfStatus.Value;
|
||||||
|
});
|
||||||
|
|
||||||
|
public static int UpdateBookStatus(this Book book, LiberatedStatus bookStatus)
|
||||||
|
=> book.UpdateUserDefinedItem(udi => udi.BookStatus = bookStatus);
|
||||||
|
public static int UpdateBookStatus(this IEnumerable<Book> books, LiberatedStatus bookStatus)
|
||||||
|
=> books.UpdateUserDefinedItem(udi => udi.BookStatus = bookStatus);
|
||||||
|
public static int UpdateBookStatus(this LibraryBook libraryBook, LiberatedStatus bookStatus)
|
||||||
|
=> libraryBook.UpdateUserDefinedItem(udi => udi.BookStatus = bookStatus);
|
||||||
|
public static int UpdateBookStatus(this IEnumerable<LibraryBook> libraryBooks, LiberatedStatus bookStatus)
|
||||||
|
=> libraryBooks.UpdateUserDefinedItem(udi => udi.BookStatus = bookStatus);
|
||||||
|
|
||||||
|
public static int UpdatePdfStatus(this Book book, LiberatedStatus pdfStatus)
|
||||||
|
=> book.UpdateUserDefinedItem(udi => udi.PdfStatus = pdfStatus);
|
||||||
|
public static int UpdatePdfStatus(this IEnumerable<Book> books, LiberatedStatus pdfStatus)
|
||||||
|
=> books.UpdateUserDefinedItem(udi => udi.PdfStatus = pdfStatus);
|
||||||
|
public static int UpdatePdfStatus(this LibraryBook libraryBook, LiberatedStatus pdfStatus)
|
||||||
|
=> libraryBook.UpdateUserDefinedItem(udi => udi.PdfStatus = pdfStatus);
|
||||||
|
public static int UpdatePdfStatus(this IEnumerable<LibraryBook> libraryBooks, LiberatedStatus pdfStatus)
|
||||||
|
=> libraryBooks.UpdateUserDefinedItem(udi => udi.PdfStatus = pdfStatus);
|
||||||
|
|
||||||
|
public static int UpdateTags(this Book book, string tags)
|
||||||
|
=> book.UpdateUserDefinedItem(udi => udi.Tags = tags);
|
||||||
|
public static int UpdateTags(this IEnumerable<Book> books, string tags)
|
||||||
|
=> books.UpdateUserDefinedItem(udi => udi.Tags = tags);
|
||||||
|
public static int UpdateTags(this LibraryBook libraryBook, string tags)
|
||||||
|
=> libraryBook.UpdateUserDefinedItem(udi => udi.Tags = tags);
|
||||||
|
public static int UpdateTags(this IEnumerable<LibraryBook> libraryBooks, string tags)
|
||||||
|
=> libraryBooks.UpdateUserDefinedItem(udi => udi.Tags = tags);
|
||||||
|
|
||||||
|
public static int UpdateUserDefinedItem(this LibraryBook libraryBook, Action<UserDefinedItem> action)
|
||||||
|
=> libraryBook.Book.updateUserDefinedItem(action);
|
||||||
|
public static int UpdateUserDefinedItem(this IEnumerable<LibraryBook> libraryBooks, Action<UserDefinedItem> action)
|
||||||
|
=> libraryBooks.Select(lb => lb.Book).updateUserDefinedItem(action);
|
||||||
|
|
||||||
|
public static int UpdateUserDefinedItem(this Book book, Action<UserDefinedItem> action) => book.updateUserDefinedItem(action);
|
||||||
|
public static int UpdateUserDefinedItem(this IEnumerable<Book> books, Action<UserDefinedItem> action) => books.updateUserDefinedItem(action);
|
||||||
|
|
||||||
|
private static int updateUserDefinedItem(this Book book, Action<UserDefinedItem> action) => new[] { book }.updateUserDefinedItem(action);
|
||||||
|
private static int updateUserDefinedItem(this IEnumerable<Book> books, Action<UserDefinedItem> action)
|
||||||
{
|
{
|
||||||
foreach (var book in books)
|
try
|
||||||
{
|
{
|
||||||
// blank tags are expected. null tags are not
|
if (books is null || !books.Any())
|
||||||
if (tags is not null && book.UserDefinedItem.Tags != tags)
|
return 0;
|
||||||
book.UserDefinedItem.Tags = tags;
|
|
||||||
|
|
||||||
if (bookStatus is not null && book.UserDefinedItem.BookStatus != bookStatus.Value)
|
|
||||||
book.UserDefinedItem.BookStatus = bookStatus.Value;
|
|
||||||
|
|
||||||
// even though PdfStatus is nullable, there's no case where we'd actually overwrite with null
|
|
||||||
if (pdfStatus is not null && book.UserDefinedItem.PdfStatus != pdfStatus.Value)
|
|
||||||
book.UserDefinedItem.PdfStatus = pdfStatus.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return UpdateUserDefinedItem(books);
|
|
||||||
}
|
|
||||||
public static int UpdateUserDefinedItem(params Book[] books) => UpdateUserDefinedItem(books.ToList());
|
|
||||||
public static int UpdateUserDefinedItem(IEnumerable<Book> books)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (books is null || !books.Any())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
using var context = DbContexts.GetContext();
|
|
||||||
|
|
||||||
// Attach() NoTracking entities before SaveChanges()
|
|
||||||
foreach (var book in books)
|
foreach (var book in books)
|
||||||
context.Attach(book.UserDefinedItem).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
|
action?.Invoke(book.UserDefinedItem);
|
||||||
|
|
||||||
var qtyChanges = context.SaveChanges();
|
using var context = DbContexts.GetContext();
|
||||||
if (qtyChanges > 0)
|
|
||||||
BookUserDefinedItemCommitted?.Invoke(null, books);
|
|
||||||
|
|
||||||
return qtyChanges;
|
// Attach() NoTracking entities before SaveChanges()
|
||||||
}
|
foreach (var book in books)
|
||||||
catch (Exception ex)
|
context.Attach(book.UserDefinedItem).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
|
||||||
{
|
|
||||||
Log.Logger.Error(ex, $"Error updating {nameof(Book.UserDefinedItem)}");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// must be here instead of in db layer due to AaxcExists
|
var qtyChanges = context.SaveChanges();
|
||||||
public static LiberatedStatus Liberated_Status(Book book)
|
if (qtyChanges > 0)
|
||||||
|
BookUserDefinedItemCommitted?.Invoke(null, books);
|
||||||
|
|
||||||
|
return qtyChanges;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Logger.Error(ex, $"Error updating {nameof(Book.UserDefinedItem)}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// must be here instead of in db layer due to AaxcExists
|
||||||
|
public static LiberatedStatus Liberated_Status(Book book)
|
||||||
=> book.Audio_Exists() ? book.UserDefinedItem.BookStatus
|
=> book.Audio_Exists() ? book.UserDefinedItem.BookStatus
|
||||||
: AudibleFileStorage.AaxcExists(book.AudibleProductId) ? LiberatedStatus.PartialDownload
|
: AudibleFileStorage.AaxcExists(book.AudibleProductId) ? LiberatedStatus.PartialDownload
|
||||||
: LiberatedStatus.NotLiberated;
|
: LiberatedStatus.NotLiberated;
|
||||||
|
|||||||
@ -50,7 +50,7 @@ namespace LibationAvalonia.Dialogs
|
|||||||
|
|
||||||
protected override void SaveAndClose()
|
protected override void SaveAndClose()
|
||||||
{
|
{
|
||||||
LibraryBook.Book.UpdateBook(NewTags, bookStatus: BookLiberatedStatus, pdfStatus: PdfLiberatedStatus);
|
LibraryBook.Book.UpdateUserDefinedItem(NewTags, bookStatus: BookLiberatedStatus, pdfStatus: PdfLiberatedStatus);
|
||||||
base.SaveAndClose();
|
base.SaveAndClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,53 @@
|
|||||||
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="120"
|
||||||
|
xmlns:controls="clr-namespace:LibationAvalonia.Controls"
|
||||||
|
x:Class="LibationAvalonia.Dialogs.LiberatedStatusBatchAutoDialog"
|
||||||
|
Title="Liberated status: Whether the book has been downloaded"
|
||||||
|
MinHeight="100" MaxHeight="165"
|
||||||
|
MinWidth="600" MaxWidth="800"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
Icon="/Assets/libation.ico">
|
||||||
|
|
||||||
|
<Grid RowDefinitions="Auto,Auto,Auto">
|
||||||
|
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="0"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
Margin="0,0,0,10"
|
||||||
|
IsChecked="{Binding SetDownloaded, Mode=TwoWay}">
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Text="If the audio file can be found, set download status to 'Downloaded'" />
|
||||||
|
</CheckBox>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="1"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
Margin="0,0,0,10"
|
||||||
|
IsChecked="{Binding SetNotDownloaded, Mode=TwoWay}">
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Text="If the audio file cannot be found, set download status to 'Not Downloaded'" />
|
||||||
|
</CheckBox>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Grid.Row="2"
|
||||||
|
Padding="30,0,30,0"
|
||||||
|
Margin="10,0,10,10"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Height="25"
|
||||||
|
Content="Save"
|
||||||
|
Click="SaveButton_Clicked"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace LibationAvalonia.Dialogs
|
||||||
|
{
|
||||||
|
public partial class LiberatedStatusBatchAutoDialog : DialogWindow
|
||||||
|
{
|
||||||
|
public bool SetDownloaded { get; set; }
|
||||||
|
public bool SetNotDownloaded { get; set; }
|
||||||
|
|
||||||
|
public LiberatedStatusBatchAutoDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
DataContext = this;
|
||||||
|
}
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||||
|
=> SaveAndClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,7 +4,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="120"
|
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="120"
|
||||||
xmlns:controls="clr-namespace:LibationAvalonia.Controls"
|
xmlns:controls="clr-namespace:LibationAvalonia.Controls"
|
||||||
x:Class="LibationAvalonia.Dialogs.LiberatedStatusBatchDialog"
|
x:Class="LibationAvalonia.Dialogs.LiberatedStatusBatchManualDialog"
|
||||||
Title="Liberated status: Whether the book has been downloaded"
|
Title="Liberated status: Whether the book has been downloaded"
|
||||||
MinWidth="400" MinHeight="120"
|
MinWidth="400" MinHeight="120"
|
||||||
MaxWidth="400" MaxHeight="120"
|
MaxWidth="400" MaxHeight="120"
|
||||||
@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace LibationAvalonia.Dialogs
|
namespace LibationAvalonia.Dialogs
|
||||||
{
|
{
|
||||||
public partial class LiberatedStatusBatchDialog : DialogWindow
|
public partial class LiberatedStatusBatchManualDialog : DialogWindow
|
||||||
{
|
{
|
||||||
private class liberatedComboBoxItem
|
private class liberatedComboBoxItem
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ namespace LibationAvalonia.Dialogs
|
|||||||
new liberatedComboBoxItem { Status = LiberatedStatus.NotLiberated, Text = "Not Downloaded" },
|
new liberatedComboBoxItem { Status = LiberatedStatus.NotLiberated, Text = "Not Downloaded" },
|
||||||
};
|
};
|
||||||
|
|
||||||
public LiberatedStatusBatchDialog()
|
public LiberatedStatusBatchManualDialog()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SelectedItem = BookStatuses[0] as liberatedComboBoxItem;
|
SelectedItem = BookStatuses[0] as liberatedComboBoxItem;
|
||||||
@ -92,6 +92,12 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Update="Dialogs\LiberatedStatusBatchAutoDialog.axaml.cs">
|
||||||
|
<DependentUpon>LiberatedStatusBatchAutoDialog.axaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="Dialogs\LiberatedStatusBatchManualDialog.axaml.cs">
|
||||||
|
<DependentUpon>LiberatedStatusBatchManualDialog.axaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Update="Views\ProcessBookControl.axaml.cs">
|
<Compile Update="Views\ProcessBookControl.axaml.cs">
|
||||||
<DependentUpon>ProcessBookControl.axaml</DependentUpon>
|
<DependentUpon>ProcessBookControl.axaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
using ApplicationServices;
|
using ApplicationServices;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using DataLayer;
|
using DataLayer;
|
||||||
|
using Dinah.Core;
|
||||||
|
using LibationFileManager;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -57,14 +59,12 @@ namespace LibationAvalonia.Views
|
|||||||
if (confirmationResult != DialogResult.Yes)
|
if (confirmationResult != DialogResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var libraryBook in visibleLibraryBooks)
|
visibleLibraryBooks.UpdateTags(dialog.NewTags);
|
||||||
libraryBook.Book.UserDefinedItem.Tags = dialog.NewTags;
|
}
|
||||||
LibraryCommands.UpdateUserDefinedItem(visibleLibraryBooks.Select(lb => lb.Book));
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void setDownloadedToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
public async void setDownloadedManualToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||||
{
|
{
|
||||||
var dialog = new Dialogs.LiberatedStatusBatchDialog();
|
var dialog = new Dialogs.LiberatedStatusBatchManualDialog();
|
||||||
var result = await dialog.ShowDialog<DialogResult>(this);
|
var result = await dialog.ShowDialog<DialogResult>(this);
|
||||||
if (result != DialogResult.OK)
|
if (result != DialogResult.OK)
|
||||||
return;
|
return;
|
||||||
@ -81,12 +81,36 @@ namespace LibationAvalonia.Views
|
|||||||
if (confirmationResult != DialogResult.Yes)
|
if (confirmationResult != DialogResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var libraryBook in visibleLibraryBooks)
|
visibleLibraryBooks.UpdateBookStatus(dialog.BookLiberatedStatus);
|
||||||
libraryBook.Book.UserDefinedItem.BookStatus = dialog.BookLiberatedStatus;
|
}
|
||||||
LibraryCommands.UpdateUserDefinedItem(visibleLibraryBooks.Select(lb => lb.Book));
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void removeToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
public async void setDownloadedAutoToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||||
|
{
|
||||||
|
var dialog = new Dialogs.LiberatedStatusBatchAutoDialog();
|
||||||
|
var result = await dialog.ShowDialog<DialogResult>(this);
|
||||||
|
if (result != DialogResult.OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var bulkSetStatus = new BulkSetDownloadStatus(_viewModel.ProductsDisplay.GetVisibleBookEntries(), dialog.SetDownloaded, dialog.SetNotDownloaded);
|
||||||
|
var count = await Task.Run(() => bulkSetStatus.Discover());
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var confirmationResult = await MessageBox.Show(
|
||||||
|
bulkSetStatus.AggregateMessage,
|
||||||
|
"Replace downloaded status?",
|
||||||
|
MessageBoxButtons.YesNo,
|
||||||
|
MessageBoxIcon.Question,
|
||||||
|
MessageBoxDefaultButton.Button1);
|
||||||
|
|
||||||
|
if (confirmationResult != DialogResult.Yes)
|
||||||
|
return;
|
||||||
|
|
||||||
|
bulkSetStatus.Execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void removeToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||||
{
|
{
|
||||||
var visibleLibraryBooks = _viewModel.ProductsDisplay.GetVisibleBookEntries();
|
var visibleLibraryBooks = _viewModel.ProductsDisplay.GetVisibleBookEntries();
|
||||||
|
|
||||||
|
|||||||
@ -110,7 +110,8 @@
|
|||||||
</MenuItem.Styles>
|
</MenuItem.Styles>
|
||||||
<MenuItem Click="liberateVisible" Header="{Binding LiberateVisibleToolStripText_2}" IsEnabled="{Binding AnyVisibleNotLiberated}" />
|
<MenuItem Click="liberateVisible" Header="{Binding LiberateVisibleToolStripText_2}" IsEnabled="{Binding AnyVisibleNotLiberated}" />
|
||||||
<MenuItem Click="replaceTagsToolStripMenuItem_Click" Header="Replace _Tags..." />
|
<MenuItem Click="replaceTagsToolStripMenuItem_Click" Header="Replace _Tags..." />
|
||||||
<MenuItem Click="setDownloadedToolStripMenuItem_Click" Header="Set '_Downloaded' status..." />
|
<MenuItem Click="setDownloadedManualToolStripMenuItem_Click" Header="Set '_Downloaded' status manually..." />
|
||||||
|
<MenuItem Click="setDownloadedAutoToolStripMenuItem_Click" Header="Set '_Downloaded' status automatically..." />
|
||||||
<MenuItem Click="removeToolStripMenuItem_Click" Header="_Remove from library..." />
|
<MenuItem Click="removeToolStripMenuItem_Click" Header="_Remove from library..." />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ using CommandLine;
|
|||||||
|
|
||||||
namespace LibationCli
|
namespace LibationCli
|
||||||
{
|
{
|
||||||
[Verb("export", HelpText = "Must include path and flag for export file type: --xlsx , --csv , --json]")]
|
[Verb("export", HelpText = "Must include path and flag for export file type: --xlsx , --csv , --json")]
|
||||||
public class ExportOptions : OptionsBase
|
public class ExportOptions : OptionsBase
|
||||||
{
|
{
|
||||||
[Option(shortName: 'p', longName: "path", Required = true, HelpText = "Path to save file to.")]
|
[Option(shortName: 'p', longName: "path", Required = true, HelpText = "Path to save file to.")]
|
||||||
|
|||||||
37
Source/LibationCli/Options/SetDownloadStatusOptions.cs
Normal file
37
Source/LibationCli/Options/SetDownloadStatusOptions.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ApplicationServices;
|
||||||
|
using AudibleUtilities;
|
||||||
|
using CommandLine;
|
||||||
|
|
||||||
|
namespace LibationCli
|
||||||
|
{
|
||||||
|
[Verb("set-status", HelpText = """
|
||||||
|
Set download statuses throughout library based on whether each book's audio file can be found.
|
||||||
|
Must include at least one flag: --downloaded , --not-downloaded.
|
||||||
|
Downloaded: If the audio file can be found, set download status to 'Downloaded'.
|
||||||
|
Not Downloaded: If the audio file cannot be found, set download status to 'Not Downloaded'
|
||||||
|
""")]
|
||||||
|
public class SetDownloadStatusOptions : OptionsBase
|
||||||
|
{
|
||||||
|
[Option(shortName: 'd', longName: "downloaded", Required = true)]
|
||||||
|
public bool SetDownloaded { get; set; }
|
||||||
|
|
||||||
|
[Option(shortName: 'n', longName: "not-downloaded", Required = true)]
|
||||||
|
public bool SetNotDownloaded { get; set; }
|
||||||
|
|
||||||
|
protected override async Task ProcessAsync()
|
||||||
|
{
|
||||||
|
var libraryBooks = DbContexts.GetLibrary_Flat_NoTracking();
|
||||||
|
|
||||||
|
var bulkSetStatus = new BulkSetDownloadStatus(libraryBooks, SetDownloaded, SetNotDownloaded);
|
||||||
|
await Task.Run(() => bulkSetStatus.Discover());
|
||||||
|
bulkSetStatus.Execute();
|
||||||
|
|
||||||
|
foreach (var msg in bulkSetStatus.Messages)
|
||||||
|
Console.WriteLine(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -113,6 +113,5 @@ namespace LibationFileManager
|
|||||||
public void Refresh() => BookDirectoryFiles.RefreshFiles();
|
public void Refresh() => BookDirectoryFiles.RefreshFiles();
|
||||||
|
|
||||||
public LongPath GetPath(string productId) => GetFilePath(productId);
|
public LongPath GetPath(string productId) => GetFilePath(productId);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
108
Source/LibationWinForms/Dialogs/LiberatedStatusBatchAutoDialog.Designer.cs
generated
Normal file
108
Source/LibationWinForms/Dialogs/LiberatedStatusBatchAutoDialog.Designer.cs
generated
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
namespace LibationWinForms.Dialogs
|
||||||
|
{
|
||||||
|
partial class LiberatedStatusBatchAutoDialog
|
||||||
|
{
|
||||||
|
/// <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.setDownloadedCb = new System.Windows.Forms.CheckBox();
|
||||||
|
this.setNotDownloadedCb = new System.Windows.Forms.CheckBox();
|
||||||
|
this.okBtn = new System.Windows.Forms.Button();
|
||||||
|
this.cancelBtn = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// setDownloadedCb
|
||||||
|
//
|
||||||
|
this.setDownloadedCb.AutoSize = true;
|
||||||
|
this.setDownloadedCb.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.setDownloadedCb.Name = "setDownloadedCb";
|
||||||
|
this.setDownloadedCb.Size = new System.Drawing.Size(379, 19);
|
||||||
|
this.setDownloadedCb.TabIndex = 0;
|
||||||
|
this.setDownloadedCb.Text = "If the audio file can be found, set download status to \'Downloaded\'";
|
||||||
|
this.setDownloadedCb.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// setNotDownloadedCb
|
||||||
|
//
|
||||||
|
this.setNotDownloadedCb.AutoSize = true;
|
||||||
|
this.setNotDownloadedCb.Location = new System.Drawing.Point(12, 37);
|
||||||
|
this.setNotDownloadedCb.Name = "setNotDownloadedCb";
|
||||||
|
this.setNotDownloadedCb.Size = new System.Drawing.Size(412, 19);
|
||||||
|
this.setNotDownloadedCb.TabIndex = 1;
|
||||||
|
this.setNotDownloadedCb.Text = "If the audio file cannot be found, set download status to \'Not Downloaded\'";
|
||||||
|
this.setNotDownloadedCb.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// okBtn
|
||||||
|
//
|
||||||
|
this.okBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.okBtn.Location = new System.Drawing.Point(346, 79);
|
||||||
|
this.okBtn.Name = "okBtn";
|
||||||
|
this.okBtn.Size = new System.Drawing.Size(88, 27);
|
||||||
|
this.okBtn.TabIndex = 2;
|
||||||
|
this.okBtn.Text = "OK";
|
||||||
|
this.okBtn.UseVisualStyleBackColor = true;
|
||||||
|
this.okBtn.Click += new System.EventHandler(this.okBtn_Click);
|
||||||
|
//
|
||||||
|
// cancelBtn
|
||||||
|
//
|
||||||
|
this.cancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.cancelBtn.Location = new System.Drawing.Point(464, 79);
|
||||||
|
this.cancelBtn.Name = "cancelBtn";
|
||||||
|
this.cancelBtn.Size = new System.Drawing.Size(88, 27);
|
||||||
|
this.cancelBtn.TabIndex = 3;
|
||||||
|
this.cancelBtn.Text = "Cancel";
|
||||||
|
this.cancelBtn.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// LiberatedStatusBatchAutoDialog
|
||||||
|
//
|
||||||
|
this.AcceptButton = this.okBtn;
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.CancelButton = this.cancelBtn;
|
||||||
|
this.ClientSize = new System.Drawing.Size(564, 118);
|
||||||
|
this.Controls.Add(this.cancelBtn);
|
||||||
|
this.Controls.Add(this.okBtn);
|
||||||
|
this.Controls.Add(this.setNotDownloadedCb);
|
||||||
|
this.Controls.Add(this.setDownloadedCb);
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.Name = "LiberatedStatusBatchAutoDialog";
|
||||||
|
this.ShowInTaskbar = false;
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
|
this.Text = "Liberated status: Scan for files";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.CheckBox setDownloadedCb;
|
||||||
|
private System.Windows.Forms.CheckBox setNotDownloadedCb;
|
||||||
|
private System.Windows.Forms.Button okBtn;
|
||||||
|
private System.Windows.Forms.Button cancelBtn;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace LibationWinForms.Dialogs
|
||||||
|
{
|
||||||
|
public partial class LiberatedStatusBatchAutoDialog : Form
|
||||||
|
{
|
||||||
|
public bool SetDownloaded { get; private set; }
|
||||||
|
public bool SetNotDownloaded { get; private set; }
|
||||||
|
|
||||||
|
public LiberatedStatusBatchAutoDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.SetLibationIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void okBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SetDownloaded = this.setDownloadedCb.Checked;
|
||||||
|
SetNotDownloaded = this.setNotDownloadedCb.Checked;
|
||||||
|
|
||||||
|
this.DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
namespace LibationWinForms.Dialogs
|
namespace LibationWinForms.Dialogs
|
||||||
{
|
{
|
||||||
partial class LiberatedStatusBatchDialog
|
partial class LiberatedStatusBatchManualDialog
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
@ -72,7 +72,6 @@
|
|||||||
this.cancelBtn.TabIndex = 9;
|
this.cancelBtn.TabIndex = 9;
|
||||||
this.cancelBtn.Text = "Cancel";
|
this.cancelBtn.Text = "Cancel";
|
||||||
this.cancelBtn.UseVisualStyleBackColor = true;
|
this.cancelBtn.UseVisualStyleBackColor = true;
|
||||||
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
|
|
||||||
//
|
//
|
||||||
// saveBtn
|
// saveBtn
|
||||||
//
|
//
|
||||||
@ -86,7 +85,7 @@
|
|||||||
this.saveBtn.UseVisualStyleBackColor = true;
|
this.saveBtn.UseVisualStyleBackColor = true;
|
||||||
this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click);
|
this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click);
|
||||||
//
|
//
|
||||||
// LiberatedStatusBatchDialog
|
// LiberatedStatusBatchManualDialog
|
||||||
//
|
//
|
||||||
this.AcceptButton = this.saveBtn;
|
this.AcceptButton = this.saveBtn;
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
@ -101,7 +100,7 @@
|
|||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.MinimizeBox = false;
|
this.MinimizeBox = false;
|
||||||
this.Name = "LiberatedStatusBatchDialog";
|
this.Name = "LiberatedStatusBatchManualDialog";
|
||||||
this.ShowInTaskbar = false;
|
this.ShowInTaskbar = false;
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "Liberated status: Whether the book has been downloaded";
|
this.Text = "Liberated status: Whether the book has been downloaded";
|
||||||
@ -8,7 +8,7 @@ using LibationFileManager;
|
|||||||
|
|
||||||
namespace LibationWinForms.Dialogs
|
namespace LibationWinForms.Dialogs
|
||||||
{
|
{
|
||||||
public partial class LiberatedStatusBatchDialog : Form
|
public partial class LiberatedStatusBatchManualDialog : Form
|
||||||
{
|
{
|
||||||
public LiberatedStatus BookLiberatedStatus { get; private set; }
|
public LiberatedStatus BookLiberatedStatus { get; private set; }
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ namespace LibationWinForms.Dialogs
|
|||||||
public override string ToString() => Text;
|
public override string ToString() => Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiberatedStatusBatchDialog()
|
public LiberatedStatusBatchManualDialog()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.SetLibationIcon();
|
this.SetLibationIcon();
|
||||||
@ -35,11 +35,5 @@ namespace LibationWinForms.Dialogs
|
|||||||
BookLiberatedStatus = ((liberatedComboBoxItem)this.bookLiberatedCb.SelectedItem).Status;
|
BookLiberatedStatus = ((liberatedComboBoxItem)this.bookLiberatedCb.SelectedItem).Status;
|
||||||
this.DialogResult = DialogResult.OK;
|
this.DialogResult = DialogResult.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelBtn_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
this.DialogResult = DialogResult.Cancel;
|
|
||||||
this.Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<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>
|
||||||
1020
Source/LibationWinForms/Form1.Designer.cs
generated
1020
Source/LibationWinForms/Form1.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -87,14 +87,12 @@ namespace LibationWinForms
|
|||||||
if (confirmationResult != DialogResult.Yes)
|
if (confirmationResult != DialogResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var libraryBook in visibleLibraryBooks)
|
visibleLibraryBooks.UpdateTags(dialog.NewTags);
|
||||||
libraryBook.Book.UserDefinedItem.Tags = dialog.NewTags;
|
}
|
||||||
LibraryCommands.UpdateUserDefinedItem(visibleLibraryBooks.Select(lb => lb.Book));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDownloadedToolStripMenuItem_Click(object sender, EventArgs e)
|
private void setDownloadedManualToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var dialog = new LiberatedStatusBatchDialog();
|
var dialog = new LiberatedStatusBatchManualDialog();
|
||||||
var result = dialog.ShowDialog();
|
var result = dialog.ShowDialog();
|
||||||
if (result != DialogResult.OK)
|
if (result != DialogResult.OK)
|
||||||
return;
|
return;
|
||||||
@ -110,12 +108,36 @@ namespace LibationWinForms
|
|||||||
if (confirmationResult != DialogResult.Yes)
|
if (confirmationResult != DialogResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var libraryBook in visibleLibraryBooks)
|
visibleLibraryBooks.UpdateBookStatus(dialog.BookLiberatedStatus);
|
||||||
libraryBook.Book.UserDefinedItem.BookStatus = dialog.BookLiberatedStatus;
|
}
|
||||||
LibraryCommands.UpdateUserDefinedItem(visibleLibraryBooks.Select(lb => lb.Book));
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void removeToolStripMenuItem_Click(object sender, EventArgs e)
|
private async void setDownloadedAutoToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var dialog = new LiberatedStatusBatchAutoDialog();
|
||||||
|
var result = dialog.ShowDialog();
|
||||||
|
if (result != DialogResult.OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var bulkSetStatus = new BulkSetDownloadStatus(productsDisplay.GetVisible(), dialog.SetDownloaded, dialog.SetNotDownloaded);
|
||||||
|
var count = await Task.Run(() => bulkSetStatus.Discover());
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var confirmationResult = MessageBox.Show(
|
||||||
|
bulkSetStatus.AggregateMessage,
|
||||||
|
"Replace downloaded status?",
|
||||||
|
MessageBoxButtons.YesNo,
|
||||||
|
MessageBoxIcon.Question,
|
||||||
|
MessageBoxDefaultButton.Button1);
|
||||||
|
|
||||||
|
if (confirmationResult != DialogResult.Yes)
|
||||||
|
return;
|
||||||
|
|
||||||
|
bulkSetStatus.Execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void removeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var visibleLibraryBooks = productsDisplay.GetVisible();
|
var visibleLibraryBooks = productsDisplay.GetVisible();
|
||||||
|
|
||||||
|
|||||||
@ -128,7 +128,7 @@ namespace LibationWinForms.GridView
|
|||||||
/// <summary>Save edits to the database</summary>
|
/// <summary>Save edits to the database</summary>
|
||||||
public void Commit(string newTags, LiberatedStatus bookStatus, LiberatedStatus? pdfStatus)
|
public void Commit(string newTags, LiberatedStatus bookStatus, LiberatedStatus? pdfStatus)
|
||||||
// MVVM pass-through
|
// MVVM pass-through
|
||||||
=> Book.UpdateBook(newTags, bookStatus: bookStatus, pdfStatus: pdfStatus);
|
=> Book.UpdateUserDefinedItem(newTags, bookStatus: bookStatus, pdfStatus: pdfStatus);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user