csv writer angefangen
This commit is contained in:
@@ -2,7 +2,8 @@ namespace XMLParser
|
||||
{
|
||||
public class KanalObjekt
|
||||
{
|
||||
public string XmlFileName {get;set;}
|
||||
public AbwassertechnischeAnlage Stammdaten { get; internal set; }
|
||||
public InspizierteAbwassertechnischeAnlage Inspektionsdaten { get; internal set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
|
||||
namespace XMLParser
|
||||
{
|
||||
@@ -49,7 +50,10 @@ namespace XMLParser
|
||||
inspektionsdaten = src.Item2;
|
||||
foreach(InspizierteAbwassertechnischeAnlage iat in inspektionsdaten) {
|
||||
AbwassertechnischeAnlage stammdatens = stammdaten.Find(x => x.Objektbezeichnung.Equals(iat.Objektbezeichnung));//;
|
||||
string[] filepathsplited = this.XmlFile.Split(Path.DirectorySeparatorChar);
|
||||
|
||||
KanalObjekte.Add(new KanalObjekt() {
|
||||
XmlFileName = filepathsplited[filepathsplited.Count()-1],
|
||||
Stammdaten = stammdatens,
|
||||
Inspektionsdaten = iat,
|
||||
});
|
||||
|
||||
@@ -3,15 +3,47 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using XMLParser;
|
||||
|
||||
namespace XMLProgramm
|
||||
{
|
||||
class CSVWriter
|
||||
{
|
||||
FileStream handle = null;
|
||||
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);
|
||||
}
|
||||
|
||||
~CSVWriter()
|
||||
{
|
||||
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;
|
||||
|
||||
KanalObjekt last = inspektionenAmTag.Last();
|
||||
|
||||
string writeToFile = last.XmlFileName + "," + last.Inspektionsdaten.OptischeInspektion.Inspektionsdatum + ","+anzahlStraßenablaufe+","+sonstigeLeitungen+","+LaengeZulageMeter+","+HauptkanalLänge;
|
||||
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
class Program
|
||||
{
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
CSVWriter csvWriter = new CSVWriter();
|
||||
List<KanalObjekt> objekte = new List<KanalObjekt>();
|
||||
DirectoryInfo info = new DirectoryInfo("./");
|
||||
FileInfo[] daten = info.GetFiles("*.xml");
|
||||
@@ -19,16 +51,14 @@ namespace XMLProgramm
|
||||
XMLParse ser = new XMLParse(aktuell.FullName);
|
||||
objekte.AddRange(ser.KanalObjekte);
|
||||
}
|
||||
|
||||
//XMLParse ser = new XMLParse("KS_Oldenburg_Heideweg.xml");
|
||||
//objekte.AddRange(ser.KanalObjekte);
|
||||
//objekte = objekte.OrderBy(x => x.Inspektionsdaten.OptischeInspektion.Inspektionsdatum);
|
||||
IEnumerable<string> datums = objekte.OrderBy(d => d.Inspektionsdaten.OptischeInspektion.Inspektionstime).Select(x => x.Inspektionsdaten.OptischeInspektion.Inspektionsdatum).Distinct();
|
||||
|
||||
decimal gesamt = 0.0m;
|
||||
//Dictionary<string,decimal> s = CalculateDay(objekte.FindAll(x => x.Inspektionsdaten.OptischeInspektion.Inspektionsdatum.Equals("05.08.2021")));
|
||||
foreach(string datum in datums) {
|
||||
Dictionary<ECalculatedResult,decimal> s = Calculate.CalculateDay(objekte.FindAll(x => x.Inspektionsdaten.OptischeInspektion.Inspektionsdatum.Equals(datum)));
|
||||
List<KanalObjekt> InspektionenAmTag = objekte.FindAll(x => x.Inspektionsdaten.OptischeInspektion.Inspektionsdatum.Equals(datum));
|
||||
Dictionary<ECalculatedResult,decimal> s = Calculate.CalculateDay(InspektionenAmTag);
|
||||
csvWriter.WriteDay(s,InspektionenAmTag);
|
||||
Console.WriteLine("Umsatz am : "+datum + " " + s[ECalculatedResult.GESAMTUMSATZ]);
|
||||
gesamt +=s[ECalculatedResult.GESAMTUMSATZ];
|
||||
//if(datum.Equals("05.08.2021")) Debugger.Break();
|
||||
|
||||
Reference in New Issue
Block a user