Added a workaround for a bug in the parser

This commit is contained in:
schnulller
2022-06-07 22:35:49 +02:00
parent 965ffd54f8
commit d4b6d04654
9 changed files with 56 additions and 23 deletions

View File

@@ -35,8 +35,7 @@ public class HaDocumentWrapper : IHaDocumentWrappper {
Library = HaDocument.Document.Create(new HaWeb.Settings.HaDocumentOptions() { HamannXMLFilePath = filepath, AvailableYearRange = (_startYear, _endYear) });
}
catch (Exception ex) {
if (ModelState != null) ModelState.AddModelError("Error:", "Das Dokument konnte nicht geparst werden: " + ex.Message);
Console.WriteLine(ex.Message);
if (ModelState != null) ModelState.AddModelError("Error", "Das Dokument konnte nicht geparst werden: " + ex.Message);
return null;
}
return Library;

View File

@@ -12,4 +12,5 @@ public interface IXMLProvider {
public List<IFileInfo>? GetHamannFiles();
public IFileInfo? GetInProduction();
public void SetInProduction(IFileInfo info);
public void DeleteHamannFile(string filename);
}

View File

@@ -10,7 +10,7 @@ public class XMLProvider : IXMLProvider {
private Dictionary<string, FileList?>? _Files;
private Dictionary<string, IXMLRoot>? _Roots;
private List<IFileInfo>? _HamannFiles;
private IFileInfo? _InProduction;
private Stack<IFileInfo>? _InProduction;
public XMLProvider(IFileProvider provider, IXMLService xmlservice) {
_fileProvider = provider;
@@ -26,9 +26,24 @@ public class XMLProvider : IXMLProvider {
public List<IFileInfo>? GetHamannFiles() => this._HamannFiles;
public IFileInfo? GetInProduction() => this._InProduction;
public IFileInfo? GetInProduction() {
if (_InProduction == null || !_InProduction.Any()) return null;
return this._InProduction.Peek();
}
public void SetInProduction(IFileInfo info) => _InProduction = info;
public void DeleteHamannFile(string filename) {
if (_HamannFiles == null) return;
var files = _HamannFiles.Where(x => x.Name == filename);
foreach (var file in files) {
File.Delete(file.PhysicalPath);
}
_HamannFiles.RemoveAll(x => x.Name == filename);
}
public void SetInProduction(IFileInfo info) {
if (_InProduction == null) _InProduction = new Stack<IFileInfo>();
_InProduction.Push(info);
}
public FileList? GetFiles(string prefix)
=> _Files != null && _Files.ContainsKey(prefix) ? _Files[prefix] : null;
@@ -89,7 +104,6 @@ public class XMLProvider : IXMLProvider {
if (_HamannFiles == null) _HamannFiles = new List<IFileInfo>();
_HamannFiles.RemoveAll(x => x.Name == info.Name);
_HamannFiles.Add(info);
_InProduction = info;
return info;
}