XML exporter erweitert

This commit is contained in:
2023-04-28 15:33:22 +02:00
parent ef2c9bfe6b
commit b22b9855fa
5 changed files with 103 additions and 28 deletions

View File

@@ -16,15 +16,26 @@ namespace WWTech_KanalSchnittstelle.Importer
}
public class CSVImporter : IImport
{
private string[] input;
private string[]? input;
private readonly Projekt projekt;
#pragma warning disable CS8618 // Ein Non-Nullable-Feld muss beim Beenden des Konstruktors einen Wert ungleich NULL enthalten. Erwägen Sie die Deklaration als Nullable.
public CSVImporter(int projektID)
#pragma warning restore CS8618 // Ein Non-Nullable-Feld muss beim Beenden des Konstruktors einen Wert ungleich NULL enthalten. Erwägen Sie die Deklaration als Nullable.
{
projekt = new Projekt() { Id = projektID };
}
private decimal parseKoordinate(string input)
{
decimal result = 0m;
input = string.Format("{0:0.000}", input).Replace('.', ',');
if(decimal.TryParse(input, out result))
{
throw new Exception("Konnte koordinate nicht parsen");
}
return result;
}
public List<Schacht> LoadSchaechte(string filename, EEntwaeserung entwaeserung)
{
List<Schacht> result = new List<Schacht>();
@@ -58,15 +69,15 @@ namespace WWTech_KanalSchnittstelle.Importer
if(kennung == EKennung.DECKEL)
{
schacht.DeckelRechtsWert = decimal.Parse(parsed[1].Replace('.', ','));
schacht.DeckelHochWert = decimal.Parse(parsed[2].Replace('.', ','));
schacht.DeckelHoehe = decimal.Parse(parsed[3].Replace('.', ','));
schacht.DeckelRechtsWert = parseKoordinate(parsed[1]);
schacht.DeckelHochWert = parseKoordinate(parsed[2]);
schacht.DeckelHoehe = parseKoordinate(parsed[3]);
}
if(kennung == EKennung.SOHLE)
{
schacht.SohlRechtsWert = decimal.Parse(parsed[1].Replace('.', ','));
schacht.SohlHochWert = decimal.Parse(parsed[2].Replace('.', ','));
schacht.SohlHoehe = decimal.Parse(parsed[3].Replace('.', ','));
schacht.SohlRechtsWert = parseKoordinate(parsed[1]);
schacht.SohlHochWert = parseKoordinate(parsed[2]);
schacht.SohlHoehe = parseKoordinate(parsed[3]);
}