Kandis exporter geschrieben
Deckel und Sohlhöhe werden gespeichert
This commit is contained in:
79
WWTech_KanalSchnittstelle/Exporter/Kandis/KANDIS_Exporter.cs
Normal file
79
WWTech_KanalSchnittstelle/Exporter/Kandis/KANDIS_Exporter.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WWTech_KanalSchnittstelle.Exporter.Kandis
|
||||
{
|
||||
public static class ExporterHelper
|
||||
{
|
||||
public static Dictionary<string, int> Exporters = new Dictionary<string, int>()
|
||||
{
|
||||
{ "KANSCH4.0",557 },
|
||||
{ "KANSCH6.0",2041 },
|
||||
{ "KANHAL4.0",530 },
|
||||
{ "KANHAL6.0",2167 }
|
||||
};
|
||||
}
|
||||
public abstract class KANDIS_Exporter : IDisposable
|
||||
{
|
||||
private StreamWriter sw;
|
||||
char[] zeile;
|
||||
|
||||
protected string Zeile => new string(zeile);
|
||||
|
||||
public KANDIS_Exporter(string filename, int maxzeilen)
|
||||
{
|
||||
|
||||
sw = new StreamWriter(filename, append: false, Encoding.GetEncoding("ISO-8859-1"));
|
||||
|
||||
zeile = new char[1476];
|
||||
ClearLine();
|
||||
}
|
||||
|
||||
private void ClearLine()
|
||||
{
|
||||
for (int i = 0; i < zeile.Length; i++)
|
||||
{
|
||||
zeile[i] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
protected void WriteLineInFile()
|
||||
{
|
||||
sw.WriteLine(Zeile);
|
||||
sw.Flush();
|
||||
ClearLine();
|
||||
}
|
||||
|
||||
protected void WriteContent(Tuple<uint, uint> spalten, string content)
|
||||
{
|
||||
uint start = spalten.Item1 - 1;
|
||||
uint ende = spalten.Item2 - 1;
|
||||
|
||||
uint length = ende - start;
|
||||
if(length > content.Length)
|
||||
{
|
||||
throw new Exception("Inhalt des Feldes ist zu lang");
|
||||
}
|
||||
|
||||
int counter = 0;
|
||||
for (uint i = start; i < (content.Length + start); i++)
|
||||
{
|
||||
zeile[i] = content[counter];
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
protected void CloseStream()
|
||||
{
|
||||
sw.Close();
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
sw.Close();
|
||||
sw.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WWTech_KanalSchnittstelle.Exporter.Kandis
|
||||
{
|
||||
public class KANDIS_HALTUNG60 : KANDIS_Exporter
|
||||
{
|
||||
public KANDIS_HALTUNG60(string filename, List<Kanal> kanaele) : base(filename, ExporterHelper.Exporters["KANHAL6.0"])
|
||||
{
|
||||
foreach(Kanal haltung in kanaele)
|
||||
{
|
||||
WriteContent(new Tuple<uint, uint>(3, 17), haltung.StartSchacht.Objektbezeichnung);
|
||||
WriteContent(new Tuple<uint, uint>(24, 38), haltung.EndSchacht.Objektbezeichnung);
|
||||
WriteContent(new Tuple<uint, uint>(45, 64), haltung.Objektbezeichnung);
|
||||
WriteContent(new Tuple<uint, uint>(66, 75), "K"); // Kanalart
|
||||
WriteContent(new Tuple<uint, uint>(77, 86), "S"); // Entwässerungskennzeichen
|
||||
WriteContent(new Tuple<uint, uint>(88, 97), "B"); // Betriebzustand
|
||||
WriteContent(new Tuple<uint, uint>(173, 182), haltung.Material);
|
||||
WriteContent(new Tuple<uint, uint>(184, 193), "1"); // Profil
|
||||
WriteContent(new Tuple<uint, uint>(195, 198), haltung.DN.ToString()); // Profilhöhe
|
||||
WriteContent(new Tuple<uint, uint>(195, 198), haltung.DN.ToString()); // Profilbreite
|
||||
WriteContent(new Tuple<uint, uint>(227,234), haltung.Haltungslaenge.ToString());
|
||||
WriteContent(new Tuple<uint, uint>(236, 245), "1"); // Status haltungslänge
|
||||
WriteContent(new Tuple<uint, uint>(307, 314), ""); // Sohlhöhe AS
|
||||
WriteContent(new Tuple<uint, uint>(316, 325), "1"); // Status Sohlhöhe AS
|
||||
WriteContent(new Tuple<uint, uint>(327, 334), ""); // Sohlhöhe ES
|
||||
WriteContent(new Tuple<uint, uint>(336, 345), "1"); // Status Sohlhöhe ES
|
||||
WriteContent(new Tuple<uint, uint>(1152, 1161), "Marwede"); // Vermesser
|
||||
WriteContent(new Tuple<uint, uint>(1257, 1266), "19.04.2023"); // Aufnahmedatum
|
||||
}
|
||||
CloseStream();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using SewerStammGen.Shared.Domain;
|
||||
|
||||
namespace WWTech_KanalSchnittstelle.Exporter.Kandis
|
||||
{
|
||||
public class KANDIS_SCHACHT60 : KANDIS_Exporter
|
||||
{
|
||||
public KANDIS_SCHACHT60(string filename,List<Schacht> schaechte) : base(filename, ExporterHelper.Exporters["KANSCH6.0"])
|
||||
{
|
||||
|
||||
foreach(Schacht schacht in schaechte)
|
||||
{
|
||||
WriteContent(new Tuple<uint, uint>(3, 17), schacht.Objektbezeichnung);
|
||||
WriteContent(new Tuple<uint, uint>(56, 65), "S");
|
||||
WriteContent(new Tuple<uint, uint>(67, 76), "IB");
|
||||
WriteContent(new Tuple<uint, uint>(78, 87), "RESC");
|
||||
WriteContent(new Tuple<uint, uint>(190, 197), schacht.DeckelHoehe.ToString());
|
||||
WriteContent(new Tuple<uint, uint>(199, 208), "1"); // Status Deckelhöhe
|
||||
WriteContent(new Tuple<uint, uint>(210, 217), schacht.SohlHoehe.ToString());
|
||||
WriteContent(new Tuple<uint, uint>(219, 228), "1"); // Status Sohlhöhe
|
||||
// Schachtmittelpunktkoordinaten
|
||||
WriteContent(new Tuple<uint, uint>(284, 298), schacht.DeckelRechtsWert.ToString());
|
||||
WriteContent(new Tuple<uint, uint>(300, 314), schacht.DeckelHochWert.ToString());
|
||||
WriteContent(new Tuple<uint, uint>(316, 325), "1"); // Status der Schachtmittelpunktkoordinaten
|
||||
// Deckelkoordinaten
|
||||
WriteContent(new Tuple<uint, uint>(370, 384), schacht.DeckelRechtsWert.ToString());
|
||||
WriteContent(new Tuple<uint, uint>(386, 400), schacht.DeckelHochWert.ToString());
|
||||
WriteContent(new Tuple<uint, uint>(402, 411), "1"); // Status der Deckelkoordinaten
|
||||
|
||||
WriteContent(new Tuple<uint, uint>(1222, 1231), "Marwede"); // Vermesser
|
||||
WriteContent(new Tuple<uint, uint>(1319, 1328), "19.04.2023"); // Aufnahmedatum
|
||||
WriteLineInFile();
|
||||
}
|
||||
CloseStream();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WWTech_KanalSchnittstelle.Exporter.Kandis
|
||||
{
|
||||
public class KANDIS_Stammdaten
|
||||
{
|
||||
private string _line;
|
||||
internal string ToString(int startSpalte, int endSpalte)
|
||||
{
|
||||
try
|
||||
{
|
||||
string text = _line.Substring(startSpalte - 1, endSpalte - startSpalte + 1);
|
||||
return text.Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user