diff --git a/Schnittstelle b/Schnittstelle index 2e6217a..ce1ca01 160000 --- a/Schnittstelle +++ b/Schnittstelle @@ -1 +1 @@ -Subproject commit 2e6217aea4ed882b3e3403267c33339d06771966 +Subproject commit ce1ca0128759dde4847b820887537728b9858348 diff --git a/dcnsanplanung.DAL/Helper/WriteToDatabase.cs b/dcnsanplanung.DAL/Helper/WriteToDatabase.cs new file mode 100644 index 0000000..0b5a75f --- /dev/null +++ b/dcnsanplanung.DAL/Helper/WriteToDatabase.cs @@ -0,0 +1,39 @@ +using dcnsanplanung.DAL.Services.PostgresqlData; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.DAL.Helper +{ + public class WriteToDatabase + { + List haltungen = new List(); + List LVPositionen = new List(); + public WriteToDatabase(string XMLFile, string connectionstring = "Host = localhost; Database = sanplaner; Username = dcnsanplaner; Password = sanplaner") + { + haltungen = new shared.Helper.ImportToSoftware(XMLFile).haltungen; + LVPositionen = new shared.Helper.ImportLVToSoftware(@"C:\Users\damia\source\repos\dcnsanplanung\BE-BS-AWN DW_0001_OOWV_Stamm_LV_Kanalsanierung_xml33.X81").LVPositionen; + + + } + + public async Task WriteInHaltung() + { + string connectionstring = "Host = localhost; Database = sanplaner; Username = dcnsanplaner; Password = sanplaner"; + HaltungDataService haltungDataService = new HaltungDataService(connectionstring); + await haltungDataService.InsertHaltungBulk(haltungen); + return true; + } + + public async Task WriteInLV() + { + string connectionstring = "Host = localhost; Database = sanplaner; Username = dcnsanplaner; Password = sanplaner"; + LVDataService lVDataService = new LVDataService(connectionstring); + await lVDataService.InsertLeistungsverzeichnisPositionBulk(LVPositionen); + return true; + } + + } +} diff --git a/dcnsanplanung.DAL/Services/PostgresqlData/HaltungDataService.cs b/dcnsanplanung.DAL/Services/PostgresqlData/HaltungDataService.cs new file mode 100644 index 0000000..48362b2 --- /dev/null +++ b/dcnsanplanung.DAL/Services/PostgresqlData/HaltungDataService.cs @@ -0,0 +1,87 @@ +using dcnsanplanung.shared.Model; +using Npgsql; +using Schnittstelle.Import.XML.v2013.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.DAL.Services.PostgresqlData +{ + public class HaltungDataService : PostgresqlDataService + { + SchadenDataService schadenDataService; + public HaltungDataService(string connectionstring) : base(connectionstring, "haltung") + { + schadenDataService = new SchadenDataService(connectionstring); + } + + public async Task Create(Haltung entity) + { + string command = "INSERT INTO " + tableName + " (guid, ref_projekt_guid, objektbezeichnung, bewertungklasse) VALUES " + + "(@1,@2,@3,@4) RETURNING id"; + using (var cmd = new NpgsqlCommand(command, conn)) + { + cmd.Parameters.AddWithValue("1", entity.Guid.ToString()); + cmd.Parameters.AddWithValue("2", entity.Ref_Projekt_Guid.ToString()); + cmd.Parameters.AddWithValue("3", entity.Objektbezeichnung); + cmd.Parameters.AddWithValue("4", NpgsqlTypes.NpgsqlDbType.Oid, entity.Bewertungklasse); + + using var reader = await cmd.ExecuteReaderAsync(); + reader.Read(); + entity.ID = reader.GetInt32(0); + } + await schadenDataService.InsertSchadenBulk(entity.Kodierungen); + return entity; + } + + public async Task> GetAllByProjekt(int projektID) + { + List result = new List(); + //ISchachtDataService schachtDataService = new SchachtDataService(connString); + //IEnumerable schaechte = await schachtDataService.GetAllByProjekt(projektID); + + string command = "SELECT * FROM " + tableName + ";";//" WHERE ref_projekt_id = @1"; + using (var cmd = new NpgsqlCommand(command, conn)) + { + //cmd.Parameters.AddWithValue("1", projektID); + using (var reader = await cmd.ExecuteReaderAsync()) + { + while (reader.Read()) + { + Haltung adding = parseHaltung(reader); + + result.Add(adding); + } + } + } + return result; + } + + private Haltung parseHaltung(NpgsqlDataReader reader) + { + Haltung result = new Haltung() + { + ID = reader.GetInt32(0), + Guid = Guid.Parse(reader.GetString(1)), + Ref_Projekt_Guid = Guid.Parse(reader.GetString(2)), + Objektbezeichnung = reader.GetString(3), + + Bewertungklasse = Convert.ToUInt32(reader.GetValue(4)), + }; + + return result; + } + + + public async Task InsertHaltungBulk(List haltungen) + { + foreach (var item in haltungen) + { + await Create(item); + } + return true; + } + } +} diff --git a/dcnsanplanung.DAL/Services/PostgresqlData/LVDataService.cs b/dcnsanplanung.DAL/Services/PostgresqlData/LVDataService.cs new file mode 100644 index 0000000..3001699 --- /dev/null +++ b/dcnsanplanung.DAL/Services/PostgresqlData/LVDataService.cs @@ -0,0 +1,75 @@ +using dcnsanplanung.shared.Model; +using Npgsql; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.DAL.Services.PostgresqlData +{ + public class LVDataService : PostgresqlDataService + { + public LVDataService(string connectionstring) : base(connectionstring, "leistungsverzeichnisposition") + { + } + + public async Task Create(LeistungsverzeichnisPosition entity) + { + string command = "INSERT INTO " + tableName + " (guid, positionsnummer, titel, einheit) VALUES " + + "(@1,@2,@3,@4) RETURNING id"; + using (var cmd = new NpgsqlCommand(command, conn)) + { + cmd.Parameters.AddWithValue("1", entity.Guid.ToString()); + cmd.Parameters.AddWithValue("2", entity.Positionsnummer); + cmd.Parameters.AddWithValue("3", entity.Titel); + cmd.Parameters.AddWithValue("4", entity.Einheit); + using var reader = await cmd.ExecuteReaderAsync(); + reader.Read(); + entity.ID = reader.GetInt32(0); + } + return entity; + } + + public async Task> GetAll() + { + List result = new List(); + string command = "SELECT * FROM " + tableName + ";"; + using (var cmd = new NpgsqlCommand(command, conn)) + { + using (var reader = await cmd.ExecuteReaderAsync()) + { + while (reader.Read()) + { + LeistungsverzeichnisPosition adding = parsePosition(reader); + + result.Add(adding); + } + } + } + return result; + } + + private LeistungsverzeichnisPosition parsePosition(NpgsqlDataReader reader) + { + LeistungsverzeichnisPosition result = new LeistungsverzeichnisPosition() + { + ID = reader.GetInt32(0), + Guid = Guid.Parse(reader.GetString(1)), + Positionsnummer = reader.GetString(2), + Titel = reader.GetString(3), + Einheit = reader.GetString(4) + }; + return result; + } + + public async Task InsertLeistungsverzeichnisPositionBulk(List position) + { + foreach (var item in position) + { + await Create(item); + } + return true; + } + } +} diff --git a/dcnsanplanung.DAL/Services/PostgresqlData/PostgresqlDataService.cs b/dcnsanplanung.DAL/Services/PostgresqlData/PostgresqlDataService.cs new file mode 100644 index 0000000..f9915fa --- /dev/null +++ b/dcnsanplanung.DAL/Services/PostgresqlData/PostgresqlDataService.cs @@ -0,0 +1,47 @@ +using Npgsql; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.DAL.Services.PostgresqlData +{ + public class PostgresqlDataService : IDisposable + { + protected readonly string connString; // = "Host = localhost; Database = sanplaner; Username = dcnsanplaner; Password = sanplaner"; + NpgsqlDataSource dataSource; + protected NpgsqlConnection? conn = null; + protected string tableName = ""; + + public PostgresqlDataService(string connectionstring, string tableName) + { + this.connString = connectionstring; + var dataSourceBuilder = new NpgsqlDataSourceBuilder(connString); + dataSource = dataSourceBuilder.Build(); + + conn = dataSource.OpenConnection(); + this.tableName = string.Format("public.{0}", tableName); + + } + public virtual async Task Delete(int id) + { + string command = $"DELETE " + tableName + " WHERE \"Id\" = @1"; + await using (var cmd = new NpgsqlCommand(command, conn)) + { + cmd.Parameters.AddWithValue("1", id); + int res = await cmd.ExecuteNonQueryAsync(); + } + return true; + } + public void Dispose() + { + if (conn != null && conn.State == System.Data.ConnectionState.Open) + { + conn.Close(); + conn.Dispose(); + } + } + + } +} diff --git a/dcnsanplanung.DAL/Services/PostgresqlData/SchadenDataService.cs b/dcnsanplanung.DAL/Services/PostgresqlData/SchadenDataService.cs new file mode 100644 index 0000000..ee06c3e --- /dev/null +++ b/dcnsanplanung.DAL/Services/PostgresqlData/SchadenDataService.cs @@ -0,0 +1,44 @@ +using dcnsanplanung.shared.Model; +using Npgsql; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.DAL.Services.PostgresqlData +{ + public class SchadenDataService : PostgresqlDataService + { + public SchadenDataService(string connectionstring) : base(connectionstring, "schaden") + { + } + + public async Task Create(Schaden entity) + { + string command = "INSERT INTO " + tableName + " (guid, ref_haltung_guid, entfernung, kodierung, schadensklasse) VALUES " + + "(@1,@2,@3,@4,@5) RETURNING id"; + using(var cmd = new NpgsqlCommand(command,conn)) + { + cmd.Parameters.AddWithValue("1", entity.Guid.ToString()); + cmd.Parameters.AddWithValue("2", entity.Ref_Haltung_Guid.ToString()); + cmd.Parameters.AddWithValue("3", entity.Entfernung); + cmd.Parameters.AddWithValue("4", entity.Kodierung); + cmd.Parameters.AddWithValue("5", NpgsqlTypes.NpgsqlDbType.Oid, entity.Schadensklasse); + using var reader = await cmd.ExecuteReaderAsync(); + reader.Read(); + entity.ID = reader.GetInt32(0); + } + return entity; + } + + public async Task InsertSchadenBulk(List schaden) + { + foreach(var item in schaden) + { + await Create(item); + } + return true; + } + } +} diff --git a/dcnsanplanung.DAL/dcnsanplanung.DAL.csproj b/dcnsanplanung.DAL/dcnsanplanung.DAL.csproj new file mode 100644 index 0000000..0633d1e --- /dev/null +++ b/dcnsanplanung.DAL/dcnsanplanung.DAL.csproj @@ -0,0 +1,18 @@ + + + + net7.0 + enable + enable + + + + + + + + + + + + diff --git a/dcnsanplanung.DALTests/Helper/WriteToDatabaseTests.cs b/dcnsanplanung.DALTests/Helper/WriteToDatabaseTests.cs new file mode 100644 index 0000000..2adb182 --- /dev/null +++ b/dcnsanplanung.DALTests/Helper/WriteToDatabaseTests.cs @@ -0,0 +1,20 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using dcnsanplanung.DAL.Helper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.DAL.Helper.Tests +{ + [TestClass()] + public class WriteToDatabaseTests + { + [TestMethod()] + public void WriteToDatabaseTest() + { + WriteToDatabase writeToDatabase = new WriteToDatabase(@"C:\Users\damia\source\repos\dcnsanplanung\test_code.xml"); + } + } +} \ No newline at end of file diff --git a/dcnsanplanung.DALTests/dcnsanplanung.DALTests.csproj b/dcnsanplanung.DALTests/dcnsanplanung.DALTests.csproj new file mode 100644 index 0000000..0b489a6 --- /dev/null +++ b/dcnsanplanung.DALTests/dcnsanplanung.DALTests.csproj @@ -0,0 +1,23 @@ + + + + net7.0 + enable + enable + + false + true + + + + + + + + + + + + + + diff --git a/dcnsanplanung.shared/Helper/ImportLVToSoftware.cs b/dcnsanplanung.shared/Helper/ImportLVToSoftware.cs new file mode 100644 index 0000000..ff68a44 --- /dev/null +++ b/dcnsanplanung.shared/Helper/ImportLVToSoftware.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.shared.Helper +{ + public class ImportLVToSoftware + { + public List LVPositionen = new List(); + + public ImportLVToSoftware(string XMLFile) + { + ReadSchnittstelle(XMLFile); + } + + private void ReadSchnittstelle(string xMLFile) + { + foreach(Schnittstelle.Import.LV.Model.LVPosition src_lv in new Schnittstelle.Import.LV.X81(xMLFile).ExportedLVPosition) + { + LVPositionen.Add(new Model.LeistungsverzeichnisPosition() + { + Guid = Guid.NewGuid(), + Einheit = src_lv.Einheit, + Titel = src_lv.Title, + Positionsnummer = src_lv.Positionsnummer, + }); + } + } + } +} diff --git a/dcnsanplanung.shared/Helper/ImportToSoftware.cs b/dcnsanplanung.shared/Helper/ImportToSoftware.cs new file mode 100644 index 0000000..97f3a16 --- /dev/null +++ b/dcnsanplanung.shared/Helper/ImportToSoftware.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.shared.Helper +{ + public class ImportToSoftware + { + public List haltungen = new List(); + public ImportToSoftware(string XMLFile) + { + ReadSchnittstelle(XMLFile); + } + + private void ReadSchnittstelle(string XMLFile) + { + List source_KanalObjekt = new Schnittstelle.Import.XML.v2013.XML2013(XMLFile).KanalObjekte.FindAll(x => x.Inspektionsdaten.Anlagentyp == Schnittstelle.Import.XML.v2013.Model.EAnlagetyp.Haltung); + + //List haltungen = new List(); + foreach (Schnittstelle.Import.XML.v2013.Model.KanalObjekt src in source_KanalObjekt) + { + Model.Haltung haltung = new Model.Haltung(); + haltung.Guid = Guid.NewGuid(); + haltung.Objektbezeichnung = src.Stammdaten.Objektbezeichnung; + haltung.Bewertungklasse = src.Inspektionsdaten.OptischeInspektion.Rohrleitung.Bewertung == null ? 6 : src.Inspektionsdaten.OptischeInspektion.Rohrleitung.Bewertung.KlasseAutomatisch; + + List kodierungen = new List(); + foreach (Schnittstelle.Import.XML.v2013.Model.RZustand src_kodierung in src.Inspektionsdaten.OptischeInspektion.Rohrleitung.Zustaende) + { + Model.Schaden kodierung = new Model.Schaden(); + kodierung.Guid = Guid.NewGuid(); + kodierung.Ref_Haltung_Guid = haltung.Guid; + kodierung.Entfernung = src_kodierung.Station; + kodierung.Kodierung = string.Format("{0}#{1}#{2}#{3}", src_kodierung.Inspektionskode ,src_kodierung.Charakterisierung1 , src_kodierung.Charakterisierung2 , src_kodierung.Quantifizierung1); + kodierung.Schadensklasse = src_kodierung.Klassifizierung == null ? 6 : src_kodierung.Klassifizierung.MaxSKeAuto; + kodierungen.Add(kodierung); + } + haltung.Kodierungen = kodierungen; + + haltungen.Add(haltung); + } + } + } +} diff --git a/dcnsanplanung.shared/Model/DBObjekt.cs b/dcnsanplanung.shared/Model/DBObjekt.cs new file mode 100644 index 0000000..f44a86f --- /dev/null +++ b/dcnsanplanung.shared/Model/DBObjekt.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.shared.Model +{ + public class DBObjekt + { + public int ID { get; set; } + public Guid Guid { get; set; } + } +} diff --git a/dcnsanplanung.shared/Model/Haltung.cs b/dcnsanplanung.shared/Model/Haltung.cs new file mode 100644 index 0000000..40de692 --- /dev/null +++ b/dcnsanplanung.shared/Model/Haltung.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.shared.Model +{ + public class Haltung : DBObjekt + { + public Guid Ref_Projekt_Guid; + public string Objektbezeichnung { get; set; } = ""; + public uint Bewertungklasse { get; set; } + public List Kodierungen = new List(); + } + + public class Schaden : DBObjekt + { + public Guid Ref_Haltung_Guid; + public decimal Entfernung; + public string Kodierung = ""; + public uint Schadensklasse; + } +} diff --git a/dcnsanplanung.shared/Model/LeistungsverzeichnisPosition.cs b/dcnsanplanung.shared/Model/LeistungsverzeichnisPosition.cs new file mode 100644 index 0000000..133e95e --- /dev/null +++ b/dcnsanplanung.shared/Model/LeistungsverzeichnisPosition.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.shared.Model +{ + public class LeistungsverzeichnisPosition : DBObjekt + { + public string Positionsnummer { get; set; } = ""; + public string Titel { get; set; } = ""; + public string Einheit { get; set; } = ""; + } +} diff --git a/dcnsanplanung.shared/Model/Projekt.cs b/dcnsanplanung.shared/Model/Projekt.cs new file mode 100644 index 0000000..a022b5d --- /dev/null +++ b/dcnsanplanung.shared/Model/Projekt.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.shared.Model +{ + public class Projekt : DBObjekt + { + public List Haltungen = new List(); + } +} diff --git a/dcnsanplanung.shared/dcnsanplanung.shared.csproj b/dcnsanplanung.shared/dcnsanplanung.shared.csproj index cfadb03..dbe8733 100644 --- a/dcnsanplanung.shared/dcnsanplanung.shared.csproj +++ b/dcnsanplanung.shared/dcnsanplanung.shared.csproj @@ -6,4 +6,8 @@ enable + + + + diff --git a/dcnsanplanung.sharedTests/Helper/ImportToSoftwareTests.cs b/dcnsanplanung.sharedTests/Helper/ImportToSoftwareTests.cs new file mode 100644 index 0000000..c83e15b --- /dev/null +++ b/dcnsanplanung.sharedTests/Helper/ImportToSoftwareTests.cs @@ -0,0 +1,20 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using dcnsanplanung.shared.Helper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace dcnsanplanung.shared.Helper.Tests +{ + [TestClass()] + public class ImportToSoftwareTests + { + [TestMethod()] + public void ImportToSoftwareTest() + { + ImportToSoftware importToSoftware = new ImportToSoftware(@"C:\Users\damia\source\repos\dcnsanplanung\test_code.xml"); + } + } +} \ No newline at end of file diff --git a/dcnsanplanung.sharedTests/dcnsanplanung.sharedTests.csproj b/dcnsanplanung.sharedTests/dcnsanplanung.sharedTests.csproj new file mode 100644 index 0000000..c82f56c --- /dev/null +++ b/dcnsanplanung.sharedTests/dcnsanplanung.sharedTests.csproj @@ -0,0 +1,23 @@ + + + + net7.0 + enable + enable + + false + true + + + + + + + + + + + + + + diff --git a/dcnsanplanung.sln b/dcnsanplanung.sln index 2fc6072..b19e575 100644 --- a/dcnsanplanung.sln +++ b/dcnsanplanung.sln @@ -3,7 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.5.33530.505 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dcnsanplanung.wpf", "dcnsanplanung.wpf\dcnsanplanung.wpf.csproj", "{B0DDBF77-B592-4485-8705-E0B3AABBF171}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dcnsanplanung.wpf", "dcnsanplanung.wpf\dcnsanplanung.wpf.csproj", "{B0DDBF77-B592-4485-8705-E0B3AABBF171}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dcnsanplanung.shared", "dcnsanplanung.shared\dcnsanplanung.shared.csproj", "{AC43208D-6A5B-4A62-B8DE-DAE110C6CAFC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Schnittstelle", "Schnittstelle\Schnittstelle\Schnittstelle.csproj", "{3CD21512-6B4B-4590-A00E-36E40B791940}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dcnsanplanung.DAL", "dcnsanplanung.DAL\dcnsanplanung.DAL.csproj", "{FA2F4994-301B-4C11-8F44-585D4B726B97}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dcnsanplanung.sharedTests", "dcnsanplanung.sharedTests\dcnsanplanung.sharedTests.csproj", "{BD28F6AD-DA89-4BC7-A82D-7E28BB00E0EB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dcnsanplanung.DALTests", "dcnsanplanung.DALTests\dcnsanplanung.DALTests.csproj", "{91A48C89-5E1F-4C70-B995-A2AC9459E6C1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +25,26 @@ Global {B0DDBF77-B592-4485-8705-E0B3AABBF171}.Debug|Any CPU.Build.0 = Debug|Any CPU {B0DDBF77-B592-4485-8705-E0B3AABBF171}.Release|Any CPU.ActiveCfg = Release|Any CPU {B0DDBF77-B592-4485-8705-E0B3AABBF171}.Release|Any CPU.Build.0 = Release|Any CPU + {AC43208D-6A5B-4A62-B8DE-DAE110C6CAFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC43208D-6A5B-4A62-B8DE-DAE110C6CAFC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC43208D-6A5B-4A62-B8DE-DAE110C6CAFC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC43208D-6A5B-4A62-B8DE-DAE110C6CAFC}.Release|Any CPU.Build.0 = Release|Any CPU + {3CD21512-6B4B-4590-A00E-36E40B791940}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3CD21512-6B4B-4590-A00E-36E40B791940}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3CD21512-6B4B-4590-A00E-36E40B791940}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3CD21512-6B4B-4590-A00E-36E40B791940}.Release|Any CPU.Build.0 = Release|Any CPU + {FA2F4994-301B-4C11-8F44-585D4B726B97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA2F4994-301B-4C11-8F44-585D4B726B97}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA2F4994-301B-4C11-8F44-585D4B726B97}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA2F4994-301B-4C11-8F44-585D4B726B97}.Release|Any CPU.Build.0 = Release|Any CPU + {BD28F6AD-DA89-4BC7-A82D-7E28BB00E0EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD28F6AD-DA89-4BC7-A82D-7E28BB00E0EB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD28F6AD-DA89-4BC7-A82D-7E28BB00E0EB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD28F6AD-DA89-4BC7-A82D-7E28BB00E0EB}.Release|Any CPU.Build.0 = Release|Any CPU + {91A48C89-5E1F-4C70-B995-A2AC9459E6C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {91A48C89-5E1F-4C70-B995-A2AC9459E6C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {91A48C89-5E1F-4C70-B995-A2AC9459E6C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {91A48C89-5E1F-4C70-B995-A2AC9459E6C1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/dcnsanplanung.wpf/App.xaml.cs b/dcnsanplanung.wpf/App.xaml.cs index 5d3b534..eeccefe 100644 --- a/dcnsanplanung.wpf/App.xaml.cs +++ b/dcnsanplanung.wpf/App.xaml.cs @@ -13,5 +13,30 @@ namespace dcnsanplanung.wpf /// public partial class App : Application { + protected override void OnStartup(StartupEventArgs e) + { + Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + + base.OnStartup(e); + } + private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + try + { + Exception ex = (Exception)e.ExceptionObject; + string text = "An application error occured. Plrease contact the Administrator with the following information:\n\n"; + MessageBox.Show(text + " " + ex.Message + "\n\n" + ex.StackTrace); + } + catch (Exception ex2) + { + MessageBox.Show("Fatal Non-UI error", ex2.Message, MessageBoxButton.OK, MessageBoxImage.Error); + } + } + + private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) + { + throw new NotImplementedException(); + } } } diff --git a/dcnsanplanung.wpf/MainWindow.xaml b/dcnsanplanung.wpf/MainWindow.xaml index bab0383..faadacc 100644 --- a/dcnsanplanung.wpf/MainWindow.xaml +++ b/dcnsanplanung.wpf/MainWindow.xaml @@ -5,8 +5,23 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:dcnsanplanung.wpf" mc:Ignorable="d" - Title="MainWindow" Height="450" Width="800"> + Title="MainWindow" Height="450" Width="800" Loaded="Window_Loaded"> + + + + + + + + + + + + + +