added basic start page setup; began rewrite of parser

This commit is contained in:
schnulller
2022-06-14 00:31:52 +02:00
parent 6be85d495b
commit 9e53de8be3
61 changed files with 532745 additions and 661 deletions

View File

@@ -4,7 +4,6 @@ using System.Web;
public class BriefeMetaViewModel {
public Meta Meta { get; private set; }
public bool HasMarginals { get; private set; }
public bool ShowZHData { get; private set; }
public bool HasText { get; set; } = true;
private string? _ParsedSenders;
@@ -47,9 +46,8 @@ public class BriefeMetaViewModel {
public (BriefeMetaViewModel, string)? Prev { get; set; }
public BriefeMetaViewModel(Meta meta, bool hasMarginals, bool showZHData) {
public BriefeMetaViewModel(Meta meta, bool hasMarginals) {
Meta = meta;
HasMarginals = hasMarginals;
ShowZHData = showZHData;
}
}

View File

@@ -1,15 +1,21 @@
namespace HaWeb.Models;
public class SucheViewModel {
public List<(int Year, List<BriefeMetaViewModel> LetterList)> Letters { get; private set; }
public List<(int Year, List<BriefeMetaViewModel> LetterList)>? Letters { get; private set; }
public int Count { get; private set; }
public int ActiveYears { get; private set; }
public List<(int StartYear, int EndYear)> AvailableYears { get; private set; }
public int ActiveYear { get; private set; }
public List<(int StartYear, int EndYear)>? AvailableYears { get; private set; }
public string? ActivePerson {get; set; }
public List<(string Key, string Name)>? AvailablePersons { get; private set; }
public SucheViewModel(List<(int Year, List<BriefeMetaViewModel> LetterList)> letters, int count, int activeYears, List<(int StartYear, int EndYear)> availableYears) {
public SucheViewModel(List<(int Year, List<BriefeMetaViewModel> LetterList)>? letters, int activeYear, List<(int StartYear, int EndYear)>? availableYears, List<(string Key, string Name)>? availablePersons) {
Letters = letters;
Count = count;
ActiveYears = activeYears;
if (letters != null)
Count = letters.Select(x => x.LetterList.Count).Aggregate(0, (x, y) => { x += y; return x; });
else
Count = 0;
ActiveYear = activeYear;
AvailableYears = availableYears;
AvailablePersons = availablePersons;
}
}

View File

@@ -8,20 +8,11 @@ using HaWeb.XMLParser;
public class XMLRootDocument {
private XElement? _Element;
private string? _filename;
private IFileInfo? _file;
[JsonIgnore]
public IXMLRoot XMLRoot { get; private set; }
[JsonIgnore]
public XElement Root {
get {
if (_Element == null) {
_Element = _GetElement();
}
return _Element;
}
}
public string FileName {
get {
if (_filename == null)
@@ -31,7 +22,17 @@ public class XMLRootDocument {
}
[JsonIgnore]
public IFileInfo? File { get; set; }
public IFileInfo? File {
get {
return _file;
}
set {
_file = value;
// After saving, we don't need to save the ELement anymore, it can get read in if it's used.
// We do this to prevent memory hogging. TODO: MAKE IT MORE EFFICIENT, EG ALL USED FILES HAVE SET ELEMENTS OR SO
// TODO Also make the file directory more efficient by reading in the directories as they are requested.
if (value != null) _Element = null;
} }
public string Prefix { get; private set; }
public DateTime Date { get; private set; }
@@ -89,7 +90,7 @@ public class XMLRootDocument {
}
}
private XElement _GetElement() {
public XElement GetElement() {
if (File == null || String.IsNullOrWhiteSpace(File.PhysicalPath) || !File.Exists)
throw new Exception("Es ist kein Pfad für die XML-Datei vorhanden.");
@@ -120,6 +121,15 @@ public class XMLRootDocument {
state.AddModelError("Error", "No corresponding Root Element found.");
return;
}
await root.CreateHamannDocument(Root).SaveAsync(stream, SaveOptions.DisableFormatting, new CancellationToken());
if (_Element == null) {
if (File == null) {
state.AddModelError("Error", "There is neither a file nor a saved element for this Document aborting the save.");
return;
}
_Element = GetElement();
}
await root.CreateHamannDocument(_Element).SaveAsync(stream, SaveOptions.DisableFormatting, new CancellationToken());
}
}