353 lines
14 KiB
C#
353 lines
14 KiB
C#
using Database;
|
|
using KlassenBIB;
|
|
using SanShared;
|
|
using SanShared.Exceptions;
|
|
using SchnittstelleImporter;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using WupiEngine;
|
|
|
|
namespace SanSystem
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public partial class frmMain : Form
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public frmMain()
|
|
{
|
|
InitializeComponent();
|
|
#if !DEBUG
|
|
update.CheckForUpdates();
|
|
#endif
|
|
string sx = Properties.Settings.Default.DATABASEMAIN;
|
|
|
|
|
|
Datenbank.Instance.pfad = sx;
|
|
Datenbank.Instance.Init();
|
|
if (!Directory.Exists(Global.Instance.Projektpfad)) Directory.CreateDirectory(Global.Instance.Projektpfad);
|
|
try
|
|
{
|
|
Datenbank.Instance.LoadProjekt(Global.Instance.ProjektNummer);// Path.Combine(Global.Instance.Projektpfad,"18-850.xaml"));
|
|
}
|
|
catch(DataBaseVersionMismatchException ex)
|
|
{
|
|
frmExceptionWindow frmException = new frmExceptionWindow(ex.Message);
|
|
frmException.FormClosed += FrmException_FormClosed;
|
|
frmException.ShowDialog();
|
|
}
|
|
|
|
|
|
|
|
//Datenbank.Instance.CreateProjekt("");
|
|
this.Width = Screen.PrimaryScreen.WorkingArea.Width;
|
|
this.Height = Screen.PrimaryScreen.WorkingArea.Height;
|
|
this.WindowState = FormWindowState.Maximized;
|
|
this.StartPosition = FormStartPosition.Manual;
|
|
this.Location = new Point(0, 0);
|
|
|
|
projektToolStripMenuItem.Text = Global.Instance.language.Labels["mainmenu_projekt"];
|
|
neuToolStripMenuItem.Text = Global.Instance.language.Labels["mainmenu_projekt_new"];
|
|
öffnenToolStripMenuItem.Text = Global.Instance.language.Labels["mainmenu_projekt_open"];
|
|
|
|
toolStripStatus_projekt_Label.Text = Datenbank.Instance.projekt;
|
|
this.Text += " " + Global.Instance.PROGRAMMVERSION;
|
|
|
|
#if (DEBUG || LAPTOP)
|
|
this.Text += " INTERNE DEBUG VERSION";
|
|
#endif
|
|
//if (Wupi.QueryInfo(0, QueryInfoOption.FirmCode) == 0)
|
|
// this.Text += " nicht geschützter Version nur für TESTZWECKE!";
|
|
|
|
|
|
FrmLinerReste frmLinerReste = new FrmLinerReste();
|
|
frmLinerReste.MdiParent = this;
|
|
Point start = new Point(this.Width - frmLinerReste.Width - 22, 0);
|
|
frmLinerReste.Location = start;
|
|
|
|
//frmLinerReste.IsMdiChild = true;
|
|
frmLinerReste.Show();
|
|
|
|
|
|
// Insgesammt eingebaut
|
|
double gesamt = 0.0;
|
|
int anzahl = 0;
|
|
foreach(Projekt projekt in Database.Datenbank.Instance.TeufelDB.Projekte)
|
|
{
|
|
foreach(Inspektionsobjekt objekt in projekt.Objekte)
|
|
{
|
|
if (objekt.Sanierung.Exists(x => (x is InlinerSanierung)))
|
|
{
|
|
anzahl++;
|
|
gesamt += (objekt.Haltungslaenge + objekt.Schachtlaenge);
|
|
}
|
|
}
|
|
}
|
|
|
|
toolstrip_gesamtLiner.Text = "Insgesamt wurde laut Erfassung " + gesamt.ToString() + "m an Liner eingebaut ("+anzahl.ToString()+")";
|
|
|
|
|
|
}
|
|
|
|
private void FrmException_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
Environment.Exit(0);
|
|
}
|
|
|
|
private void frm_main_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
frmStrassenList strassenList = new frmStrassenList();
|
|
strassenList.MdiParent = this;
|
|
strassenList.Top = 0;
|
|
strassenList.Left = 0;
|
|
strassenList.Location = new Point(0, 0);
|
|
strassenList.StartPosition = FormStartPosition.Manual;
|
|
strassenList.Show();
|
|
}
|
|
|
|
private void frm_main_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
|
|
Datenbank.Instance.SaveProjekt();
|
|
}
|
|
|
|
private void neuToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
frmNewProjekt frmNewProjekt = new frmNewProjekt();
|
|
frmNewProjekt.FormClosed += FrmProjektList_FormClosed;
|
|
frmNewProjekt.ShowDialog();
|
|
}
|
|
|
|
private void öffnenToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
//
|
|
frmProjektList frmProjektList = new frmProjektList();
|
|
|
|
frmProjektList.FormClosed += FrmProjektList_FormClosed;
|
|
frmProjektList.ShowDialog();
|
|
}
|
|
|
|
private void FrmProjektList_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
toolStripStatus_projekt_Label.Text = Global.Instance.ProjektNummer;
|
|
Form[] openedWindows = this.MdiChildren;
|
|
foreach(Form form in openedWindows)
|
|
{
|
|
form.Close();
|
|
form.Dispose();
|
|
}
|
|
frmStrassenList strassenList = new frmStrassenList();
|
|
strassenList.MdiParent = this;
|
|
strassenList.Top = 0;
|
|
strassenList.Left = 0;
|
|
strassenList.Location = new Point(0, 0);
|
|
strassenList.StartPosition = FormStartPosition.Manual;
|
|
strassenList.Show();
|
|
|
|
FrmLinerReste frmLinerReste = new FrmLinerReste();
|
|
frmLinerReste.MdiParent = this;
|
|
Point start = new Point(this.Width - frmLinerReste.Width - 22, 0);
|
|
frmLinerReste.Location = start;
|
|
|
|
//frmLinerReste.IsMdiChild = true;
|
|
frmLinerReste.Show();
|
|
}
|
|
|
|
private void speichernToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
Datenbank.Instance.SaveProjekt();
|
|
}
|
|
|
|
private void massenstatistikToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
frmSelectMassenDate frmSelectMassenDate = new frmSelectMassenDate();
|
|
frmSelectMassenDate.ShowDialog();
|
|
}
|
|
|
|
private void stammdatenImportierenToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
openFileDialog.Filter = "XML Daten | *.xml";
|
|
if(Datenbank.Instance.loadedProjekt == null)
|
|
{
|
|
MessageBox.Show("Diese Projekt ist nicht Initialisiert");
|
|
return;
|
|
}
|
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
{
|
|
string path = openFileDialog.FileName;
|
|
|
|
IImportedObjekte importedObjekte = SchnittstelleImporter.ImportBuilder.Import(ImportSchnittstellen.XML2006);
|
|
importedObjekte.XMLFile = path;//@"C:\Users\Damian\Desktop\XML\3_Zustandsdaten\ISYBAU_XML-2006-Zustandsdaten_DIN_EN_13508-2.xml";
|
|
importedObjekte.Projektnummer = Global.Instance.ProjektNummer;
|
|
Datenbank.Instance.loadedProjekt.Objekte.AddRange(importedObjekte.GetInspektionsobjekte());
|
|
|
|
Form[] openedWindows = this.MdiChildren;
|
|
foreach (Form form in openedWindows)
|
|
{
|
|
form.Close();
|
|
form.Dispose();
|
|
}
|
|
frmStrassenList strassenList = new frmStrassenList();
|
|
strassenList.MdiParent = this;
|
|
strassenList.Top = 0;
|
|
strassenList.Left = 0;
|
|
strassenList.Location = new Point(0, 0);
|
|
strassenList.StartPosition = FormStartPosition.Manual;
|
|
strassenList.Show();
|
|
}
|
|
}
|
|
|
|
private void auftraggeberToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
if(Datenbank.Instance.loadedProjekt.Auftraggeber == null)
|
|
{
|
|
Auftraggeber auftraggeber = new Auftraggeber();
|
|
Datenbank.Instance.TeufelDB.Auftraggeber.Add(auftraggeber);
|
|
Datenbank.Instance.loadedProjekt.Auftraggeber = auftraggeber;
|
|
|
|
}
|
|
frmAuftraggeberEdit frmAuftraggeberEdit = new frmAuftraggeberEdit(Datenbank.Instance.loadedProjekt.Auftraggeber);
|
|
frmAuftraggeberEdit.ShowDialog();
|
|
}
|
|
|
|
private void ProjektordnerÖffnenToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
Process prozess = new Process();
|
|
prozess.StartInfo.FileName = "explorer";
|
|
try
|
|
{
|
|
prozess.StartInfo.Arguments = Path.Combine(Environment.CurrentDirectory, Global.Instance.Projektpfad);
|
|
prozess.Start();
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
MessageBox.Show("Es ist ein fehler aufgetreten beim öffnen vom Baustellenordner " + ex.Message);
|
|
}
|
|
}
|
|
|
|
private void ImprägnierberichteToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
frmImprägnierBerichtList frmImprägnierBerichtList = new frmImprägnierBerichtList();
|
|
frmImprägnierBerichtList.ShowDialog();
|
|
}
|
|
|
|
private void MassenberichteToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
List<InlinerSanierung> ausdruck = new List<InlinerSanierung>();
|
|
List<BilderObject> bilder = new List<BilderObject>();
|
|
foreach(Inspektionsobjekt objekte in Database.Datenbank.Instance.loadedProjekt.Objekte)
|
|
{
|
|
if (bilder.Count > 0) bilder.Clear();
|
|
foreach(AbstractSanieren san in objekte.Sanierung)
|
|
{
|
|
if(san is InlinerSanierung)
|
|
{
|
|
ausdruck.Add((InlinerSanierung)san);
|
|
}
|
|
/*
|
|
else if(san is SchachtAnbindung)
|
|
{
|
|
foreach(SavedBilder bild in (san as SchachtAnbindung).SavedBilders)
|
|
{
|
|
string komment = String.Empty;
|
|
if ((san as SchachtAnbindung).SchachtNummer != null)
|
|
{
|
|
komment = string.Format("{0} von Schacht: {1}", bild.Bildname, (san as SchachtAnbindung).SchachtNummer);
|
|
}
|
|
bilder.Add(new BilderObject()
|
|
{
|
|
Path = bild.Speicherpfad,
|
|
|
|
Kommentar = komment
|
|
});
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
}
|
|
|
|
foreach(InlinerSanierung san in ausdruck)
|
|
{
|
|
bilder.Clear();
|
|
foreach (Sanierung d in san.Inspektionsobjekt.Sanierung)
|
|
{
|
|
if (d is SchachtAnbindung)
|
|
{
|
|
foreach(SavedBilder c in (d as SchachtAnbindung).SavedBilders)
|
|
{
|
|
string komment = String.Empty;
|
|
if ((d as SchachtAnbindung).SchachtNummer != null)
|
|
{
|
|
komment = string.Format("{0} von Schacht: {1}", c.Bildname, (d as SchachtAnbindung).SchachtNummer);
|
|
}
|
|
bilder.Add(new BilderObject()
|
|
{
|
|
Path = c.Speicherpfad,
|
|
Kommentar = komment
|
|
});
|
|
|
|
}
|
|
}
|
|
}
|
|
string destinationPath = san.CheckVerzeichnisse(Global.Instance.Projektpfad);
|
|
Hashtable hashtable = san.MakeProtokoll(destinationPath, Database.Datenbank.Instance.loadedProjekt, DateTime.MinValue);
|
|
DirectoryInfo directory = Directory.GetParent(destinationPath);
|
|
string speicherpfad = Path.Combine(directory.FullName,"Einbauprotokolle");
|
|
BerichtGen.FrmOptions options = new BerichtGen.FrmOptions("JUME", "liner_einbauBlueLight.docx", speicherpfad, san.Inspektionsobjekt.Objektbezeichnung, hashtable, bilder,null,true);
|
|
|
|
}
|
|
//options.ShowDialog();
|
|
MessageBox.Show("Fertig");
|
|
}
|
|
|
|
private void VerbrauchToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
/*FrmGetDataFromBluelight frmGetDataFromBluelight = new FrmGetDataFromBluelight();
|
|
frmGetDataFromBluelight.ShowDialog();*/
|
|
Dictionary<string,List<string>> daten = KlassenBIB.LinerChargen.GenLinerChargenOverview(Datenbank.Instance.TeufelDB.Projekte);
|
|
List<string> content = new List<string>();
|
|
foreach (KeyValuePair<string, List<string>> x in daten)
|
|
{
|
|
content.Add(x.Key);
|
|
|
|
content.Add("================");
|
|
foreach(string values in x.Value)
|
|
{
|
|
content.Add(values);
|
|
}
|
|
content.Add("##############");
|
|
}
|
|
|
|
string[] datencontent = new string[content.Count];
|
|
for(int i = 0; i < content.Count; i++)
|
|
{
|
|
datencontent[i] = content[i];
|
|
}
|
|
|
|
File.WriteAllLines("linercharges.txt", datencontent);
|
|
|
|
}
|
|
|
|
private void PrefixSuffixToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
FrmPrefixSuffix frmPrefixSuffix = new FrmPrefixSuffix();
|
|
frmPrefixSuffix.ShowDialog();
|
|
}
|
|
}
|
|
}
|