#409 bug fixes
This commit is contained in:
parent
621bc118cb
commit
5748fdd55e
@ -18,7 +18,7 @@ namespace RMuseum.Services.Implementation
|
||||
{
|
||||
public partial class PDFLibraryService
|
||||
{
|
||||
private async Task<RServiceResult<bool>> StartImportingSohaLibraryUrlAsync(RMuseumDbContext ctx, string srcUrl)
|
||||
private async Task<RServiceResult<int>> StartImportingSohaLibraryUrlAsync(RMuseumDbContext ctx, string srcUrl)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -28,7 +28,7 @@ namespace RMuseum.Services.Implementation
|
||||
null
|
||||
)
|
||||
{
|
||||
return new RServiceResult<bool>(false, $"duplicated srcUrl '{srcUrl}'");
|
||||
return new RServiceResult<int>(0, $"duplicated srcUrl '{srcUrl}'");
|
||||
}
|
||||
if (
|
||||
(
|
||||
@ -40,18 +40,18 @@ namespace RMuseum.Services.Implementation
|
||||
null
|
||||
)
|
||||
{
|
||||
return new RServiceResult<bool>(false, $"Job is already scheduled or running for importing source url: {srcUrl}");
|
||||
return new RServiceResult<int>(0, $"Job is already scheduled or running for importing source url: {srcUrl}");
|
||||
}
|
||||
|
||||
return await ImportSohaLibraryUrlAsync(srcUrl, ctx, true);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
return new RServiceResult<int>(0, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<RServiceResult<bool>> ImportSohaLibraryUrlAsync(string srcUrl, RMuseumDbContext context, bool finalizeDownload)
|
||||
private async Task<RServiceResult<int>> ImportSohaLibraryUrlAsync(string srcUrl, RMuseumDbContext context, bool finalizeDownload)
|
||||
{
|
||||
/*
|
||||
var oldJobs = await context.ImportJobs.ToArrayAsync();
|
||||
@ -115,7 +115,7 @@ namespace RMuseum.Services.Implementation
|
||||
job.Exception = $"Http result is not ok ({result.StatusCode}) for {srcUrl}";
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -127,7 +127,7 @@ namespace RMuseum.Services.Implementation
|
||||
job.Exception = $"/item/download/ not found in html source.";
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
|
||||
List<RTagValue> meta = new List<RTagValue>();
|
||||
@ -161,7 +161,7 @@ namespace RMuseum.Services.Implementation
|
||||
job.Exception = $"title-normal-for-book-name not found in {srcUrl}";
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
idxStart = html.IndexOf(">", idx);
|
||||
if (idxStart != -1)
|
||||
@ -374,7 +374,7 @@ namespace RMuseum.Services.Implementation
|
||||
job.Exception = "Language is not فارسی";
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
}
|
||||
if (tagName == "شماره جلد")
|
||||
@ -516,7 +516,7 @@ namespace RMuseum.Services.Implementation
|
||||
job.Status = ImportJobStatus.Succeeded;
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
|
||||
using (var client = new HttpClient())
|
||||
@ -580,6 +580,16 @@ namespace RMuseum.Services.Implementation
|
||||
|
||||
context.Update(pdf);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<int>(res.Result.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(string.IsNullOrEmpty(res.ExceptionString))
|
||||
{
|
||||
return new RServiceResult<int>(0, "ImportLocalPDFFileAsync result was null");
|
||||
}
|
||||
|
||||
return new RServiceResult<int>(0, res.ExceptionString);
|
||||
}
|
||||
|
||||
}
|
||||
@ -590,12 +600,12 @@ namespace RMuseum.Services.Implementation
|
||||
job.Exception = $"Http result is not ok ({result.StatusCode}) for {downloadUrl}";
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -606,10 +616,10 @@ namespace RMuseum.Services.Implementation
|
||||
job.EndTime = DateTime.Now;
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
|
||||
return new RServiceResult<bool>(true);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -18,7 +18,7 @@ namespace RMuseum.Services.Implementation
|
||||
{
|
||||
public partial class PDFLibraryService
|
||||
{
|
||||
private async Task<RServiceResult<bool>> StartImportingELiteratureBookUrlAsync(RMuseumDbContext ctx, string srcUrl)
|
||||
private async Task<RServiceResult<int>> StartImportingELiteratureBookUrlAsync(RMuseumDbContext ctx, string srcUrl)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -28,7 +28,7 @@ namespace RMuseum.Services.Implementation
|
||||
null
|
||||
)
|
||||
{
|
||||
return new RServiceResult<bool>(false, $"duplicated srcUrl '{srcUrl}'");
|
||||
return new RServiceResult<int>(0, $"duplicated srcUrl '{srcUrl}'");
|
||||
}
|
||||
if (
|
||||
(
|
||||
@ -40,17 +40,17 @@ namespace RMuseum.Services.Implementation
|
||||
null
|
||||
)
|
||||
{
|
||||
return new RServiceResult<bool>(false, $"Job is already scheduled or running for importing source url: {srcUrl}");
|
||||
return new RServiceResult<int>(0, $"Job is already scheduled or running for importing source url: {srcUrl}");
|
||||
}
|
||||
|
||||
return await ImportELiteratureBookLibraryUrlAsync(srcUrl, ctx, true);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
return new RServiceResult<int>(0, exp.ToString());
|
||||
}
|
||||
}
|
||||
private async Task<RServiceResult<bool>> ImportELiteratureBookLibraryUrlAsync(string srcUrl, RMuseumDbContext context, bool finalizeDownload)
|
||||
private async Task<RServiceResult<int>> ImportELiteratureBookLibraryUrlAsync(string srcUrl, RMuseumDbContext context, bool finalizeDownload)
|
||||
{
|
||||
/*
|
||||
var oldJobs = await context.ImportJobs.ToArrayAsync();
|
||||
@ -114,7 +114,7 @@ namespace RMuseum.Services.Implementation
|
||||
job.Exception = $"Http result is not ok ({result.StatusCode}) for {srcUrl}";
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ namespace RMuseum.Services.Implementation
|
||||
job.Exception = $"/download/ not found in html source.";
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
|
||||
List<RTagValue> meta = new List<RTagValue>();
|
||||
@ -144,7 +144,7 @@ namespace RMuseum.Services.Implementation
|
||||
job.Exception = $"\"book-title\" not found in {srcUrl}";
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
idxStart = html.IndexOf(">", idx);
|
||||
if (idxStart != -1)
|
||||
@ -397,7 +397,7 @@ namespace RMuseum.Services.Implementation
|
||||
job.Exception = "Language is not فارسی";
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
}
|
||||
if (tagName == "شماره جلد")
|
||||
@ -559,7 +559,7 @@ namespace RMuseum.Services.Implementation
|
||||
job.Status = ImportJobStatus.Succeeded;
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
|
||||
using (var client = new HttpClient())
|
||||
@ -610,6 +610,16 @@ namespace RMuseum.Services.Implementation
|
||||
|
||||
context.Update(pdf);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<int>(res.Result.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(res.ExceptionString))
|
||||
{
|
||||
return new RServiceResult<int>(0, "ImportLocalPDFFileAsync result was null");
|
||||
}
|
||||
|
||||
return new RServiceResult<int>(0, res.ExceptionString);
|
||||
}
|
||||
|
||||
}
|
||||
@ -620,7 +630,7 @@ namespace RMuseum.Services.Implementation
|
||||
job.Exception = $"Http result is not ok ({result.StatusCode}) for {downloadUrl}";
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -636,12 +646,9 @@ namespace RMuseum.Services.Implementation
|
||||
job.EndTime = DateTime.Now;
|
||||
context.Update(job);
|
||||
await context.SaveChangesAsync();
|
||||
return new RServiceResult<bool>(false, job.Exception);
|
||||
return new RServiceResult<int>(0, job.Exception);
|
||||
}
|
||||
|
||||
return new RServiceResult<bool>(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -50,7 +50,7 @@ namespace RMuseum.Services.Implementation
|
||||
/// <param name="context"></param>
|
||||
/// <param name="srcUrl"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<RServiceResult<bool>> ImportfFromKnownSourceAsync(RMuseumDbContext context, string srcUrl)
|
||||
private async Task<RServiceResult<int>> ImportfFromKnownSourceAsync(RMuseumDbContext context, string srcUrl)
|
||||
{
|
||||
if (srcUrl.Contains("https://sohalibrary.com"))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user