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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user