Testdateien hinzugefügt.

Schächte werden Importiert
This commit is contained in:
2023-04-18 21:06:28 +02:00
parent a854d7e8f1
commit 455d23e3ad
23 changed files with 356 additions and 21 deletions

View File

@@ -0,0 +1,52 @@
using SewerStammGen.Shared.Domain;
using Shared.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WWTech_KanalSchnittstelle.Importer
{
public class CSVImporter : IImport
{
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 };
}
public List<Schacht> LoadSchaechte(string filename, EEntwaeserung entwaeserung)
{
List<Schacht> result = new List<Schacht>();
if(!File.Exists(filename))
{
throw new FileNotFoundException(filename);
}
input = File.ReadAllLines(filename);
int zeile = -1;
foreach (string line in input)
{
zeile++;
if (zeile == 0) continue;
string[] parsed = line.Split(new char[] { ';' });
result.Add(new Schacht()
{
Objektbezeichnung = parsed[0],
RechtsWert = decimal.Parse(parsed[1].Replace('.',',')),
HochWert = decimal.Parse(parsed[2].Replace('.', ',')),
DeckelHoehe = decimal.Parse(parsed[3].Replace('.', ',')),
Projekt = projekt,
Entwaesserung = entwaeserung
});
}
return result;
}
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SewerStammGen.Shared\SewerStammGen.Shared.csproj" />
</ItemGroup>
</Project>