diff --git a/RMuseum/Models/PDFLibrary/ViewModels/PDFPageOCRDataViewModel.cs b/RMuseum/Models/PDFLibrary/ViewModels/PDFPageOCRDataViewModel.cs
index da9f01ee..cf058045 100644
--- a/RMuseum/Models/PDFLibrary/ViewModels/PDFPageOCRDataViewModel.cs
+++ b/RMuseum/Models/PDFLibrary/ViewModels/PDFPageOCRDataViewModel.cs
@@ -10,7 +10,7 @@ namespace RMuseum.Models.PDFLibrary.ViewModels
///
/// Id
///
- public int id { get; set; }
+ public int Id { get; set; }
///
/// full resolution image width
@@ -27,11 +27,6 @@ namespace RMuseum.Models.PDFLibrary.ViewModels
///
public bool OCRed { get; set; }
- ///
- /// ocr date time
- ///
- public DateTime OCRTime { get; set; }
-
///
/// page text
///
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index 95c660ce..e5c7983f 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -13047,7 +13047,7 @@
PDF Page OCR Data View Model
-
+
Id
@@ -13067,11 +13067,6 @@
ocred
-
-
- ocr date time
-
-
page text
@@ -18663,6 +18658,19 @@
+
+
+ get next un-ocred PDF Book
+
+
+
+
+
+ set pdf page ocr info (and if a book whole pages are ocred the book ocred flag is set to true)
+
+
+
+
Database Context
@@ -19891,6 +19899,19 @@
+
+
+ get next un-ocred PDF Book
+
+
+
+
+
+ set pdf page ocr info (and if a book whole pages are ocred the book ocred flag is set to true)
+
+
+
+
manipulating picture files
diff --git a/RMuseum/Services/IPDFLibraryService.cs b/RMuseum/Services/IPDFLibraryService.cs
index db7a5ffb..f0607734 100644
--- a/RMuseum/Services/IPDFLibraryService.cs
+++ b/RMuseum/Services/IPDFLibraryService.cs
@@ -383,5 +383,18 @@ namespace RMuseum.Services
///
///
Task> SynchronizePDFGanjoorLinkAsync(Guid linkId);
+
+ ///
+ /// get next un-ocred PDF Book
+ ///
+ ///
+ Task> GetNextUnOCRedPDFBookAsync();
+
+ ///
+ /// set pdf page ocr info (and if a book whole pages are ocred the book ocred flag is set to true)
+ ///
+ ///
+ ///
+ Task> SetPDFPageOCRInfoAsync(PDFPageOCRDataViewModel model);
}
}
diff --git a/RMuseum/Services/Implementation/PDFLibraryService.cs b/RMuseum/Services/Implementation/PDFLibraryService.cs
index ce024670..cfdc4217 100644
--- a/RMuseum/Services/Implementation/PDFLibraryService.cs
+++ b/RMuseum/Services/Implementation/PDFLibraryService.cs
@@ -1568,6 +1568,72 @@ namespace RMuseum.Services.Implementation
return new RServiceResult(true);
}
+ ///
+ /// get next un-ocred PDF Book
+ ///
+ ///
+ public async Task> GetNextUnOCRedPDFBookAsync()
+ {
+ try
+ {
+ var pdfBook = await _context.PDFBooks.AsNoTracking()
+ .Include(b => b.PDFFile)
+ .Include(b => b.Pages)
+ .Where(b => b.Status == PublishStatus.Published && b.OCRed == false)
+ .OrderBy(b => b.Id)
+ .FirstOrDefaultAsync();
+ return new RServiceResult(pdfBook);
+
+ }
+ catch (Exception exp)
+ {
+ return new RServiceResult(null, exp.ToString());
+ }
+ }
+
+ ///
+ /// set pdf page ocr info (and if a book whole pages are ocred the book ocred flag is set to true)
+ ///
+ ///
+ ///
+ public async Task> SetPDFPageOCRInfoAsync(PDFPageOCRDataViewModel model)
+ {
+ try
+ {
+ var dbPage = await _context.PDFPages.Where(p => p.Id == model.Id).SingleAsync();
+ dbPage.FullResolutionImageWidth = model.FullResolutionImageWidth;
+ dbPage.FullResolutionImageHeight = model.FullResolutionImageHeight;
+ dbPage.OCRed = model.OCRed;
+ dbPage.OCRTime = DateTime.Now;
+ dbPage.PageText = model.PageText;
+ _context.Update(dbPage);
+ await _context.SaveChangesAsync();
+
+ var pdfBook = await _context.PDFBooks
+ .Include(b => b.Pages)
+ .Where(b => b.Id == dbPage.PDFBookId)
+ .SingleAsync();
+ if(!pdfBook.Pages.Any(p => p.OCRed == false))
+ {
+ pdfBook.OCRed = true;
+ pdfBook.OCRTime = DateTime.Now;
+ _context.Update(pdfBook);
+ await _context.SaveChangesAsync();
+ }
+ else if(pdfBook.OCRed)
+ {
+ pdfBook.OCRed = false;
+ _context.Update(pdfBook);
+ await _context.SaveChangesAsync();
+ }
+ return new RServiceResult(true);
+ }
+ catch (Exception exp)
+ {
+ return new RServiceResult(false, exp.ToString());
+ }
+ }
+
///
/// Database Context
///