- add retry logic to library get

- UI bug fix when no library yet
- publishing related xml added to data and UI projects
- 'how to publish' notes
This commit is contained in:
Robert McRackan 2019-11-14 14:17:20 -05:00
parent 5d4a97cdc4
commit 9076fae6f6
8 changed files with 77 additions and 48 deletions

View File

@ -32,6 +32,7 @@
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>
</ItemGroup>

View File

@ -4,6 +4,10 @@
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Polly" Version="7.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\audible api\AudibleApi\AudibleApi\AudibleApi.csproj" />
<ProjectReference Include="..\FileManager\FileManager.csproj" />

View File

@ -5,26 +5,25 @@ using System.Threading.Tasks;
using AudibleApi;
using AudibleApiDTOs;
using FileManager;
using Polly;
using Polly.Retry;
namespace InternalUtilities
{
public class AudibleApiActions
{
private AsyncRetryPolicy policy { get; }
= Policy.Handle<Exception>()
// 2 retries == 3 total
.RetryAsync(2);
public async Task<List<Item>> GetAllLibraryItemsAsync(ILoginCallback callback)
{
// bug on audible's side. the 1st time after a long absence, a query to get library will return without titles or authors. a subsequent identical query will be successful. this is true whether or tokens are refreshed
// worse, this 1st dummy call doesn't seem to help:
// var page = await api.GetLibraryAsync(new AudibleApi.LibraryOptions { NumberOfResultPerPage = 1, PageNumber = 1, PurchasedAfter = DateTime.Now.AddYears(-20), ResponseGroups = AudibleApi.LibraryOptions.ResponseGroupOptions.ALL_OPTIONS });
// i don't want to incur the cost of making a full dummy call every time because it fails sometimes
try
{
return await getItemsAsync(callback);
}
catch
{
return await getItemsAsync(callback);
}
return await policy.ExecuteAsync(() => getItemsAsync(callback));
}
private async Task<List<Item>> getItemsAsync(ILoginCallback callback)

View File

@ -6,6 +6,11 @@
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>libation.ico</ApplicationIcon>
<AssemblyName>Libation</AssemblyName>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>

View File

@ -33,14 +33,14 @@ namespace LibationWinForm
pdfsCountsLbl_Format = pdfsCountsLbl.Text;
visibleCountLbl_Format = visibleCountLbl.Text;
beginBookBackupsToolStripMenuItem_format = beginBookBackupsToolStripMenuItem.Text;
beginBookBackupsToolStripMenuItem_format = beginBookBackupsToolStripMenuItem.Text;
beginPdfBackupsToolStripMenuItem_format = beginPdfBackupsToolStripMenuItem.Text;
}
private async void Form1_Load(object sender, EventArgs e)
{
// call static ctor. There are bad race conditions if static ctor is first executed when we're running in parallel in setBackupCountsAsync()
var foo = FilePathCache.JsonFile;
{
// call static ctor. There are bad race conditions if static ctor is first executed when we're running in parallel in setBackupCountsAsync()
var foo = FilePathCache.JsonFile;
// load default/missing cover images. this will also initiate the background image downloader
var format = System.Drawing.Imaging.ImageFormat.Jpeg;
@ -48,6 +48,8 @@ namespace LibationWinForm
PictureStorage.SetDefaultImage(PictureSize._300x300, Properties.Resources.default_cover_300x300.ToBytes(format));
PictureStorage.SetDefaultImage(PictureSize._500x500, Properties.Resources.default_cover_500x500.ToBytes(format));
setVisibleCount(null, 0);
reloadGrid();
// also applies filter. ONLY call AFTER loading grid

View File

@ -5,6 +5,29 @@ v3.0.1 : Legacy inAudible wire-up code is still present but is commented out. Al
v3.0 : This version is fully powered by the Audible API. Legacy scraping code is still present but is commented out. All future check-ins are not guaranteed to have any scraping code
-- end VERSIONING ---------------------------------------------------------------------------------------------------------------------
-- begin HOW TO PUBLISH ---------------------------------------------------------------------------------------------------------------------
OPTION 1: UI
rt-clk project > Publish...
click Publish
OPTION 2: cmd line
change dir to folder containing project
cd C:\[full...path]\Libation\LibationWinForm
this will use the parameters specified in csproj
dotnet publish -c Release
OPTION 3: cmd line, custom
open csproj
remove: PublishTrimmed, PublishReadyToRun, PublishSingleFile, 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 /p:PublishSingleFile=true
-- end HOW TO PUBLISH ---------------------------------------------------------------------------------------------------------------------
-- 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 ---------------------------------------------------------------------------------------------------------------------

View File

@ -29,36 +29,13 @@ since we have mult contexts, must use -context:
Update-Database -context LibationContext
QUICK VIEW
==========
declare @productId nvarchar(450) = 'B075Y4SWJ8'
declare @bookId int
declare @catId int
select @bookId = b.BookId from Books b where b.AudibleProductId = @productId
select @catId = b.CategoryId from Books b where b.AudibleProductId = @productId
select * from Books b where b.AudibleProductId = @productId
select *
from BookContributor bc
join Contributors c on bc.ContributorId = c.ContributorId
where bc.BookId = @bookId order by role, [order]
select *
from SeriesBook sb
join Series s on sb.SeriesId = s.SeriesId
where sb.BookId = @bookId
select *
from Categories c1
left join Categories c2 on c1.ParentCategoryCategoryId = c2.CategoryId
where c1.CategoryId = @catId
ERROR
=====
Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program
SOLUTION
--------
dependencies > manage nuget packages
add: Microsoft.EntityFrameworkCore.Tools
add nuget pkg: Microsoft.EntityFrameworkCore.Tools
SQLite

View File

@ -1,18 +1,32 @@
-- begin BETA ---------------------------------------------------------------------------------------------------------------------
OLD WEB DOWNLOADER
- download logic in DownloadPdf should look more like DownloadBook
download logic in DownloadPdf should look more like DownloadBook
TESTING
possible bug: no mdf,ldf files created in C:\Users\[username]
TESTING BUG
dbl clk. long pause. exception:
System.ComponentModel.Win32Exception (2): The system cannot find the file specified.
"continue" button allows me to keep using
bottom #s do not update
login succeeded. IdentityTokens.json successfully created
received above error again during scan. continue
stuck on scan. force quit from task manager
only files:
Images -- empty dir
IdentityTokens.json -- populated
no mdf, ldf
REPLACE DB
need completely need db? replace LocalDb with sqlite? embedded document nosql?
CREATE INSTALLER
see REFERENCE.txt > HOW TO PUBLISH
RELEASE TO BETA
- Create release version and installer
https://dotnetcoretutorials.com/2019/06/20/publishing-a-single-exe-file-in-net-core-3-0/
- Warn of known performance issues
- Library import
- Tag add/edit
- Grid is slow to respond loading when books aren't liberated
- get decrypt key -- unavoidable
Warn of known performance issues
- Library import
- Tag add/edit
- Grid is slow to respond loading when books aren't liberated
- get decrypt key -- unavoidable
-- end BETA ---------------------------------------------------------------------------------------------------------------------
-- begin ENHANCEMENT, IMPORT UI ---------------------------------------------------------------------------------------------------------------------
@ -90,8 +104,12 @@ replace complex config saving throughout with new way in my ConsoleDependencyInj
all settings should be strongly typed
re-create my shortcuts and bak
for appsettings.json to get copied in the single-file release, project must incl <ExcludeFromSingleFile>true
multiple files named "appsettings.json" will overwrite each other
libraries should avoid this generic name. ok for applications to use them
libraries should avoid this generic name. in general: ok for applications to use them
there are exceptions: datalayer has appsettings which is copied to winform. if winform uses appsettings also, it will override datalayer's
Audible API
\AudibleApi\_Tests\AudibleApi.Tests\bin\Debug\netcoreapp3.0\L1