diff --git a/ApplicationServices/LibraryCommands.cs b/ApplicationServices/LibraryCommands.cs index b92eb7d8..d990ddff 100644 --- a/ApplicationServices/LibraryCommands.cs +++ b/ApplicationServices/LibraryCommands.cs @@ -155,7 +155,12 @@ namespace ApplicationServices #endregion #region Update book details - + /// + /// Occurs when , , or + /// changed values are successfully persisted. + /// + public static event EventHandler BookUserDefinedItemCommitted; + public static int UpdateUserDefinedItem(Book book) { try @@ -166,7 +171,10 @@ namespace ApplicationServices context.Attach(book.UserDefinedItem).State = Microsoft.EntityFrameworkCore.EntityState.Modified; var qtyChanges = context.SaveChanges(); if (qtyChanges > 0) + { SearchEngineCommands.UpdateLiberatedStatus(book); + BookUserDefinedItemCommitted?.Invoke(null, book.AudibleProductId); + } return qtyChanges; } diff --git a/DataLayer/EfClasses/UserDefinedItem.cs b/DataLayer/EfClasses/UserDefinedItem.cs index acc484fe..1686d3a1 100644 --- a/DataLayer/EfClasses/UserDefinedItem.cs +++ b/DataLayer/EfClasses/UserDefinedItem.cs @@ -136,6 +136,7 @@ namespace DataLayer #endregion /// /// Occurs when , , or values change. + /// This signals the change of the in-memory value; it does not ensure that the new value has been persisted. /// public static event EventHandler ItemChanged; public override string ToString() => $"{Book} {Rating} {Tags}"; diff --git a/DataLayer/_HowTo- EF Core.txt b/DataLayer/_HowTo- EF Core.txt deleted file mode 100644 index 9f0e618a..00000000 --- a/DataLayer/_HowTo- EF Core.txt +++ /dev/null @@ -1,57 +0,0 @@ -FOR QUICK MIGRATION INSTRUCTIONS: -_DB_NOTES.txt - - -HOW TO CREATE: EF CORE PROJECT -============================== -example is for sqlite but the same works with MsSql - - -nuget -Microsoft.EntityFrameworkCore.Tools (needed for using Package Manager Console) -Microsoft.EntityFrameworkCore.Sqlite - -MIGRATIONS - require core, not standard - this can be a problem b/c standard and framework can only reference standard, not core -TO USE MIGRATIONS (core and/or standard) - add to csproj - - true - -TO USE MIGRATIONS AS *BOTH* CORE AND STANDARD - edit csproj - pluralize this xml tag - from: TargetFramework - to: TargetFrameworks - inside of TargetFrameworks - from: netstandard2.1 - to: netcoreapp3.1;netstandard2.1 - -run. error -SQLite Error 1: 'no such table: Blogs'. - -set project "Set as StartUp Project" - -Tools >> Nuget Package Manager >> Package Manager Console -default project: Examples\SQLite_NETCore2_0 - -PM> add-migration InitialCreate -PM> Update-Database - -if add-migration xyz throws and error, don't take the error msg at face value. try again with add-migration xyz -verbose - -new sqlite .db file created: Copy always/Copy if newer -or copy .db file to destination - -relative: - optionsBuilder.UseSqlite("Data Source=blogging.db"); -absolute (use fwd slashes): - optionsBuilder.UseSqlite("Data Source=C:/foo/bar/blogging.db"); - - -REFERENCE ARTICLES ------------------- -https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite -https://carlos.mendible.com/2016/07/11/step-by-step-dotnet-core-and-entity-framework-core/ -https://www.benday.com/2017/12/19/ef-core-2-0-migrations-without-hard-coded-connection-strings/ \ No newline at end of file diff --git a/LibationLauncher/LibationLauncher.csproj b/LibationLauncher/LibationLauncher.csproj index d7717e38..5eb07a9a 100644 --- a/LibationLauncher/LibationLauncher.csproj +++ b/LibationLauncher/LibationLauncher.csproj @@ -13,7 +13,7 @@ win-x64 - 5.6.1.0 + 5.6.2.1 diff --git a/LibationWinForms/Form1.cs b/LibationWinForms/Form1.cs index 3bda0aff..128a72f0 100644 --- a/LibationWinForms/Form1.cs +++ b/LibationWinForms/Form1.cs @@ -32,7 +32,7 @@ namespace LibationWinForms // independent UI updates this.Load += (_, __) => RestoreSizeAndLocation(); this.Load += (_, __) => RefreshImportMenu(); - UserDefinedItem.ItemChanged += setBackupCounts; + LibraryCommands.BookUserDefinedItemCommitted += setBackupCounts; var format = System.Drawing.Imaging.ImageFormat.Jpeg; PictureStorage.SetDefaultImage(PictureSize._80x80, Properties.Resources.default_cover_80x80.ToBytes(format)); diff --git a/REFERENCE.txt b/REFERENCE.txt index 0b5edb65..59efb925 100644 --- a/REFERENCE.txt +++ b/REFERENCE.txt @@ -1,25 +1,9 @@ -- begin VERSIONING --------------------------------------------------------------------------------------------------------------------- https://github.com/rmcrackan/Libation/releases -v3.1.8 : Experimental: add Australia to locale options -v3.1.7 : Improved logging -v3.1.6 : Bugfix: some series indexes/sequences formats cause library not to import -v3.1.5 : Bugfix: some series indexes/sequences could cause library not to import -v3.1.4 : Bugfix: IsAuthorNarrated was returning no books -v3.1.3 : fix weirdness with build number -v3.1.2 : minor bug fixes +pre-github versions: v3.1.1 : Check if upgrade available on github v3.1.0 : FIRST PUBLIC RELEASE -v3.1-beta.11 : Improved configuration and settings file management. Configurable logging -v3.1-beta.10 : New feature: clicking Liberate button on a liberated item navigates to that audio file -v3.1-beta.9 : New feature: liberate individual book -v3.1-beta.8 : Bugfix: decrypt file conflict -v3.1-beta.7 : Bugfix: decrypt book with no author -v3.1-beta.6 : Improved logging -v3.1-beta.5 : Improved importing -v3.1-beta.4 : Added beta-specific logging -v3.1-beta.3 : fixed known performance issue: Full-screen grid is slow to respond loading when books aren't liberated -v3.1-beta.2 : fixed known performance issue: Tag add/edit v3.1-beta.1 : RELEASE TO BETA v3.0.3 : Switch to SQLite. No longer relies on LocalDB, which must be installed separately v3.0.2 : Final using LocalDB @@ -29,29 +13,6 @@ v2 : new library page scraping. still chrome cookies. all decryption is handled v1 : old library ajax scraping. wish list scraping. chrome cookies. directly call local inAudible. .net framework -- end VERSIONING --------------------------------------------------------------------------------------------------------------------- --- begin HOW TO PUBLISH --------------------------------------------------------------------------------------------------------------------- -OPTION 1: UI -rt-clk project project > Publish... -click Publish - -OPTION 2: cmd line -change dir to folder containing project - cd C:\[full...path]\Libation\LibationWinForms -this will use the parameters specified in csproj -dotnet publish -c Release - -OPTION 3: cmd line, custom -open csproj -remove: PublishTrimmed, PublishReadyToRun, RuntimeIdentifier -run customized publish. examples: -publish all platforms - dotnet publish -c Release -publish win64 platform only - dotnet publish -r win-x64 -c Release -publish win64 platform, single-file - dotnet publish -r win-x64 -c Release --- end HOW TO PUBLISH --------------------------------------------------------------------------------------------------------------------- - -- begin IMAGES/ICONS --------------------------------------------------------------------------------------------------------------------- edit tags icon images from: icons8.com @@ -60,32 +21,9 @@ edit tags icon images from: 'edit' icon: https://www.iconfinder.com/icons/383147/edit_icon -- end IMAGES/ICONS --------------------------------------------------------------------------------------------------------------------- --- begin AUDIBLE DETAILS --------------------------------------------------------------------------------------------------------------------- -alternate book id (eg BK_RAND_006061) is called 'sku' , 'sku_lite' , 'prod_id' , 'product_id' in different parts of the site --- end AUDIBLE DETAILS --------------------------------------------------------------------------------------------------------------------- - -- begin SOLUTION LAYOUT --------------------------------------------------------------------------------------------------------------------- do NOT combine jsons for - audible-scraped persistence: library, book details - libation-generated persistence: FileLocations.json - user-defined persistence: BookTags.json -- end SOLUTION LAYOUT --------------------------------------------------------------------------------------------------------------------- - --- begin EF CORE --------------------------------------------------------------------------------------------------------------------- -transaction notes ------------------ -// https://msdn.microsoft.com/en-us/data/dn456843.aspx -// Rollback is called by transaction Dispose(). No need to call it explicitly - using var dbContext = new LibationContext(); - using var dbContextTransaction = dbContext.Database.BeginTransaction(); - refreshAction(dbContext, productItems); - dbContext.SaveChanges(); - dbContextTransaction.Commit(); - -aggregate root is transactional boundary - // //context.Database.CurrentTransaction - //var dbTransaction = Microsoft.EntityFrameworkCore.Storage.DbContextTransactionExtensions.GetDbTransaction(context.Database.CurrentTransaction); - // // test with and without : using TransactionScope scope = new TransactionScope(); - //System.Transactions.Transaction.Current.TransactionCompleted += (sender, e) => { }; - // also : https://docs.microsoft.com/en-us/dotnet/api/system.transactions.transaction.enlistvolatile --- end EF CORE --------------------------------------------------------------------------------------------------------------------- diff --git a/_DB_NOTES.txt b/_DB_NOTES.txt index 79cdaef0..1f53b695 100644 --- a/_DB_NOTES.txt +++ b/_DB_NOTES.txt @@ -1,45 +1,42 @@ -Logging/Debugging (EF CORE) -=========================== -Once you configure logging on a DbContext instance it will be enabled on all instances of that DbContext type - using var context = new MyContext(); - context.ConfigureLogging(s => System.Diagnostics.Debug.WriteLine(s)); // write to Visual Studio "Output" tab - //context.ConfigureLogging(s => Console.WriteLine(s)); -see comments at top of file: - Dinah.EntityFrameworkCore\DbContextLoggingExtensions.cs - -LocalDb -======= -only works if LocalDb is separately installed on host box -SSMS db connection: (LocalDb)\MSSQLLocalDB -eg: Server=(localdb)\mssqllocaldb;Database=DataLayer.LibationContext;Integrated Security=true; -LocalDb database files live at: - C:\Users\[user]\DataLayer.LibationContext.mdf - C:\Users\[user]\DataLayer.LibationContext_log.ldf - -Migrations -========== - -Visual Studio, EF Core ----------------------- +Migrations, quick +================= View > Other Windows > Package Manager Console Default project: DataLayer Startup project: DataLayer since we have mult contexts, must use -context: - Add-Migration MyComment -context LibationContext - Update-Database -context LibationContext + Add-Migration MyComment -context LibationContext + Update-Database -context LibationContext Startup project: reset to prev. eg: LibationLauncher -ERROR -===== -Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program - -SOLUTION --------- -add nuget pkg: Microsoft.EntityFrameworkCore.Tools +Migrations, detailed +==================== +if only 1 context present, can omit -context arg: + Add-Migration MyComment + Update-Database -SQLite -====== -SQLite does not support all migrations (schema changes) due to limitations in SQLite -delete db before running Update-Database? \ No newline at end of file +Migrations, errors +================= +if add-migration xyz throws and error, don't take the error msg at face value. try again with add-migration xyz -verbose + +ERROR: Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program +SOLUTION: add nuget pkg: Microsoft.EntityFrameworkCore.Tools + + +SqLite config +============= +relative: + optionsBuilder.UseSqlite("Data Source=blogging.db"); +absolute (use fwd slashes): + optionsBuilder.UseSqlite("Data Source=C:/foo/bar/blogging.db"); + + +Logging/Debugging (EF CORE) +=========================== +Once you configure logging on a DbContext instance it will be enabled on all instances of that DbContext type + using var context = new MyContext(); + context.ConfigureLogging(s => System.Diagnostics.Debug.WriteLine(s)); // write to Visual Studio "Output" tab + //context.ConfigureLogging(s => Console.WriteLine(s)); +see comments at top of file: + Dinah.EntityFrameworkCore\DbContextLoggingExtensions.cs \ No newline at end of file