Contracts hinzugefügt
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
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,7 +3,8 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using XMLParser;
|
||||
using XMLParser.Contract;
|
||||
using XMLParser.Model;
|
||||
|
||||
namespace XMLProgramm
|
||||
{
|
||||
@@ -11,46 +12,16 @@ namespace XMLProgramm
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
CSVWriter csvWriter = new CSVWriter();
|
||||
|
||||
ICSVWriter csvWriter = new CSVWriter();
|
||||
//CSVWriter csvWriter = new CSVWriter();
|
||||
List<KanalObjekt> objekte = new List<KanalObjekt>();
|
||||
IUmsatzCalculator calculator = new XMLParser.Functions.UmsatzCalculator.TagesUmsatz();
|
||||
calculator.Calculate(csvWriter,objekte);
|
||||
|
||||
StrassenUmsatz(csvWriter,objekte);
|
||||
//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.CalculateStreet(objekte);
|
||||
|
||||
}
|
||||
|
||||
static void TagesUmsatz(CSVWriter csvWriter, List<KanalObjekt> objekte)
|
||||
{
|
||||
DirectoryInfo info = new DirectoryInfo("./");
|
||||
FileInfo[] daten = info.GetFiles("*.xml");
|
||||
foreach(FileInfo aktuell in daten) {
|
||||
XMLParse ser = new XMLParse(aktuell.FullName);
|
||||
objekte.AddRange(ser.KanalObjekte);
|
||||
}
|
||||
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) {
|
||||
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();
|
||||
}
|
||||
int anzahlTage = datums.Count();
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\XMLParser\XMLParser.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="input.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\XMLParser.Contract\XMLParser.Contract.csproj" />
|
||||
<ProjectReference Include="..\XMLParser.Model\XMLParser.Model.csproj" />
|
||||
<ProjectReference Include="..\XMLParser.Functions\XMLParser.Functions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
|
||||
Reference in New Issue
Block a user