#409 adding finalizeDownload parameter to BatchImportELiteratureBookLibraryAsync
This commit is contained in:
parent
3e2f30d412
commit
a80aa75c0c
@ -301,14 +301,15 @@ namespace RMuseum.Controllers
|
||||
/// </summary>
|
||||
/// <param name="ajaxPageIndexStart">start from 0</param>
|
||||
/// <param name="ajaxPageIndexEnd"></param>
|
||||
/// <param name="finalizeDownload"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("elit/{ajaxPageIndexStart}/{ajaxPageIndexEnd}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.PDFLibraryEntityShortName + ":" + SecurableItem.AddOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public IActionResult BatchImportELiteratureBookLibraryAsync(int ajaxPageIndexStart, int ajaxPageIndexEnd)
|
||||
public IActionResult BatchImportELiteratureBookLibraryAsync(int ajaxPageIndexStart, int ajaxPageIndexEnd, bool finalizeDownload)
|
||||
{
|
||||
_pdfService.BatchImportELiteratureBookLibraryAsync(ajaxPageIndexStart, ajaxPageIndexEnd);
|
||||
_pdfService.BatchImportELiteratureBookLibraryAsync(ajaxPageIndexStart, ajaxPageIndexEnd, finalizeDownload);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
@ -2437,12 +2437,13 @@
|
||||
<param name="finalizeDownload"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.PDFLibraryController.BatchImportELiteratureBookLibraryAsync(System.Int32,System.Int32)">
|
||||
<member name="M:RMuseum.Controllers.PDFLibraryController.BatchImportELiteratureBookLibraryAsync(System.Int32,System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
batch import eliteraturebook.com library
|
||||
</summary>
|
||||
<param name="ajaxPageIndexStart">start from 0</param>
|
||||
<param name="ajaxPageIndexEnd"></param>
|
||||
<param name="finalizeDownload"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.PDFLibraryController.PutPDFBookAsync(RMuseum.Models.PDFLibrary.PDFBook)">
|
||||
@ -18481,12 +18482,13 @@
|
||||
PDF Library Services
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.BatchImportELiteratureBookLibraryAsync(System.Int32,System.Int32)">
|
||||
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.BatchImportELiteratureBookLibraryAsync(System.Int32,System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
batch import eliteraturebook.com library
|
||||
</summary>
|
||||
<param name="ajaxPageIndexStart">from 0</param>
|
||||
<param name="ajaxPageIndexEnd"></param>
|
||||
<param name="finalizeDownload"></param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.StartImportingLocalPDFAsync(RMuseum.Models.PDFLibrary.ViewModels.NewPDFBookViewModel)">
|
||||
<summary>
|
||||
@ -20107,12 +20109,13 @@
|
||||
<param name="end"></param>
|
||||
<param name="finalizeDownload"></param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IPDFLibraryService.BatchImportELiteratureBookLibraryAsync(System.Int32,System.Int32)">
|
||||
<member name="M:RMuseum.Services.IPDFLibraryService.BatchImportELiteratureBookLibraryAsync(System.Int32,System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
batch import eliteraturebook.com library
|
||||
</summary>
|
||||
<param name="ajaxPageIndexStart">from 0</param>
|
||||
<param name="ajaxPageIndexEnd"></param>
|
||||
<param name="finalizeDownload"></param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IPDFLibraryService.SearchPDFBooksAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.String)">
|
||||
<summary>
|
||||
|
||||
@ -342,7 +342,8 @@ namespace RMuseum.Services
|
||||
/// </summary>
|
||||
/// <param name="ajaxPageIndexStart">from 0</param>
|
||||
/// <param name="ajaxPageIndexEnd"></param>
|
||||
void BatchImportELiteratureBookLibraryAsync(int ajaxPageIndexStart, int ajaxPageIndexEnd);
|
||||
/// <param name="finalizeDownload"></param>
|
||||
void BatchImportELiteratureBookLibraryAsync(int ajaxPageIndexStart, int ajaxPageIndexEnd, bool finalizeDownload);
|
||||
|
||||
/// <summary>
|
||||
/// search pdf books
|
||||
|
||||
@ -49,7 +49,7 @@ namespace RMuseum.Services.Implementation
|
||||
{
|
||||
using (RMuseumDbContext context = new RMuseumDbContext(new DbContextOptions<RMuseumDbContext>()))
|
||||
{
|
||||
await ImportELiteratureBookLibraryUrlAsync(srcUrl, context);
|
||||
await ImportELiteratureBookLibraryUrlAsync(srcUrl, context, true);
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -61,7 +61,7 @@ namespace RMuseum.Services.Implementation
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
}
|
||||
}
|
||||
private async Task ImportELiteratureBookLibraryUrlAsync(string srcUrl, RMuseumDbContext context)
|
||||
private async Task ImportELiteratureBookLibraryUrlAsync(string srcUrl, RMuseumDbContext context, bool finalizeDownload)
|
||||
{
|
||||
/*
|
||||
var oldJobs = await context.ImportJobs.ToArrayAsync();
|
||||
@ -546,6 +546,32 @@ namespace RMuseum.Services.Implementation
|
||||
|
||||
model.OriginalFileUrl = downloadUrl;
|
||||
|
||||
if (!finalizeDownload)
|
||||
{
|
||||
context.QueuedPDFBooks.Add
|
||||
(
|
||||
new QueuedPDFBook()
|
||||
{
|
||||
Title = model.Title,
|
||||
DownloadOrder = await context.QueuedPDFBooks.CountAsync(),
|
||||
AuthorsLine = model.AuthorsLine,
|
||||
Description = model.Description,
|
||||
Language = model.Language,
|
||||
IsTranslation = model.IsTranslation,
|
||||
TranslatorsLine = model.TranslatorsLine,
|
||||
OriginalSourceName = model.OriginalSourceName,
|
||||
OriginalSourceUrl = model.OriginalSourceUrl,
|
||||
OriginalFileUrl = model.OriginalFileUrl,
|
||||
}
|
||||
);
|
||||
await context.SaveChangesAsync();
|
||||
job.EndTime = DateTime.Now;
|
||||
job.Status = ImportJobStatus.Succeeded;
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
using (var result = await client.GetAsync(downloadUrl))
|
||||
@ -630,7 +656,8 @@ namespace RMuseum.Services.Implementation
|
||||
/// </summary>
|
||||
/// <param name="ajaxPageIndexStart">from 0</param>
|
||||
/// <param name="ajaxPageIndexEnd"></param>
|
||||
public void BatchImportELiteratureBookLibraryAsync(int ajaxPageIndexStart, int ajaxPageIndexEnd)
|
||||
/// <param name="finalizeDownload"></param>
|
||||
public void BatchImportELiteratureBookLibraryAsync(int ajaxPageIndexStart, int ajaxPageIndexEnd, bool finalizeDownload)
|
||||
{
|
||||
_backgroundTaskQueue.QueueBackgroundWorkItem
|
||||
(
|
||||
@ -700,7 +727,7 @@ namespace RMuseum.Services.Implementation
|
||||
null
|
||||
)
|
||||
{
|
||||
await ImportELiteratureBookLibraryUrlAsync(srcUrl, context);
|
||||
await ImportELiteratureBookLibraryUrlAsync(srcUrl, context, finalizeDownload);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user