WIP umsatz für Junker nach Straßen
This commit is contained in:
53
XMLProgramm/CSVWriter.cs
Normal file
53
XMLProgramm/CSVWriter.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
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<ECalculatedResult, decimal> calculated, List<KanalObjekt> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,58 +3,32 @@ 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;
|
||||
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");
|
||||
handleOffset = 0;
|
||||
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<ECalculatedResult, decimal> calculated, List<KanalObjekt> 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.HAUPTKANALLAENGE];
|
||||
|
||||
KanalObjekt last = inspektionenAmTag.Last();
|
||||
|
||||
string entry = last.Inspektionsdaten.OptischeInspektion.Inspektionsdatum + "#"+anzahlStraßenablaufe+"#"+Strassenablaufzulage+"#"+sonstigeLeitungen+"#"+Sonstigezulage+"#"+HauptkanalLänge;
|
||||
writeToFile(entry);
|
||||
}
|
||||
}
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
CSVWriter csvWriter = new CSVWriter();
|
||||
List<KanalObjekt> objekte = new List<KanalObjekt>();
|
||||
|
||||
StrassenUmsatz(csvWriter,objekte);
|
||||
//TagesUmsatz(csvWriter,objekte);
|
||||
}
|
||||
|
||||
private static void StrassenUmsatz(CSVWriter csvWriter, List<KanalObjekt> objekte)
|
||||
{
|
||||
// KS_Oldenburg_Lönsweg.xml
|
||||
XMLParse ser = new XMLParse("2021-07-29_KR_H_L_Oldenburg_Eichenstraße.xml");
|
||||
objekte.AddRange(ser.KanalObjekte);
|
||||
Dictionary<ECalculatedResult,decimal> d = Calculate.CalculateDay(objekte);
|
||||
|
||||
}
|
||||
|
||||
static void TagesUmsatz(CSVWriter csvWriter, List<KanalObjekt> objekte)
|
||||
{
|
||||
DirectoryInfo info = new DirectoryInfo("./");
|
||||
FileInfo[] daten = info.GetFiles("*.xml");
|
||||
foreach(FileInfo aktuell in daten) {
|
||||
@@ -77,7 +51,6 @@ namespace XMLProgramm
|
||||
decimal Durchschnitt = gesamt / anzahlTage;
|
||||
int prognosedays = 63;
|
||||
Console.WriteLine(string.Format("Tage : {0} \nGesamt umsatz: {1}\nDurchschnitt : {2}\nPrognose für {3} tage {4}",anzahlTage,gesamt,Durchschnitt,prognosedays,prognosedays*Durchschnitt));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user