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