Added Models for displaying files and all kinds of stuff

This commit is contained in:
schnulller
2022-06-06 22:44:56 +02:00
parent cb3a09a7de
commit 84048f9fe9
17 changed files with 248 additions and 47 deletions

View File

@@ -7,6 +7,8 @@ public class XMLService : IXMLService {
private Dictionary<string, FileList?>? _Used;
private Dictionary<string, IXMLRoot>? _Roots;
private Dictionary<string, FileList?>? _InProduction;
public XMLService() {
// Getting all classes which implement IXMLRoot for possible document endpoints
var types = _GetAllTypesThatImplementInterface<IXMLRoot>().ToList();
@@ -30,6 +32,8 @@ public class XMLService : IXMLService {
public Dictionary<string, IXMLRoot>? GetRootsDictionary() => this._Roots == null ? null : this._Roots;
public Dictionary<string, FileList?>? GetInProduction() => this._InProduction;
public List<XMLRootDocument>? ProbeHamannFile(XDocument document, ModelStateDictionary ModelState) {
if (document.Root!.Name != "opus") {
ModelState.AddModelError("Error", "A valid Hamann-Docuemnt must begin with <opus>");
@@ -93,17 +97,20 @@ public class XMLService : IXMLService {
}
var opus = new XElement("opus");
var inProduction = new Dictionary<string, FileList?>();
foreach (var category in _Used) {
if (category.Value == null || category.Value.GetFileList() == null || !category.Value.GetFileList()!.Any()) {
ModelState.AddModelError("Error", _Roots![category.Key].Type + " nicht vorhanden.");
return null;
}
inProduction.Add(category.Key, category.Value);
var documents = category.Value.GetFileList();
foreach (var document in documents!) {
document.XMLRoot.MergeIntoFile(opus, document);
}
}
_InProduction = inProduction;
return opus;
}