Massenstatistik wird erstellt
This commit is contained in:
196
SanSystem/MassenStatistik.cs
Normal file
196
SanSystem/MassenStatistik.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
using Database;
|
||||
using KlassenBIB;
|
||||
using SanShared;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SanSystem
|
||||
{
|
||||
class MassenStatistik : IMakeProtokol
|
||||
{
|
||||
List<Inspektionsobjekt> inspektionsobjekts = null;
|
||||
|
||||
DateTime targetDatum;
|
||||
public MassenStatistik(List<Inspektionsobjekt> inspektionsobjekts, DateTime datum)
|
||||
{
|
||||
this.inspektionsobjekts = inspektionsobjekts;
|
||||
targetDatum = datum;
|
||||
|
||||
|
||||
BuildBericht(SearchForWaranties());
|
||||
}
|
||||
|
||||
void BuildBericht(List<Inspektionsobjekt> list)
|
||||
{
|
||||
Hashtable grundDaten = MakeProtokoll("");
|
||||
|
||||
DataTable inliner = getMassenTableInliner();
|
||||
|
||||
double gesamtLiner = 0;
|
||||
double gesamtHarz = 0;
|
||||
foreach (Inspektionsobjekt objekt in list)
|
||||
{
|
||||
DataRow dr = inliner.NewRow();
|
||||
dr["hausnummer"] = objekt.Hausnummer;
|
||||
Trace.WriteLine(objekt.Hausnummer);
|
||||
if (objekt.Hausnummer.Equals("17a"))
|
||||
Debugger.Break();
|
||||
if(objekt.HaltungGemessen.Day == targetDatum.Day &&
|
||||
objekt.HaltungGemessen.Month == targetDatum.Month &&
|
||||
objekt.HaltungGemessen.Year == targetDatum.Year)
|
||||
{
|
||||
dr["vorbereitet"] = "ja";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dr["vorbereitet"] = "nein wurde am " + objekt.HaltungGemessen.ToShortDateString();
|
||||
}
|
||||
int schachtanbindungen = 0;
|
||||
foreach (Sanieren mainsan in objekt.Sanierung)
|
||||
{
|
||||
if (
|
||||
mainsan.Datum.Day == targetDatum.Day &&
|
||||
mainsan.Datum.Month == targetDatum.Month &&
|
||||
mainsan.Datum.Year == targetDatum.Year)
|
||||
{
|
||||
|
||||
if (mainsan is InlinerSanierung)
|
||||
{
|
||||
double linerLang = objekt.Haltungslaenge + objekt.Schachtlaenge + 0.5;
|
||||
gesamtLiner += linerLang;
|
||||
dr["liner_laenge"] = linerLang;
|
||||
dr["kalibrierschlauch"] = objekt.Haltungslaenge + (objekt.Schachtlaenge * 2) + 0.3;
|
||||
dr["preliner"] = linerLang - 0.5;
|
||||
dr["harzmenge"] = linerLang * (mainsan as InlinerSanierung).HarzBedarf;
|
||||
gesamtHarz += linerLang * (mainsan as InlinerSanierung).Harzbedarf;
|
||||
}
|
||||
if (mainsan is SchachtAnbindung)
|
||||
{
|
||||
schachtanbindungen++;
|
||||
}
|
||||
dr["schachtanbindung"] = schachtanbindungen;
|
||||
}
|
||||
}
|
||||
inliner.Rows.Add(dr);
|
||||
}
|
||||
|
||||
grundDaten["gesamtHarz"] = gesamtHarz;
|
||||
grundDaten["gesamtliner"] = gesamtLiner;
|
||||
grundDaten["Ausdruck_datum"] = targetDatum.ToLongDateString();
|
||||
grundDaten["Ort"] = inspektionsobjekts.Last().OrtName;
|
||||
grundDaten["Strasse"] = inspektionsobjekts.Last().StrasseName;
|
||||
grundDaten["Projektnummer"] = Datenbank.Instance.loadedProjekt.Nummer;
|
||||
BerichtGen.FrmOptions frmOptions = new BerichtGen.FrmOptions("JUME", "Massenstatistik.docx", ".", "Massenstatistik", grundDaten, null, inliner);
|
||||
frmOptions.ShowDialog();
|
||||
}
|
||||
|
||||
public Hashtable MakeProtokoll(string destinationPath)
|
||||
{
|
||||
Hashtable grundDaten = new Hashtable()
|
||||
{
|
||||
{"Ausdruck_datum","" },
|
||||
{"Strasse","" },
|
||||
{"Ort","" },
|
||||
{"Projektnummer","" },
|
||||
{"gesamtliner","" },
|
||||
{"gesamtHarz","" }
|
||||
};
|
||||
return grundDaten;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DataTable getMassenTableInliner()
|
||||
{
|
||||
DataTable dt = new DataTable("Liner");
|
||||
DataColumn column = new DataColumn("hausnummer")
|
||||
{
|
||||
MaxLength = 50
|
||||
};
|
||||
dt.Columns.Add(column);
|
||||
|
||||
column = new DataColumn("liner_laenge")
|
||||
{
|
||||
MaxLength = 50
|
||||
};
|
||||
dt.Columns.Add(column);
|
||||
|
||||
column = new DataColumn("kalibrierschlauch")
|
||||
{
|
||||
MaxLength = 50
|
||||
};
|
||||
dt.Columns.Add(column);
|
||||
|
||||
column = new DataColumn("preliner")
|
||||
{
|
||||
MaxLength = 50
|
||||
};
|
||||
dt.Columns.Add(column);
|
||||
|
||||
column = new DataColumn("harzmenge")
|
||||
{
|
||||
MaxLength = 50
|
||||
};
|
||||
dt.Columns.Add(column);
|
||||
|
||||
column = new DataColumn("vorbereitet")
|
||||
{
|
||||
MaxLength = 50
|
||||
};
|
||||
dt.Columns.Add(column);
|
||||
|
||||
|
||||
column = new DataColumn("schachtanbindung")
|
||||
{
|
||||
MaxLength = 50
|
||||
};
|
||||
dt.Columns.Add(column);
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
List<Inspektionsobjekt> SearchForWaranties()
|
||||
{
|
||||
if (inspektionsobjekts == null) return null ;
|
||||
|
||||
List<Inspektionsobjekt> result = new List<Inspektionsobjekt>();
|
||||
foreach(Inspektionsobjekt objekt in inspektionsobjekts)
|
||||
{
|
||||
bool add = false;
|
||||
if (
|
||||
objekt.HaltungGemessen.Year == targetDatum.Year &&
|
||||
objekt.HaltungGemessen.Month == targetDatum.Month &&
|
||||
objekt.HaltungGemessen.Day == targetDatum.Day
|
||||
)
|
||||
{
|
||||
add = true;
|
||||
}
|
||||
|
||||
foreach(Sanieren san in objekt.Sanierung)
|
||||
{
|
||||
if (san.Fertig &&
|
||||
|
||||
san.Datum.Day == targetDatum.Day &&
|
||||
san.Datum.Month == targetDatum.Month &&
|
||||
san.Datum.Year == targetDatum.Year
|
||||
)
|
||||
add = true;
|
||||
}
|
||||
|
||||
if (add)
|
||||
result.Add(objekt);
|
||||
|
||||
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user