From 6d737517edf4af5de547c5fb743555afb786e6f5 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Thu, 27 Jul 2023 16:42:50 +0330 Subject: [PATCH] #402 restricting soha input source --- .../PDFLibraryService-SohaLibrary.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/RMuseum/Services/Implementation/PDFLibraryService-Partials/PDFLibraryService-SohaLibrary.cs b/RMuseum/Services/Implementation/PDFLibraryService-Partials/PDFLibraryService-SohaLibrary.cs index ce0ce4ae..2fd73d15 100644 --- a/RMuseum/Services/Implementation/PDFLibraryService-Partials/PDFLibraryService-SohaLibrary.cs +++ b/RMuseum/Services/Implementation/PDFLibraryService-Partials/PDFLibraryService-SohaLibrary.cs @@ -139,6 +139,7 @@ namespace RMuseum.Services.Implementation List meta = new List(); int idxStart; int idx = html.IndexOf("branch-link"); + string firstHandSource = ""; if (idx != -1) { idxStart = html.IndexOf(">", idx); @@ -148,14 +149,25 @@ namespace RMuseum.Services.Implementation if (idxEnd != -1) { + firstHandSource = html.Substring(idxStart + 1, idxEnd - idxStart - 1); meta.Add ( - await TagHandler.PrepareAttribute(context, "First Hand Source", html.Substring(idxStart + 1, idxEnd - idxStart - 1), 1) + await TagHandler.PrepareAttribute(context, "First Hand Source", firstHandSource, 1) ); } } } + if(firstHandSource != "کتابخانه تخصصی ادبیات") + { + job.EndTime = DateTime.Now; + job.Status = ImportJobStatus.Failed; + job.Exception = $"کتابخانه تخصصی ادبیات not found."; + context.Update(job); + await context.SaveChangesAsync(); + return; + } + idx = html.IndexOf("title-normal-for-book-name");