#409 added finalizeDownload parameter for soha
This commit is contained in:
parent
034930c0fc
commit
3e2f30d412
@ -283,14 +283,15 @@ namespace RMuseum.Controllers
|
||||
/// </summary>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="finalizeDownload"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("soha/{start}/{end}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.PDFLibraryEntityShortName + ":" + SecurableItem.AddOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public IActionResult BatchImportSohaLibraryAsync(int start, int end)
|
||||
public IActionResult BatchImportSohaLibraryAsync(int start, int end, bool finalizeDownload)
|
||||
{
|
||||
_pdfService.BatchImportSohaLibraryAsync(start, end);
|
||||
_pdfService.BatchImportSohaLibraryAsync(start, end, finalizeDownload);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
@ -2428,12 +2428,13 @@
|
||||
<param name="srcUrl"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.PDFLibraryController.BatchImportSohaLibraryAsync(System.Int32,System.Int32)">
|
||||
<member name="M:RMuseum.Controllers.PDFLibraryController.BatchImportSohaLibraryAsync(System.Int32,System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
batch import soha library
|
||||
</summary>
|
||||
<param name="start"></param>
|
||||
<param name="end"></param>
|
||||
<param name="finalizeDownload"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.PDFLibraryController.BatchImportELiteratureBookLibraryAsync(System.Int32,System.Int32)">
|
||||
@ -18504,12 +18505,13 @@
|
||||
طول تصویر بندانگشتی
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.BatchImportSohaLibraryAsync(System.Int32,System.Int32)">
|
||||
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.BatchImportSohaLibraryAsync(System.Int32,System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
batch import soha library
|
||||
</summary>
|
||||
<param name="start"></param>
|
||||
<param name="end"></param>
|
||||
<param name="finalizeDownload"></param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.StartImportingKnownSourceAsync(System.String)">
|
||||
<summary>
|
||||
@ -20097,12 +20099,13 @@
|
||||
<param name="sourceId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IPDFLibraryService.BatchImportSohaLibraryAsync(System.Int32,System.Int32)">
|
||||
<member name="M:RMuseum.Services.IPDFLibraryService.BatchImportSohaLibraryAsync(System.Int32,System.Int32,System.Boolean)">
|
||||
<summary>
|
||||
batch import soha library
|
||||
</summary>
|
||||
<param name="start"></param>
|
||||
<param name="end"></param>
|
||||
<param name="finalizeDownload"></param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IPDFLibraryService.BatchImportELiteratureBookLibraryAsync(System.Int32,System.Int32)">
|
||||
<summary>
|
||||
|
||||
@ -334,7 +334,8 @@ namespace RMuseum.Services
|
||||
/// </summary>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
void BatchImportSohaLibraryAsync(int start, int end);
|
||||
/// <param name="finalizeDownload"></param>
|
||||
void BatchImportSohaLibraryAsync(int start, int end, bool finalizeDownload);
|
||||
|
||||
/// <summary>
|
||||
/// batch import eliteraturebook.com library
|
||||
|
||||
@ -49,7 +49,7 @@ namespace RMuseum.Services.Implementation
|
||||
{
|
||||
using (RMuseumDbContext context = new RMuseumDbContext(new DbContextOptions<RMuseumDbContext>()))
|
||||
{
|
||||
await ImportSohaLibraryUrlAsync(srcUrl, context);
|
||||
await ImportSohaLibraryUrlAsync(srcUrl, context, true);
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -62,7 +62,7 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ImportSohaLibraryUrlAsync(string srcUrl, RMuseumDbContext context)
|
||||
private async Task ImportSohaLibraryUrlAsync(string srcUrl, RMuseumDbContext context, bool finalizeDownload)
|
||||
{
|
||||
/*
|
||||
var oldJobs = await context.ImportJobs.ToArrayAsync();
|
||||
@ -503,6 +503,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))
|
||||
@ -600,7 +626,8 @@ namespace RMuseum.Services.Implementation
|
||||
/// </summary>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
public void BatchImportSohaLibraryAsync(int start, int end)
|
||||
/// <param name="finalizeDownload"></param>
|
||||
public void BatchImportSohaLibraryAsync(int start, int end, bool finalizeDownload)
|
||||
{
|
||||
_backgroundTaskQueue.QueueBackgroundWorkItem
|
||||
(
|
||||
@ -623,7 +650,7 @@ namespace RMuseum.Services.Implementation
|
||||
try
|
||||
{
|
||||
|
||||
await ImportSohaLibraryUrlAsync(srcUrl, context);
|
||||
await ImportSohaLibraryUrlAsync(srcUrl, context, finalizeDownload);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user