From 1c4f581f2813cd2847d90bd752b8b4e84270ac7c Mon Sep 17 00:00:00 2001 From: Damian Wessels Date: Sat, 14 Jan 2023 12:20:47 +0100 Subject: [PATCH] EF core added --- SanSystem/BüroExporter.cs | 3 +- SanSystem/FrmNewProjekt.cs | 28 ++- SanSystem/Global.cs | 12 - SanSystem/KlassenBIB/Auftraggeber.cs | 2 +- SanSystem/KlassenBIB/DBModel.cs | 13 + SanSystem/KlassenBIB/Inspektionsobjekt.cs | 18 +- SanSystem/KlassenBIB/Projekt.cs | 8 +- .../Sanierung/Renovation/InlinerSanierung.cs | 2 +- SanSystem/KlassenBIB/Sanierung/Reparatur.cs | 2 +- SanSystem/KlassenBIB/Sanierung/Sanierung.cs | 4 +- SanSystem/KlassenBIB/SchachtAnbindung.cs | 2 +- .../20230114101006_InitialCreate.Designer.cs | 226 ++++++++++++++++++ .../20230114101006_InitialCreate.cs | 153 ++++++++++++ .../SanVerwalterContextModelSnapshot.cs | 224 +++++++++++++++++ SanSystem/Program.cs | 1 + SanSystem/SanSystem.csproj | 19 +- SanSystem/SanVerwalterContext.cs | 32 +++ SanSystem/SanVerwaltung.db | Bin 0 -> 49152 bytes SanSystem/SchnittstelleImporter/I2006XML.cs | 2 +- SanSystem/UCInliner.cs | 2 +- SanSystem/frmMain.cs | 4 +- SanSystem/frmObjektEdit.cs | 6 +- SanSystem/frmObjekteList.cs | 2 +- SanSystem/frmStrassenList.cs | 7 +- 24 files changed, 719 insertions(+), 53 deletions(-) create mode 100644 SanSystem/KlassenBIB/DBModel.cs create mode 100644 SanSystem/Migrations/20230114101006_InitialCreate.Designer.cs create mode 100644 SanSystem/Migrations/20230114101006_InitialCreate.cs create mode 100644 SanSystem/Migrations/SanVerwalterContextModelSnapshot.cs create mode 100644 SanSystem/SanVerwalterContext.cs create mode 100644 SanSystem/SanVerwaltung.db diff --git a/SanSystem/BüroExporter.cs b/SanSystem/BüroExporter.cs index b527712..f912fb8 100644 --- a/SanSystem/BüroExporter.cs +++ b/SanSystem/BüroExporter.cs @@ -58,7 +58,7 @@ namespace SanSystem } else if (san is KlassenBIB.SchachtAnbindung) { - string sourceDirectory = san.CheckVerzeichnisse(Global.Instance.Projektpfad); + /*string sourceDirectory = san.CheckVerzeichnisse(Global.Instance.Projektpfad); SchachtAnbindung fotoDokumentation = (san as SchachtAnbindung); KlassenBIB.Collections.Bilder fotos = fotoDokumentation.SavedBilders; foreach (SavedBilder foto in fotos) @@ -70,6 +70,7 @@ namespace SanSystem File.Copy(foto.Speicherpfad, Path.Combine(tempPath, destinationName)); } + */ } } diff --git a/SanSystem/FrmNewProjekt.cs b/SanSystem/FrmNewProjekt.cs index a2c4a55..184267a 100644 --- a/SanSystem/FrmNewProjekt.cs +++ b/SanSystem/FrmNewProjekt.cs @@ -25,26 +25,30 @@ namespace SanSystem InitializeComponent(); } - private bool project_already_excist(string projektnummer) - { - return Datenbank.Instance.TeufelDB.Projekte.FindAll(x => x.Nummer.Equals(projektnummer)).Count > 0; - } - private void btn_save_Click(object sender, EventArgs e) { - if(project_already_excist(txt_pro_nr.Text)) + using (var context = new SanVerwalterContext()) { - MessageBox.Show(string.Format("Projekt mit den nummer {0} excistiert bereits. Projekt wird nicht angelegt", txt_pro_nr.Text)); - return; + if (project_already_exist(context, txt_pro_nr.Text)) + { + MessageBox.Show(string.Format("Projekt mit den nummer {0} excistiert bereits. Projekt wird nicht angelegt", txt_pro_nr.Text)); + return; + } + Projekt projekt = new Projekt(); + projekt.Nummer = txt_pro_nr.Text; + projekt.Ort = txt_ort.Text; + context.Projekte.Add(projekt); + context.SaveChanges(); } - Projekt projekt = new Projekt(); - projekt.Nummer = txt_pro_nr.Text; - projekt.Ort = txt_ort.Text; - Global.Instance.SetProjekt(projekt); this.Close(); //Global.Instance.ChangeProjekt(txt_pro_nr.Text); } + private bool project_already_exist(SanVerwalterContext context, string text) + { + return context.Projekte.Count(x => x.Nummer.Equals(text)) > 0; + } + private void txt_pro_nr_KeyPress(object sender, KeyPressEventArgs e) { if(e.KeyChar == '/' || e.KeyChar == '\\') diff --git a/SanSystem/Global.cs b/SanSystem/Global.cs index 934e76c..cabdb5e 100644 --- a/SanSystem/Global.cs +++ b/SanSystem/Global.cs @@ -95,18 +95,6 @@ namespace SanSystem } } - internal void SetProjekt(Projekt projekt) - { - Database.Datenbank.Instance.SaveProjekt(); - this.ProjektNummer = projekt.Nummer; - Database.Datenbank.Instance.loadedProjekt = null; - Database.Datenbank.Instance.LoadProjekt(projekt.Nummer); - - if (!Directory.Exists(Projektpfad)) Directory.CreateDirectory(Projektpfad); - Database.Datenbank.Instance.TeufelDB.Projekte.Add(projekt); - Database.Datenbank.Instance.InitProjekt(projekt, Projektpfad); - } - public string Projektpfad { get diff --git a/SanSystem/KlassenBIB/Auftraggeber.cs b/SanSystem/KlassenBIB/Auftraggeber.cs index 845ebf3..bc529cd 100644 --- a/SanSystem/KlassenBIB/Auftraggeber.cs +++ b/SanSystem/KlassenBIB/Auftraggeber.cs @@ -10,7 +10,7 @@ namespace KlassenBIB /// /// /// - public class Auftraggeber :IAuftraggeber + public class Auftraggeber : DBModel, IAuftraggeber { /// /// diff --git a/SanSystem/KlassenBIB/DBModel.cs b/SanSystem/KlassenBIB/DBModel.cs new file mode 100644 index 0000000..5887593 --- /dev/null +++ b/SanSystem/KlassenBIB/DBModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KlassenBIB +{ + public abstract class DBModel + { + public int Id { get; set; } + } +} diff --git a/SanSystem/KlassenBIB/Inspektionsobjekt.cs b/SanSystem/KlassenBIB/Inspektionsobjekt.cs index 5a9fa74..7d7e406 100644 --- a/SanSystem/KlassenBIB/Inspektionsobjekt.cs +++ b/SanSystem/KlassenBIB/Inspektionsobjekt.cs @@ -1,6 +1,7 @@ using SanShared; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -11,11 +12,11 @@ namespace KlassenBIB /// /// /// - public class Inspektionsobjekt + public class Inspektionsobjekt: DBModel { private string strasseName = "none"; - public IAuftraggeber OverrideAuftraggeber { get; set; } + public Auftraggeber OverrideAuftraggeber { get; set; } public bool GeschlossenesEnde { get; set; } public string StrasseName { get => strasseName; set => strasseName = value; } @@ -42,25 +43,26 @@ namespace KlassenBIB public DateTime HaltungGemessen { get; set; } - public Collections.Inspektionskuerzeln Schadenskuerzeln { get; set; } + //public Collections.Inspektionskuerzeln Schadenskuerzeln { get; set; } public string Bemerkung { get; set; } - + + [NotMapped] public Collections.Sanierung Sanierung { get;set; } - public Collections.AusgefuehrteTaetigkeiten AusgefuehrteTaetigkeiten { get; set; } + //public Collections.AusgefuehrteTaetigkeiten AusgefuehrteTaetigkeiten { get; set; } public string Inspektionsrichtung { get; set; } public string Sanierungsnummer { get; set; } - public Guid Guid { get; set; } + public Inspektionsobjekt() { - Schadenskuerzeln = new Collections.Inspektionskuerzeln(); + //Schadenskuerzeln = new Collections.Inspektionskuerzeln(); Sanierung = new Collections.Sanierung(); - AusgefuehrteTaetigkeiten = new Collections.AusgefuehrteTaetigkeiten(); + //AusgefuehrteTaetigkeiten = new Collections.AusgefuehrteTaetigkeiten(); if (HaltungGemessen <= DateTime.MinValue || HaltungGemessen >= DateTime.MaxValue) HaltungGemessen = DateTime.Now; } } diff --git a/SanSystem/KlassenBIB/Projekt.cs b/SanSystem/KlassenBIB/Projekt.cs index 711c86d..715891b 100644 --- a/SanSystem/KlassenBIB/Projekt.cs +++ b/SanSystem/KlassenBIB/Projekt.cs @@ -8,12 +8,12 @@ using System.Windows.Markup; namespace KlassenBIB { - public class Projekt :IProjekt + public class Projekt: DBModel //:IProjekt { public string Nummer { get; set; } public string Ort { get; set; } - public IAuftraggeber Auftraggeber { get; set; } - public Collections.Leistungsverzeichnis Leistungsverzeichnis { get; set; } + public Auftraggeber Auftraggeber { get; set; } + //public Collections.Leistungsverzeichnis Leistungsverzeichnis { get; set; } public Collections.AbwasserTechnischeAnlage Objekte { get; set; } public string SanierungsIDPrefix { get; set; } public string SanierungsIDSuffix { get; set; } @@ -23,7 +23,7 @@ namespace KlassenBIB public Projekt() { Objekte = new Collections.AbwasserTechnischeAnlage(); - Leistungsverzeichnis = new Collections.Leistungsverzeichnis(); + //Leistungsverzeichnis = new Collections.Leistungsverzeichnis(); Auftraggeber = new Auftraggeber(); } } diff --git a/SanSystem/KlassenBIB/Sanierung/Renovation/InlinerSanierung.cs b/SanSystem/KlassenBIB/Sanierung/Renovation/InlinerSanierung.cs index 0bc0343..2530261 100644 --- a/SanSystem/KlassenBIB/Sanierung/Renovation/InlinerSanierung.cs +++ b/SanSystem/KlassenBIB/Sanierung/Renovation/InlinerSanierung.cs @@ -51,7 +51,7 @@ namespace KlassenBIB return haltungslaenge * harzbedarf; } - public override string CheckVerzeichnisse(string projektpfad) + public string CheckVerzeichnisse(string projektpfad) { string path = Path.Combine(projektpfad, PfadZurSan); if (!Directory.Exists(path)) Directory.CreateDirectory(path); diff --git a/SanSystem/KlassenBIB/Sanierung/Reparatur.cs b/SanSystem/KlassenBIB/Sanierung/Reparatur.cs index 465cddc..2c1e693 100644 --- a/SanSystem/KlassenBIB/Sanierung/Reparatur.cs +++ b/SanSystem/KlassenBIB/Sanierung/Reparatur.cs @@ -32,7 +32,7 @@ namespace KlassenBIB /// /// /// - public override string CheckVerzeichnisse(string projektpfad) + public string CheckVerzeichnisse(string projektpfad) { throw new NotImplementedException(); } diff --git a/SanSystem/KlassenBIB/Sanierung/Sanierung.cs b/SanSystem/KlassenBIB/Sanierung/Sanierung.cs index 4a375c3..8bef836 100644 --- a/SanSystem/KlassenBIB/Sanierung/Sanierung.cs +++ b/SanSystem/KlassenBIB/Sanierung/Sanierung.cs @@ -10,7 +10,7 @@ namespace KlassenBIB { [EditorBrowsable(EditorBrowsableState.Never)] [Browsable(false)] - public abstract class Sanierung : INotifyPropertyChanged + public class Sanierung : INotifyPropertyChanged { Guid guid; double tempAusen; @@ -37,7 +37,7 @@ namespace KlassenBIB } - public abstract string CheckVerzeichnisse(string projektpfad); + //public string CheckVerzeichnisse(string projektpfad); public Guid Guid { get => guid; set => guid = value; } diff --git a/SanSystem/KlassenBIB/SchachtAnbindung.cs b/SanSystem/KlassenBIB/SchachtAnbindung.cs index 27770e5..601bafe 100644 --- a/SanSystem/KlassenBIB/SchachtAnbindung.cs +++ b/SanSystem/KlassenBIB/SchachtAnbindung.cs @@ -37,7 +37,7 @@ namespace KlassenBIB /// /// /// - public override string CheckVerzeichnisse(string projektpfad) + public string CheckVerzeichnisse(string projektpfad) { string path = Path.Combine(projektpfad, PfadZurSan); if (!Directory.Exists(path)) Directory.CreateDirectory(path); diff --git a/SanSystem/Migrations/20230114101006_InitialCreate.Designer.cs b/SanSystem/Migrations/20230114101006_InitialCreate.Designer.cs new file mode 100644 index 0000000..5b2c3a7 --- /dev/null +++ b/SanSystem/Migrations/20230114101006_InitialCreate.Designer.cs @@ -0,0 +1,226 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using SanSystem; + +#nullable disable + +namespace SanSystem.Migrations +{ + [DbContext(typeof(SanVerwalterContext))] + [Migration("20230114101006_InitialCreate")] + partial class InitialCreate + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.0"); + + modelBuilder.Entity("KlassenBIB.Auftraggeber", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Ansprechpartner") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Ort") + .HasColumnType("TEXT"); + + b.Property("Strasse") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Auftraggebers"); + }); + + modelBuilder.Entity("KlassenBIB.Inspektionsobjekt", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bemerkung") + .HasColumnType("TEXT"); + + b.Property("BisPunkt") + .HasColumnType("TEXT"); + + b.Property("GeschlossenesEnde") + .HasColumnType("INTEGER"); + + b.Property("Guid") + .HasColumnType("TEXT"); + + b.Property("HaltungGemessen") + .HasColumnType("TEXT"); + + b.Property("Haltungslaenge") + .HasColumnType("REAL"); + + b.Property("Hausnummer") + .HasColumnType("TEXT"); + + b.Property("Inspektionsrichtung") + .HasColumnType("TEXT"); + + b.Property("Kanalrohrweite") + .HasColumnType("INTEGER"); + + b.Property("Objektbezeichnung") + .HasColumnType("TEXT"); + + b.Property("OrtName") + .HasColumnType("TEXT"); + + b.Property("OverrideAuftraggeberId") + .HasColumnType("INTEGER"); + + b.Property("ProjektId") + .HasColumnType("INTEGER"); + + b.Property("Projektnummer") + .HasColumnType("TEXT"); + + b.Property("RohrMaterial") + .HasColumnType("TEXT"); + + b.Property("Sanierungsnummer") + .HasColumnType("TEXT"); + + b.Property("Schachtlaenge") + .HasColumnType("REAL"); + + b.Property("StrasseName") + .HasColumnType("TEXT"); + + b.Property("VonPunkt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OverrideAuftraggeberId"); + + b.HasIndex("ProjektId"); + + b.ToTable("InspektionObjekte"); + }); + + modelBuilder.Entity("KlassenBIB.Projekt", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AuftraggeberId") + .HasColumnType("INTEGER"); + + b.Property("Nummer") + .HasColumnType("TEXT"); + + b.Property("Ort") + .HasColumnType("TEXT"); + + b.Property("SanierungsIDPrefix") + .HasColumnType("TEXT"); + + b.Property("SanierungsIDSuffix") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("AuftraggeberId"); + + b.ToTable("Projekte"); + }); + + modelBuilder.Entity("KlassenBIB.Sanierung", b => + { + b.Property("GenehmigungVorhanden") + .HasColumnType("INTEGER"); + + b.Property("Guid") + .HasColumnType("TEXT"); + + b.Property("HDReinigung") + .HasColumnType("INTEGER"); + + b.Property("HDReinigungDatum") + .HasColumnType("TEXT"); + + b.Property("InspektionsobjektId") + .HasColumnType("INTEGER"); + + b.Property("STVOAbsicherung") + .HasColumnType("INTEGER"); + + b.Property("TempAusen") + .HasColumnType("REAL"); + + b.Property("TempKanal") + .HasColumnType("REAL"); + + b.Property("VorbereitetMechanisch") + .HasColumnType("INTEGER"); + + b.Property("VorbereitetRoboter") + .HasColumnType("INTEGER"); + + b.Property("WasserhaltungEingerichtet") + .HasColumnType("INTEGER"); + + b.Property("Wetter") + .HasColumnType("TEXT"); + + b.HasIndex("InspektionsobjektId"); + + b.ToTable("Sanierung"); + }); + + modelBuilder.Entity("KlassenBIB.Inspektionsobjekt", b => + { + b.HasOne("KlassenBIB.Auftraggeber", "OverrideAuftraggeber") + .WithMany() + .HasForeignKey("OverrideAuftraggeberId"); + + b.HasOne("KlassenBIB.Projekt", null) + .WithMany("Objekte") + .HasForeignKey("ProjektId"); + + b.Navigation("OverrideAuftraggeber"); + }); + + modelBuilder.Entity("KlassenBIB.Projekt", b => + { + b.HasOne("KlassenBIB.Auftraggeber", "Auftraggeber") + .WithMany() + .HasForeignKey("AuftraggeberId"); + + b.Navigation("Auftraggeber"); + }); + + modelBuilder.Entity("KlassenBIB.Sanierung", b => + { + b.HasOne("KlassenBIB.Inspektionsobjekt", "Inspektionsobjekt") + .WithMany() + .HasForeignKey("InspektionsobjektId"); + + b.Navigation("Inspektionsobjekt"); + }); + + modelBuilder.Entity("KlassenBIB.Projekt", b => + { + b.Navigation("Objekte"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SanSystem/Migrations/20230114101006_InitialCreate.cs b/SanSystem/Migrations/20230114101006_InitialCreate.cs new file mode 100644 index 0000000..c915327 --- /dev/null +++ b/SanSystem/Migrations/20230114101006_InitialCreate.cs @@ -0,0 +1,153 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SanSystem.Migrations +{ + public partial class InitialCreate : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Auftraggebers", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: true), + Strasse = table.Column(type: "TEXT", nullable: true), + Ort = table.Column(type: "TEXT", nullable: true), + Ansprechpartner = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Auftraggebers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Projekte", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Nummer = table.Column(type: "TEXT", nullable: true), + Ort = table.Column(type: "TEXT", nullable: true), + AuftraggeberId = table.Column(type: "INTEGER", nullable: true), + SanierungsIDPrefix = table.Column(type: "TEXT", nullable: true), + SanierungsIDSuffix = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Projekte", x => x.Id); + table.ForeignKey( + name: "FK_Projekte_Auftraggebers_AuftraggeberId", + column: x => x.AuftraggeberId, + principalTable: "Auftraggebers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "InspektionObjekte", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + OverrideAuftraggeberId = table.Column(type: "INTEGER", nullable: true), + GeschlossenesEnde = table.Column(type: "INTEGER", nullable: false), + StrasseName = table.Column(type: "TEXT", nullable: true), + OrtName = table.Column(type: "TEXT", nullable: true), + Hausnummer = table.Column(type: "TEXT", nullable: true), + Projektnummer = table.Column(type: "TEXT", nullable: true), + Objektbezeichnung = table.Column(type: "TEXT", nullable: true), + VonPunkt = table.Column(type: "TEXT", nullable: true), + BisPunkt = table.Column(type: "TEXT", nullable: true), + RohrMaterial = table.Column(type: "TEXT", nullable: true), + Kanalrohrweite = table.Column(type: "INTEGER", nullable: false), + Haltungslaenge = table.Column(type: "REAL", nullable: false), + Schachtlaenge = table.Column(type: "REAL", nullable: false), + HaltungGemessen = table.Column(type: "TEXT", nullable: false), + Bemerkung = table.Column(type: "TEXT", nullable: true), + Inspektionsrichtung = table.Column(type: "TEXT", nullable: true), + Sanierungsnummer = table.Column(type: "TEXT", nullable: true), + Guid = table.Column(type: "TEXT", nullable: false), + ProjektId = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_InspektionObjekte", x => x.Id); + table.ForeignKey( + name: "FK_InspektionObjekte_Auftraggebers_OverrideAuftraggeberId", + column: x => x.OverrideAuftraggeberId, + principalTable: "Auftraggebers", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_InspektionObjekte_Projekte_ProjektId", + column: x => x.ProjektId, + principalTable: "Projekte", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Sanierung", + columns: table => new + { + Guid = table.Column(type: "TEXT", nullable: false), + TempAusen = table.Column(type: "REAL", nullable: false), + TempKanal = table.Column(type: "REAL", nullable: false), + Wetter = table.Column(type: "TEXT", nullable: true), + GenehmigungVorhanden = table.Column(type: "INTEGER", nullable: false), + WasserhaltungEingerichtet = table.Column(type: "INTEGER", nullable: false), + STVOAbsicherung = table.Column(type: "INTEGER", nullable: false), + HDReinigung = table.Column(type: "INTEGER", nullable: false), + HDReinigungDatum = table.Column(type: "TEXT", nullable: false), + InspektionsobjektId = table.Column(type: "INTEGER", nullable: true), + VorbereitetMechanisch = table.Column(type: "INTEGER", nullable: false), + VorbereitetRoboter = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.ForeignKey( + name: "FK_Sanierung_InspektionObjekte_InspektionsobjektId", + column: x => x.InspektionsobjektId, + principalTable: "InspektionObjekte", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_InspektionObjekte_OverrideAuftraggeberId", + table: "InspektionObjekte", + column: "OverrideAuftraggeberId"); + + migrationBuilder.CreateIndex( + name: "IX_InspektionObjekte_ProjektId", + table: "InspektionObjekte", + column: "ProjektId"); + + migrationBuilder.CreateIndex( + name: "IX_Projekte_AuftraggeberId", + table: "Projekte", + column: "AuftraggeberId"); + + migrationBuilder.CreateIndex( + name: "IX_Sanierung_InspektionsobjektId", + table: "Sanierung", + column: "InspektionsobjektId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Sanierung"); + + migrationBuilder.DropTable( + name: "InspektionObjekte"); + + migrationBuilder.DropTable( + name: "Projekte"); + + migrationBuilder.DropTable( + name: "Auftraggebers"); + } + } +} diff --git a/SanSystem/Migrations/SanVerwalterContextModelSnapshot.cs b/SanSystem/Migrations/SanVerwalterContextModelSnapshot.cs new file mode 100644 index 0000000..ab05f7b --- /dev/null +++ b/SanSystem/Migrations/SanVerwalterContextModelSnapshot.cs @@ -0,0 +1,224 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using SanSystem; + +#nullable disable + +namespace SanSystem.Migrations +{ + [DbContext(typeof(SanVerwalterContext))] + partial class SanVerwalterContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.0"); + + modelBuilder.Entity("KlassenBIB.Auftraggeber", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Ansprechpartner") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Ort") + .HasColumnType("TEXT"); + + b.Property("Strasse") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Auftraggebers"); + }); + + modelBuilder.Entity("KlassenBIB.Inspektionsobjekt", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bemerkung") + .HasColumnType("TEXT"); + + b.Property("BisPunkt") + .HasColumnType("TEXT"); + + b.Property("GeschlossenesEnde") + .HasColumnType("INTEGER"); + + b.Property("Guid") + .HasColumnType("TEXT"); + + b.Property("HaltungGemessen") + .HasColumnType("TEXT"); + + b.Property("Haltungslaenge") + .HasColumnType("REAL"); + + b.Property("Hausnummer") + .HasColumnType("TEXT"); + + b.Property("Inspektionsrichtung") + .HasColumnType("TEXT"); + + b.Property("Kanalrohrweite") + .HasColumnType("INTEGER"); + + b.Property("Objektbezeichnung") + .HasColumnType("TEXT"); + + b.Property("OrtName") + .HasColumnType("TEXT"); + + b.Property("OverrideAuftraggeberId") + .HasColumnType("INTEGER"); + + b.Property("ProjektId") + .HasColumnType("INTEGER"); + + b.Property("Projektnummer") + .HasColumnType("TEXT"); + + b.Property("RohrMaterial") + .HasColumnType("TEXT"); + + b.Property("Sanierungsnummer") + .HasColumnType("TEXT"); + + b.Property("Schachtlaenge") + .HasColumnType("REAL"); + + b.Property("StrasseName") + .HasColumnType("TEXT"); + + b.Property("VonPunkt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OverrideAuftraggeberId"); + + b.HasIndex("ProjektId"); + + b.ToTable("InspektionObjekte"); + }); + + modelBuilder.Entity("KlassenBIB.Projekt", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AuftraggeberId") + .HasColumnType("INTEGER"); + + b.Property("Nummer") + .HasColumnType("TEXT"); + + b.Property("Ort") + .HasColumnType("TEXT"); + + b.Property("SanierungsIDPrefix") + .HasColumnType("TEXT"); + + b.Property("SanierungsIDSuffix") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("AuftraggeberId"); + + b.ToTable("Projekte"); + }); + + modelBuilder.Entity("KlassenBIB.Sanierung", b => + { + b.Property("GenehmigungVorhanden") + .HasColumnType("INTEGER"); + + b.Property("Guid") + .HasColumnType("TEXT"); + + b.Property("HDReinigung") + .HasColumnType("INTEGER"); + + b.Property("HDReinigungDatum") + .HasColumnType("TEXT"); + + b.Property("InspektionsobjektId") + .HasColumnType("INTEGER"); + + b.Property("STVOAbsicherung") + .HasColumnType("INTEGER"); + + b.Property("TempAusen") + .HasColumnType("REAL"); + + b.Property("TempKanal") + .HasColumnType("REAL"); + + b.Property("VorbereitetMechanisch") + .HasColumnType("INTEGER"); + + b.Property("VorbereitetRoboter") + .HasColumnType("INTEGER"); + + b.Property("WasserhaltungEingerichtet") + .HasColumnType("INTEGER"); + + b.Property("Wetter") + .HasColumnType("TEXT"); + + b.HasIndex("InspektionsobjektId"); + + b.ToTable("Sanierung"); + }); + + modelBuilder.Entity("KlassenBIB.Inspektionsobjekt", b => + { + b.HasOne("KlassenBIB.Auftraggeber", "OverrideAuftraggeber") + .WithMany() + .HasForeignKey("OverrideAuftraggeberId"); + + b.HasOne("KlassenBIB.Projekt", null) + .WithMany("Objekte") + .HasForeignKey("ProjektId"); + + b.Navigation("OverrideAuftraggeber"); + }); + + modelBuilder.Entity("KlassenBIB.Projekt", b => + { + b.HasOne("KlassenBIB.Auftraggeber", "Auftraggeber") + .WithMany() + .HasForeignKey("AuftraggeberId"); + + b.Navigation("Auftraggeber"); + }); + + modelBuilder.Entity("KlassenBIB.Sanierung", b => + { + b.HasOne("KlassenBIB.Inspektionsobjekt", "Inspektionsobjekt") + .WithMany() + .HasForeignKey("InspektionsobjektId"); + + b.Navigation("Inspektionsobjekt"); + }); + + modelBuilder.Entity("KlassenBIB.Projekt", b => + { + b.Navigation("Objekte"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SanSystem/Program.cs b/SanSystem/Program.cs index a6fe33a..5cf0819 100644 --- a/SanSystem/Program.cs +++ b/SanSystem/Program.cs @@ -18,6 +18,7 @@ namespace SanSystem [STAThread] static void Main() { + new Mutex(initiallyOwned: true, "SanVerwaltung", out bool result); if(!result) { diff --git a/SanSystem/SanSystem.csproj b/SanSystem/SanSystem.csproj index b690094..c94cb85 100644 --- a/SanSystem/SanSystem.csproj +++ b/SanSystem/SanSystem.csproj @@ -18,13 +18,30 @@ - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + PreserveNewest + + + Never + + + Never + + + diff --git a/SanSystem/SanVerwalterContext.cs b/SanSystem/SanVerwalterContext.cs new file mode 100644 index 0000000..d7f1f83 --- /dev/null +++ b/SanSystem/SanVerwalterContext.cs @@ -0,0 +1,32 @@ +using KlassenBIB; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SanSystem +{ + public class SanVerwalterContext : DbContext + { + public DbSet Projekte { get; set; } + public DbSet InspektionObjekte { get; set; } + public DbSet Sanierung { get; set; } + public DbSet Auftraggebers { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlite("Data Source=SanVerwaltung.db"); + base.OnConfiguring(optionsBuilder); + + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasNoKey(); + base.OnModelCreating(modelBuilder); + + } + } +} diff --git a/SanSystem/SanVerwaltung.db b/SanSystem/SanVerwaltung.db new file mode 100644 index 0000000000000000000000000000000000000000..f544ca9fc0c4b41602859f96823645bcb684916c GIT binary patch literal 49152 zcmeI4OHbog6vyKP2#;atri!{ic&th@(TpIOX$N)J047+FN0ST#i&5kxm*A4vj34b# zsf*00Rn=8LM7Ldb-4D=RrEa?F$LO*r#!h@=8;0d1e~T!#@44rm^E(gc21NaU0&rlWV8if&!9 z3tKaE%V>Q~XG&)@cyG5R7aFptl=tKlQMzrOBv#6zG@31mkE96gQub;&ohhsfg9pAf zRnr)*%$fz~%r@0-m$jIwbo|>ZAv64ui3!&R_=Cgsd4*DTaDOSCQMQCZ-d}rcVa0Wy zHNE*tCp5GiG9)B2o_%dhNMLByXazFp^Tl+gO$M=egDT%J)6_bQcP6BH={>BAR&|4^ zF%z;se3DLQHa3Kx1zT05$r6w!IvUn(;#lu`qIG)|Al}^Fr zrNSK>3U*Ow=fBSA-VLa>BW>Ai+JStc}#{y*>fXq09l)b9S&a^iX zih@FQ=PXiaA~3#J+y^m>yBeCrM`prcK0LueD-fgV+(PE@W8u_|koCGp72dSiYlrD= zHgP%6#cN{lkxtF<3C+yDolB)N4<8Eeimpy>VeVp%)5m?L99npXM+2u;5^v9h=*I1} z^@tG0WC%ShO?uv6s-~@TJ)M$&a3Z8L+uOq1ii@Gyl=n+o*Hqmt!GUJkhItivGs$C# zlo{h0=^W+*_n~j{`5B`q0Ly>8QTBD5wtdV@i}o)QYRNSvxsZ9aEhOBJ)?OZ{j%~Qt z&B%3{`N-QT+HfrnH(jgr64w4n&<_p}009sH0T2KI5C8!X009sH0T2Lz501d6LQ2j& z%{_gV%jZAK=kmGSbNV(^v+29$U6awb&d)b-l0T2KI5C8!X009sH0T2KI5SV@f z!~g$}|Nl4rafXK=00JNY0w4eaAOHd&00JNY0<%p3`~TUFKfDJ45C8!X009sH0T2KI z5C8!Xm< ortteile = Datenbank.Instance.loadedProjekt.Objekte.Select(x => x.OrtName).Distinct().ToList(); int aktuellOpened = -1; bool aktuelleStrasse = false; @@ -109,7 +110,8 @@ namespace SanSystem } private void buildUnsortedStreetList() - { + { + List strassen = Datenbank.Instance.loadedProjekt.Objekte.Select(x => x.StrasseName).Distinct().ToList(); List streets = new List(); @@ -129,6 +131,9 @@ namespace SanSystem private void frmStrassenList_Load(object sender, EventArgs e) { + + + this.Height = this.MdiParent.Height - 120; if(streetListSetting.SortedSelected()) {