Protokollwriter weitergeführt
Lässt sich noch nicht bauen!
This commit is contained in:
108
ProtokollWriter/SBTextFileWriter.cs
Normal file
108
ProtokollWriter/SBTextFileWriter.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Models;
|
||||
using ProtokollWriterContract;
|
||||
|
||||
namespace ProtokollWriter {
|
||||
/// Erstellt eine Städtler und Beck Dichtheitsprüfdatei
|
||||
public class SBTextFileWriter : IProtokollWriter
|
||||
{
|
||||
string[] content;
|
||||
ArrayList newFile = new ArrayList();
|
||||
string targetFile;
|
||||
|
||||
Hashtable hashtable = new Hashtable() {
|
||||
{"DATUM",""},
|
||||
{"PROJEKTNR","" },
|
||||
{"PRUEFNR","" },
|
||||
{"AUFTRAGGEBER_NAME","" },
|
||||
{"AUFTRAGGEBER_STRASSE","" },
|
||||
{"AUFTRAGGEBER_ORT","" },
|
||||
{"AUFTRAGGEBER_TEL","" },
|
||||
{"BAUVORHABEN_STRASSE","" },
|
||||
{"BAUVORHABEN_ORT","" },
|
||||
{"BAUVORHABEN_STANDORT","" },
|
||||
{"MESSDATEI","" },
|
||||
{"DN","" },
|
||||
{"LAENGE","" },
|
||||
{"VOLUMEN","" },
|
||||
{"HALTUNGNR","" },
|
||||
{"VONSCHACHT","" },
|
||||
{"BISSCHACHT","" },
|
||||
{"PRUEFRESULTAT","" },
|
||||
{"BEMERKUNG","" }
|
||||
};
|
||||
|
||||
Inspektionsobjekt inspObjekt;
|
||||
public void WriteProtokoll(Inspektionsobjekt inspektionsobjekt)
|
||||
{
|
||||
inspObjekt = inspektionsobjekt;
|
||||
}
|
||||
|
||||
void ReadVorlage() {
|
||||
content = File.ReadAllLines("./vorlage.txt",Encoding.Default);
|
||||
|
||||
}
|
||||
void Ersetzen() {
|
||||
hashtable["DATUM"] = prüfdatum;
|
||||
hashtable["PRUEFNR"] = getPrüfnummer();
|
||||
hashtable["DN"] = inspObjekt.Durchmesser;
|
||||
hashtable["LAENGE"] = inspObjekt.ObjektLänge;
|
||||
hashtable["VOLUMEN"] = PruefVolumen();
|
||||
hashtable["AUFTRAGGEBER_NAME"] = inspObjekt.Bauvorhaben.Auftraggeber.Name;
|
||||
hashtable["AUFTRAGGEBER_STRASSE"] = inspObjekt.Bauvorhaben.Auftraggeber.Strasse;
|
||||
hashtable["AUFTRAGGEBER_ORT"] = inspObjekt.Bauvorhaben.Auftraggeber.Ort;
|
||||
hashtable["AUFTRAGGEBER_TEL"] = inspObjekt.Bauvorhaben.Auftraggeber.Tel;
|
||||
hashtable["VONSCHACHT"] = inspObjekt.ObereSchacht;
|
||||
hashtable["BISSCHACHT"] = inspObjekt.UntereSchacht;
|
||||
hashtable["PROJEKTNR"] = Projektnummer;
|
||||
hashtable["HALTUNGNR"] = inspObjekt.Objektname != null ? inspObjekt.Objektname : inspObjekt.ObereSchacht;
|
||||
hashtable["MESSDATEI"] = inspObjekt.Objektname != null ? inspObjekt.Objektname : inspObjekt.ObereSchacht;
|
||||
hashtable["BAUVORHABEN_STRASSE"] = inspObjekt.Bauvorhaben.Strasse;
|
||||
hashtable["BAUVORHABEN_ORT"] = inspObjekt.Bauvorhaben.Ort;
|
||||
hashtable["BAUVORHABEN_STANDORT"] = inspObjekt.Bauvorhaben.Strasse;
|
||||
hashtable["BEMERKUNG"] = inspObjekt.Bemerkung;
|
||||
hashtable["PRUEFRESULTAT"] = Bestanden ? "Prüfung Bestanden" : "Prüfung N I C H T Bestanden";
|
||||
}
|
||||
void WriteFile() {
|
||||
string zeile;
|
||||
for(int i = 0; i < content.Length; i++) {
|
||||
zeile = content[i];
|
||||
if(zeile.Contains("{")) {
|
||||
int start = zeile.IndexOf("{");
|
||||
int ende = zeile.IndexOf("}");
|
||||
string cmd = zeile.Substring(start+1,(ende-start) -1);
|
||||
|
||||
if(hashtable.ContainsKey(cmd)) {
|
||||
string rep = "{"+cmd+"}";
|
||||
string n = zeile.Replace(rep,hashtable[cmd].ToString());
|
||||
zeile = n;
|
||||
} else {
|
||||
if(cmd.StartsWith("@")) {
|
||||
string n = "";
|
||||
foreach(MeasureData data in inspObjekt.PressureTests[0].Measuredatas) {
|
||||
n = string.Format("{0}{1}\r\n",n,data.ToString());
|
||||
}
|
||||
zeile = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
newFile.Add(zeile);
|
||||
}
|
||||
File.WriteAllLines(targetFile,FileConverter(newFile),Encoding.Default);
|
||||
}
|
||||
string[] FileConverter(ArrayList content) {
|
||||
string[] result = new string[content.Count];
|
||||
int counter = 0;
|
||||
foreach(var x in content) {
|
||||
string c = (string)x;
|
||||
result[counter] = c;
|
||||
counter++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user