mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-30 01:35:32 +00:00
Added Upload functionality; still a bit janky in selecting the files to use...
This commit is contained in:
@@ -30,7 +30,7 @@ public class XMLService : IXMLService {
|
||||
|
||||
public Dictionary<string, IXMLRoot>? GetRootsDictionary() => this._Roots == null ? null : this._Roots;
|
||||
|
||||
public async Task<List<XMLRootDocument>?> ProbeHamannFile(XDocument document, ModelStateDictionary ModelState) {
|
||||
public List<XMLRootDocument>? ProbeHamannFile(XDocument document, ModelStateDictionary ModelState) {
|
||||
if (document.Root!.Name != "opus") {
|
||||
ModelState.AddModelError("Error", "A valid Hamann-Docuemnt must begin with <opus>");
|
||||
return null;
|
||||
@@ -86,6 +86,27 @@ public class XMLService : IXMLService {
|
||||
}
|
||||
}
|
||||
|
||||
public XElement? MergeUsedDocuments(ModelStateDictionary ModelState) {
|
||||
if (_Used == null || _Roots == null) {
|
||||
ModelState.AddModelError("Error", "Keine Dokumente ausgewählt");
|
||||
return null;
|
||||
}
|
||||
|
||||
var opus = new XElement("opus");
|
||||
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;
|
||||
}
|
||||
|
||||
var documents = category.Value.GetFileList();
|
||||
foreach (var document in documents!) {
|
||||
document.XMLRoot.MergeIntoFile(opus, document);
|
||||
}
|
||||
}
|
||||
return opus;
|
||||
}
|
||||
|
||||
private XMLRootDocument _createXMLRootDocument(IXMLRoot Root, XElement element) {
|
||||
var doc = new XMLRootDocument(Root, Root.Prefix, Root.GenerateIdentificationString(element), element);
|
||||
doc.Fields = Root.GenerateFields(doc);
|
||||
|
||||
Reference in New Issue
Block a user