csv writer erweitert
This commit is contained in:
@@ -11,32 +11,42 @@ namespace XMLProgramm
|
||||
class CSVWriter
|
||||
{
|
||||
FileStream handle = null;
|
||||
int handleOffset;
|
||||
|
||||
void writeToFile(string content)
|
||||
{
|
||||
content += Environment.NewLine;
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(content);
|
||||
handle.Write(bytes,0,bytes.Length);
|
||||
handle.Flush();
|
||||
|
||||
handleOffset += bytes.Length;
|
||||
}
|
||||
public CSVWriter()
|
||||
{
|
||||
handle = File.Create("./data.csv");
|
||||
string WriteHeader = "Filename,Inspektionsdatum,Straßenablaufeanzahl,SonstigeLeitungen,Längenzugabe,Hauptkanallänge";
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(WriteHeader);
|
||||
handle.Write(bytes,0,bytes.Length);
|
||||
handleOffset = 0;
|
||||
string WriteHeader = "Inspektionsdatum#Anzahl Straßenablaufe#Länge über 5m#SonstigeLeitungen#Sonstige Länge über 5m#Hauptkanallänge";
|
||||
writeToFile(WriteHeader);
|
||||
}
|
||||
|
||||
~CSVWriter()
|
||||
public void Save()
|
||||
{
|
||||
handle.Close();
|
||||
handle.Dispose();
|
||||
}
|
||||
|
||||
internal void WriteDay(Dictionary<ECalculatedResult, decimal> calculated, List<KanalObjekt> inspektionenAmTag)
|
||||
{
|
||||
int anzahlStraßenablaufe = (int)calculated[ECalculatedResult.STRASSENABLAUFANZAHL];
|
||||
int sonstigeLeitungen = (int)calculated[ECalculatedResult.SONSTIGEANZAHL];
|
||||
decimal LaengeZulageMeter = calculated[ECalculatedResult.LAENGEZULAGEMETER];
|
||||
decimal HauptkanalLänge = calculated[ECalculatedResult.HAUPTKANALUMSATZ] / 1.6m;
|
||||
decimal Strassenablaufzulage = calculated[ECalculatedResult.STRASSENABLAUFLAENGEZULAGEMETER];
|
||||
decimal Sonstigezulage = calculated[ECalculatedResult.SONSTIGELAENGEZULAGEMETER];
|
||||
decimal HauptkanalLänge = calculated[ECalculatedResult.HAUPTKANALLAENGE];
|
||||
|
||||
KanalObjekt last = inspektionenAmTag.Last();
|
||||
|
||||
string writeToFile = last.XmlFileName + "," + last.Inspektionsdaten.OptischeInspektion.Inspektionsdatum + ","+anzahlStraßenablaufe+","+sonstigeLeitungen+","+LaengeZulageMeter+","+HauptkanalLänge;
|
||||
|
||||
//throw new NotImplementedException();
|
||||
string entry = last.Inspektionsdaten.OptischeInspektion.Inspektionsdatum + "#"+anzahlStraßenablaufe+"#"+Strassenablaufzulage+"#"+sonstigeLeitungen+"#"+Sonstigezulage+"#"+HauptkanalLänge;
|
||||
writeToFile(entry);
|
||||
}
|
||||
}
|
||||
class Program
|
||||
|
||||
Reference in New Issue
Block a user