using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using XMLParser; namespace XMLProgramm { [DebuggerDisplay("{" + nameof(GetDebuggerDisplay) + "(),nq}")] class CSVWriter { FileStream handle = null; void writeToFile(string content) { content += Environment.NewLine; byte[] bytes = Encoding.UTF8.GetBytes(content); handle.Write(bytes,0,bytes.Length); handle.Flush(); } public CSVWriter() { handle = File.Create("./data.csv"); string WriteHeader = "Inspektionsdatum#Anzahl Straßenablaufe#Länge über 5m#SonstigeLeitungen#Sonstige Länge über 5m#Hauptkanallänge"; writeToFile(WriteHeader); } public void Save() { handle.Close(); } internal void WriteDay(Dictionary calculated, List inspektionenAmTag) { int anzahlStraßenablaufe = (int)calculated[ECalculatedResult.STRASSENABLAUFANZAHL]; int sonstigeLeitungen = (int)calculated[ECalculatedResult.SONSTIGEANZAHL]; decimal Strassenablaufzulage = calculated[ECalculatedResult.STRASSENABLAUFLAENGEZULAGEMETER]; decimal Sonstigezulage = calculated[ECalculatedResult.SONSTIGELAENGEZULAGEMETER]; decimal HauptkanalLänge = calculated[ECalculatedResult.DN150DN250]; KanalObjekt last = inspektionenAmTag.Last(); string entry = last.Inspektionsdaten.OptischeInspektion.Inspektionsdatum + "#"+anzahlStraßenablaufe+"#"+Strassenablaufzulage+"#"+sonstigeLeitungen+"#"+Sonstigezulage+"#"+HauptkanalLänge; writeToFile(entry); } private string GetDebuggerDisplay() { return ToString(); } } }