mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 17:25:32 +00:00
Added Search Page. Final Version for 1st internal relaese
This commit is contained in:
@@ -19,5 +19,5 @@ public interface IXMLService {
|
||||
public void UnUseProduction();
|
||||
public void SetInProduction();
|
||||
public void SetInProduction(XDocument document);
|
||||
public List<(string Index, List<(string Page, string Line, string Preview)> Results)>? SearchCollection(string collection, string searchword, IReaderService reader);
|
||||
public List<(string Index, List<(string Page, string Line, string Preview, string Identifier)> Results)>? SearchCollection(string collection, string searchword, IReaderService reader);
|
||||
}
|
||||
@@ -112,16 +112,16 @@ public class XMLService : IXMLService {
|
||||
_collectedProduction = ret.ToDictionary(x => x.Key, y => y.Value);
|
||||
}
|
||||
|
||||
public List<(string Index, List<(string Page, string Line, string Preview)> Results)>? SearchCollection(string collection, string searchword, IReaderService reader) {
|
||||
public List<(string Index, List<(string Page, string Line, string Preview, string Identifier)> Results)>? SearchCollection(string collection, string searchword, IReaderService reader) {
|
||||
if (!_collectedProduction.ContainsKey(collection)) return null;
|
||||
var searchableObjects = _collectedProduction[collection].Items;
|
||||
var res = new ConcurrentBag<(string Index, List<(string Page, string Line, string preview)> Results)>();
|
||||
var res = new ConcurrentBag<(string Index, List<(string Page, string Line, string preview, string identifier)> Results)>();
|
||||
var sw = StringHelpers.NormalizeWhiteSpace(searchword.Trim());
|
||||
Parallel.ForEach(searchableObjects, (obj) => {
|
||||
if (obj.Value.SearchText != null) {
|
||||
var state = new SearchState(sw);
|
||||
var rd = reader.RequestStringReader(obj.Value.SearchText);
|
||||
var parser = new HaWeb.HTMLParser.LineXMLHelper<SearchState>(state, rd, new StringBuilder(), null, null, null, SearchRules.TextRules, SearchRules.WhitespaceRules);
|
||||
var parser = new HaWeb.HTMLParser.LineXMLHelper<SearchState>(state, rd, new StringBuilder(), SearchRules.OTagRules, null, null, SearchRules.TextRules, SearchRules.WhitespaceRules);
|
||||
rd.Read();
|
||||
if (state.Results != null)
|
||||
res.Add((
|
||||
@@ -134,7 +134,8 @@ public class XMLService : IXMLService {
|
||||
.Where(y => y.Page == x.Page && y.Line == x.Line)
|
||||
.Select(x => x.Text)
|
||||
.FirstOrDefault(string.Empty)
|
||||
: ""
|
||||
: "",
|
||||
x.Identifier
|
||||
)).ToList()));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user