From 09b34c0a14d59f40dc865ba98e991a83419ae6d9 Mon Sep 17 00:00:00 2001 From: francesco Date: Sat, 29 Aug 2020 22:33:50 +0200 Subject: [PATCH] Call CTE in a StoredProcedure with EF Add All Models in DB and Updated Components to match ID of the impoted Tables --- .../LoggingClient/LoggingClient.csproj | 64 +- LoggingClient/LoggingClient/Model/Customer.cs | 18 +- .../LoggingClient/Model/Inventar.Context.cs | 22 + .../LoggingClient/Model/Inventar.Designer.cs | 2 +- .../LoggingClient/Model/Inventar.edmx | 1538 ++++++++++++++++- .../LoggingClient/Model/Inventar.edmx.diagram | 46 +- LoggingClient/LoggingClient/Model/Location.cs | 105 +- .../LoggingClient/Model/abrechnung.cs | 39 + LoggingClient/LoggingClient/Model/address.cs | 35 + LoggingClient/LoggingClient/Model/contact.cs | 31 + .../LoggingClient/Model/credentials.cs | 31 + LoggingClient/LoggingClient/Model/device.cs | 49 + .../LoggingClient/Model/deviceport.cs | 25 + .../LoggingClient/Model/devicetype.cs | 34 + .../LoggingClient/Model/interface.cs | 38 + .../LoggingClient/Model/kundenkonto.cs | 31 + LoggingClient/LoggingClient/Model/log.cs | 26 + LoggingClient/LoggingClient/Model/network.cs | 32 + .../LoggingClient/Model/operatingsystem.cs | 31 + LoggingClient/LoggingClient/Model/person.cs | 30 + .../LoggingClient/Model/pointofdelivery.cs | 30 + LoggingClient/LoggingClient/Model/produkte.cs | 24 + .../LoggingClient/Model/produktegruppe.cs | 33 + .../Model/softwaredienstleistung.cs | 23 + LoggingClient/LoggingClient/Model/town.cs | 30 + .../LoggingClient/Model/transportmedium.cs | 29 + .../LoggingClient/Model/v_logentries.cs | 25 + .../Repository/LocationRepository.cs | 51 +- .../ViewModel/LocationTreeBuilder.cs | 4 +- .../ViewModel/LocationViewModel.cs | 8 +- .../LoggingClient/Views/LocationView.xaml | 14 +- 31 files changed, 2378 insertions(+), 120 deletions(-) create mode 100644 LoggingClient/LoggingClient/Model/abrechnung.cs create mode 100644 LoggingClient/LoggingClient/Model/address.cs create mode 100644 LoggingClient/LoggingClient/Model/contact.cs create mode 100644 LoggingClient/LoggingClient/Model/credentials.cs create mode 100644 LoggingClient/LoggingClient/Model/device.cs create mode 100644 LoggingClient/LoggingClient/Model/deviceport.cs create mode 100644 LoggingClient/LoggingClient/Model/devicetype.cs create mode 100644 LoggingClient/LoggingClient/Model/interface.cs create mode 100644 LoggingClient/LoggingClient/Model/kundenkonto.cs create mode 100644 LoggingClient/LoggingClient/Model/log.cs create mode 100644 LoggingClient/LoggingClient/Model/network.cs create mode 100644 LoggingClient/LoggingClient/Model/operatingsystem.cs create mode 100644 LoggingClient/LoggingClient/Model/person.cs create mode 100644 LoggingClient/LoggingClient/Model/pointofdelivery.cs create mode 100644 LoggingClient/LoggingClient/Model/produkte.cs create mode 100644 LoggingClient/LoggingClient/Model/produktegruppe.cs create mode 100644 LoggingClient/LoggingClient/Model/softwaredienstleistung.cs create mode 100644 LoggingClient/LoggingClient/Model/town.cs create mode 100644 LoggingClient/LoggingClient/Model/transportmedium.cs create mode 100644 LoggingClient/LoggingClient/Model/v_logentries.cs diff --git a/LoggingClient/LoggingClient/LoggingClient.csproj b/LoggingClient/LoggingClient/LoggingClient.csproj index 27b2442..582f905 100644 --- a/LoggingClient/LoggingClient/LoggingClient.csproj +++ b/LoggingClient/LoggingClient/LoggingClient.csproj @@ -87,10 +87,34 @@ MSBuild:Compile Designer + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + Inventar.tt + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + True True @@ -106,10 +130,48 @@ True Inventar.edmx + + Inventar.tt + + + Inventar.tt + - + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + + + Inventar.tt + diff --git a/LoggingClient/LoggingClient/Model/Customer.cs b/LoggingClient/LoggingClient/Model/Customer.cs index 2118d2a..2f90ca9 100644 --- a/LoggingClient/LoggingClient/Model/Customer.cs +++ b/LoggingClient/LoggingClient/Model/Customer.cs @@ -9,8 +9,17 @@ namespace LoggingClient.Model { + using System; + using System.Collections.Generic; + public partial class Customer { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public Customer() + { + this.pointofdelivery = new HashSet(); + } + public long customer_id { get; set; } public string firstname { get; set; } public string lastname { get; set; } @@ -20,8 +29,10 @@ namespace LoggingClient.Model public string email { get; set; } public string url { get; set; } public string password { get; set; } - - public Customer() { } + + public virtual kundenkonto kundenkonto { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection pointofdelivery { get; set; } public Customer(long Id, string FirstName, string LastName, string CustomerNumber, long Customer_fk, string PhoneNumber, string EMail, string URL, string Password) { @@ -35,5 +46,6 @@ namespace LoggingClient.Model this.url = URL; this.password = Password; } - } + + } } diff --git a/LoggingClient/LoggingClient/Model/Inventar.Context.cs b/LoggingClient/LoggingClient/Model/Inventar.Context.cs index c086774..36bed02 100644 --- a/LoggingClient/LoggingClient/Model/Inventar.Context.cs +++ b/LoggingClient/LoggingClient/Model/Inventar.Context.cs @@ -11,6 +11,7 @@ namespace LoggingClient.Model { using System; using System.Data.Entity; + using System.Data.Entity.Core.Objects; using System.Data.Entity.Infrastructure; public partial class inventarisierungsloesungEntities : DbContext @@ -26,5 +27,26 @@ namespace LoggingClient.Model } public virtual DbSet Customer { get; set; } + public virtual DbSet abrechnung { get; set; } + public virtual DbSet
address { get; set; } + public virtual DbSet contact { get; set; } + public virtual DbSet credentials { get; set; } + public virtual DbSet device { get; set; } + public virtual DbSet deviceport { get; set; } + public virtual DbSet devicetype { get; set; } + public virtual DbSet<@interface> @interface { get; set; } + public virtual DbSet kundenkonto { get; set; } + public virtual DbSet Location { get; set; } + public virtual DbSet log { get; set; } + public virtual DbSet network { get; set; } + public virtual DbSet operatingsystem { get; set; } + public virtual DbSet person { get; set; } + public virtual DbSet pointofdelivery { get; set; } + public virtual DbSet produkte { get; set; } + public virtual DbSet produktegruppe { get; set; } + public virtual DbSet softwaredienstleistung { get; set; } + public virtual DbSet town { get; set; } + public virtual DbSet transportmedium { get; set; } + public virtual DbSet v_logentries { get; set; } } } diff --git a/LoggingClient/LoggingClient/Model/Inventar.Designer.cs b/LoggingClient/LoggingClient/Model/Inventar.Designer.cs index b914d78..9e3a707 100644 --- a/LoggingClient/LoggingClient/Model/Inventar.Designer.cs +++ b/LoggingClient/LoggingClient/Model/Inventar.Designer.cs @@ -1,4 +1,4 @@ -// T4 code generation is enabled for model 'Z:\Workspace\zbw\pa\pa2.Testat\LoggingClient\LoggingClient\Model\Inventar.edmx'. +// T4 code generation is enabled for model 'C:\Workspace\pa2.Testat\LoggingClient\LoggingClient\Model\Inventar.edmx'. // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model // is open in the designer. diff --git a/LoggingClient/LoggingClient/Model/Inventar.edmx b/LoggingClient/LoggingClient/Model/Inventar.edmx index 8a3b258..cb2501c 100644 --- a/LoggingClient/LoggingClient/Model/Inventar.edmx +++ b/LoggingClient/LoggingClient/Model/Inventar.edmx @@ -4,12 +4,51 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -19,11 +58,616 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + @@ -31,19 +675,644 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -65,6 +1334,249 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LoggingClient/LoggingClient/Model/Inventar.edmx.diagram b/LoggingClient/LoggingClient/Model/Inventar.edmx.diagram index 4b9a5ff..5d7408c 100644 --- a/LoggingClient/LoggingClient/Model/Inventar.edmx.diagram +++ b/LoggingClient/LoggingClient/Model/Inventar.edmx.diagram @@ -5,7 +5,51 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LoggingClient/LoggingClient/Model/Location.cs b/LoggingClient/LoggingClient/Model/Location.cs index 3b2514d..f880ba1 100644 --- a/LoggingClient/LoggingClient/Model/Location.cs +++ b/LoggingClient/LoggingClient/Model/Location.cs @@ -1,79 +1,52 @@ -using System; +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ namespace LoggingClient.Model { - public class Location : Model + using System; + using System.Collections.Generic; + + public partial class Location { - public new int Id { get; set; } - public int ParentId { get; set; } - public int AddressId { get; set; } - public string Designation { get; set; } - public int BuildingNr { get; set; } - public int RoomNr { get; set; } - + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public Location() { - + this.abrechnung = new HashSet(); + this.device = new HashSet(); + this.pointofdelivery = new HashSet(); } + public Location(int id, int parentId, int addressId, string designation, int buildingNr, int roomNr) { - this.Id = id; - this.ParentId = parentId; - this.AddressId = addressId; - this.Designation = designation; - this.BuildingNr = buildingNr; - this.RoomNr = roomNr; - } - public bool Equals(Location location) - { - if (Object.ReferenceEquals(null, location)) return false; - if (Object.ReferenceEquals(this, location)) return true; - - return String.Equals(Designation, location.Designation) && String.Equals(BuildingNr, location.BuildingNr) && String.Equals(RoomNr, location.RoomNr); - } - public override bool Equals(object value) - { - return Equals(value as Location); - } - public override int GetHashCode() - { - unchecked - { - // Choose large primes to avoid hashing collisions - const int hashingBase = (int)2166136261; - const int hashingMultiplier = 16777619; - - int hash = hashingBase; - hash = (hash * hashingMultiplier) ^ (!Object.ReferenceEquals(null, Designation) ? Designation.GetHashCode() : 0); - hash = (hash * hashingMultiplier) ^ (!Object.ReferenceEquals(null, BuildingNr) ? BuildingNr.GetHashCode() : 0); - hash = (hash * hashingMultiplier) ^ (!Object.ReferenceEquals(null, RoomNr) ? RoomNr.GetHashCode() : 0); - return hash; - } - } - public static bool operator ==(Location locA, Location locB) - { - if (Object.ReferenceEquals(locA, locB)) - { - return true; - } - - //Ensure that A isnt Null - if (Object.ReferenceEquals(null, locA)) - { - return false; - } - - return (locA.Equals(locB)); + this.location_id = id; + this.parentid = parentId; + this.address_fk = addressId; + this.designation = designation; + this.building = buildingNr; + this.room = roomNr; } - public static bool operator !=(Location locA, Location locB) - { - return !(locA == locB); - } + public long location_id { get; set; } + public Nullable parentid { get; set; } + public long address_fk { get; set; } + public string designation { get; set; } + public long building { get; set; } + public long room { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection abrechnung { get; set; } + public virtual address address { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection device { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection pointofdelivery { get; set; } + - public override string ToString() - { - return Designation; - } } -} \ No newline at end of file +} diff --git a/LoggingClient/LoggingClient/Model/abrechnung.cs b/LoggingClient/LoggingClient/Model/abrechnung.cs new file mode 100644 index 0000000..2e21849 --- /dev/null +++ b/LoggingClient/LoggingClient/Model/abrechnung.cs @@ -0,0 +1,39 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class abrechnung + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public abrechnung() + { + this.produktegruppe = new HashSet(); + this.softwaredienstleistung = new HashSet(); + } + + public long abrechnung_id { get; set; } + public long kundenkonto_fk { get; set; } + public long location_fk { get; set; } + public long device_fk { get; set; } + public long interface_fk { get; set; } + + public virtual kundenkonto kundenkonto { get; set; } + public virtual Location Location { get; set; } + public virtual device device { get; set; } + public virtual @interface @interface { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection produktegruppe { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection softwaredienstleistung { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/address.cs b/LoggingClient/LoggingClient/Model/address.cs new file mode 100644 index 0000000..4c0947d --- /dev/null +++ b/LoggingClient/LoggingClient/Model/address.cs @@ -0,0 +1,35 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class address + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public address() + { + this.Location = new HashSet(); + } + + public long address_id { get; set; } + public long town_fk { get; set; } + public string streetname { get; set; } + public string streetnumber { get; set; } + public string country { get; set; } + public string additive { get; set; } + public Nullable po_box { get; set; } + + public virtual town town { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection Location { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/contact.cs b/LoggingClient/LoggingClient/Model/contact.cs new file mode 100644 index 0000000..d973c09 --- /dev/null +++ b/LoggingClient/LoggingClient/Model/contact.cs @@ -0,0 +1,31 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class contact + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public contact() + { + this.pointofdelivery = new HashSet(); + } + + public long contact_id { get; set; } + public long person_fk { get; set; } + public string priority { get; set; } + + public virtual person person { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection pointofdelivery { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/credentials.cs b/LoggingClient/LoggingClient/Model/credentials.cs new file mode 100644 index 0000000..bac4182 --- /dev/null +++ b/LoggingClient/LoggingClient/Model/credentials.cs @@ -0,0 +1,31 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class credentials + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public credentials() + { + this.device = new HashSet(); + } + + public long credentials_id { get; set; } + public string benutzername { get; set; } + public string passwort { get; set; } + public string snmp { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection device { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/device.cs b/LoggingClient/LoggingClient/Model/device.cs new file mode 100644 index 0000000..a33a804 --- /dev/null +++ b/LoggingClient/LoggingClient/Model/device.cs @@ -0,0 +1,49 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class device + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public device() + { + this.abrechnung = new HashSet(); + this.deviceport = new HashSet(); + this.@interface = new HashSet<@interface>(); + this.log = new HashSet(); + this.credentials = new HashSet(); + } + + public long device_id { get; set; } + public long location_fk { get; set; } + public long devicetype_fk { get; set; } + public System.DateTime inventorydate { get; set; } + public System.DateTime deactivatedate { get; set; } + public string hostname { get; set; } + public string domain { get; set; } + public string description { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection abrechnung { get; set; } + public virtual Location Location { get; set; } + public virtual devicetype devicetype { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection deviceport { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection<@interface> @interface { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection log { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection credentials { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/deviceport.cs b/LoggingClient/LoggingClient/Model/deviceport.cs new file mode 100644 index 0000000..ce2955e --- /dev/null +++ b/LoggingClient/LoggingClient/Model/deviceport.cs @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class deviceport + { + public int deviceport_id { get; set; } + public string description { get; set; } + public long device_fk { get; set; } + public long transportmedium_fk { get; set; } + + public virtual device device { get; set; } + public virtual transportmedium transportmedium { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/devicetype.cs b/LoggingClient/LoggingClient/Model/devicetype.cs new file mode 100644 index 0000000..45632e3 --- /dev/null +++ b/LoggingClient/LoggingClient/Model/devicetype.cs @@ -0,0 +1,34 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class devicetype + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public devicetype() + { + this.device = new HashSet(); + this.operatingsystem = new HashSet(); + } + + public long devicetype_id { get; set; } + public string manufacturer { get; set; } + public string model { get; set; } + public string version { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection device { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection operatingsystem { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/interface.cs b/LoggingClient/LoggingClient/Model/interface.cs new file mode 100644 index 0000000..e759935 --- /dev/null +++ b/LoggingClient/LoggingClient/Model/interface.cs @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class @interface + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public @interface() + { + this.abrechnung = new HashSet(); + } + + public long interface_id { get; set; } + public int network_fk { get; set; } + public long device_fk { get; set; } + public string ip_adress_v4 { get; set; } + public string mac_adresse { get; set; } + public short isfullduplex { get; set; } + public Nullable bandwith { get; set; } + public Nullable is_in_use { get; set; } + public string description { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection abrechnung { get; set; } + public virtual device device { get; set; } + public virtual network network { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/kundenkonto.cs b/LoggingClient/LoggingClient/Model/kundenkonto.cs new file mode 100644 index 0000000..4da019b --- /dev/null +++ b/LoggingClient/LoggingClient/Model/kundenkonto.cs @@ -0,0 +1,31 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class kundenkonto + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public kundenkonto() + { + this.abrechnung = new HashSet(); + this.Customer = new HashSet(); + } + + public long kundenkonto_id { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection abrechnung { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection Customer { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/log.cs b/LoggingClient/LoggingClient/Model/log.cs new file mode 100644 index 0000000..f334eda --- /dev/null +++ b/LoggingClient/LoggingClient/Model/log.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class log + { + public long log_id { get; set; } + public long device_fk { get; set; } + public System.DateTime timestamp { get; set; } + public string logmessage { get; set; } + public string level { get; set; } + public Nullable is_acknowledged { get; set; } + + public virtual device device { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/network.cs b/LoggingClient/LoggingClient/Model/network.cs new file mode 100644 index 0000000..3df85d5 --- /dev/null +++ b/LoggingClient/LoggingClient/Model/network.cs @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class network + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public network() + { + this.@interface = new HashSet<@interface>(); + } + + public int network_id { get; set; } + public string subnet { get; set; } + public string mask { get; set; } + public int vlan { get; set; } + public string description { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection<@interface> @interface { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/operatingsystem.cs b/LoggingClient/LoggingClient/Model/operatingsystem.cs new file mode 100644 index 0000000..c9692ba --- /dev/null +++ b/LoggingClient/LoggingClient/Model/operatingsystem.cs @@ -0,0 +1,31 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class operatingsystem + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public operatingsystem() + { + this.devicetype = new HashSet(); + } + + public long operatingsystem_id { get; set; } + public string operatingsystemname { get; set; } + public string model { get; set; } + public string version { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection devicetype { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/person.cs b/LoggingClient/LoggingClient/Model/person.cs new file mode 100644 index 0000000..ef43c7d --- /dev/null +++ b/LoggingClient/LoggingClient/Model/person.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class person + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public person() + { + this.contact = new HashSet(); + } + + public long person_id { get; set; } + public string firstname { get; set; } + public string lastname { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection contact { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/pointofdelivery.cs b/LoggingClient/LoggingClient/Model/pointofdelivery.cs new file mode 100644 index 0000000..6f9828e --- /dev/null +++ b/LoggingClient/LoggingClient/Model/pointofdelivery.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class pointofdelivery + { + public long pod_id { get; set; } + public long customer_id_fk { get; set; } + public long contact_id_fk { get; set; } + public long location_fk { get; set; } + public string designation { get; set; } + public System.TimeSpan timezone { get; set; } + public short timezonepositiv { get; set; } + public string ntpserverip { get; set; } + + public virtual contact contact { get; set; } + public virtual Customer Customer { get; set; } + public virtual Location Location { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/produkte.cs b/LoggingClient/LoggingClient/Model/produkte.cs new file mode 100644 index 0000000..4bcc7bf --- /dev/null +++ b/LoggingClient/LoggingClient/Model/produkte.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class produkte + { + public int artikelnummer_id { get; set; } + public string artikelname { get; set; } + public decimal preis { get; set; } + public int produktegruppe_fk { get; set; } + + public virtual produktegruppe produktegruppe { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/produktegruppe.cs b/LoggingClient/LoggingClient/Model/produktegruppe.cs new file mode 100644 index 0000000..0b7de29 --- /dev/null +++ b/LoggingClient/LoggingClient/Model/produktegruppe.cs @@ -0,0 +1,33 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class produktegruppe + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public produktegruppe() + { + this.produkte = new HashSet(); + } + + public int produktegruppe_id { get; set; } + public string hardware { get; set; } + public string software { get; set; } + public string sonstigeartikel { get; set; } + public long abrechung_fk { get; set; } + + public virtual abrechnung abrechnung { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection produkte { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/softwaredienstleistung.cs b/LoggingClient/LoggingClient/Model/softwaredienstleistung.cs new file mode 100644 index 0000000..e916da4 --- /dev/null +++ b/LoggingClient/LoggingClient/Model/softwaredienstleistung.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class softwaredienstleistung + { + public int software_id { get; set; } + public int stundenaufwand { get; set; } + public long abrechung_fk { get; set; } + + public virtual abrechnung abrechnung { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/town.cs b/LoggingClient/LoggingClient/Model/town.cs new file mode 100644 index 0000000..3e11434 --- /dev/null +++ b/LoggingClient/LoggingClient/Model/town.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class town + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public town() + { + this.address = new HashSet
(); + } + + public long town_id { get; set; } + public long zip { get; set; } + public string town1 { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection
address { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/transportmedium.cs b/LoggingClient/LoggingClient/Model/transportmedium.cs new file mode 100644 index 0000000..eed50fa --- /dev/null +++ b/LoggingClient/LoggingClient/Model/transportmedium.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class transportmedium + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public transportmedium() + { + this.deviceport = new HashSet(); + } + + public long transportmedium_id { get; set; } + public string description { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection deviceport { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Model/v_logentries.cs b/LoggingClient/LoggingClient/Model/v_logentries.cs new file mode 100644 index 0000000..02557f1 --- /dev/null +++ b/LoggingClient/LoggingClient/Model/v_logentries.cs @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LoggingClient.Model +{ + using System; + using System.Collections.Generic; + + public partial class v_logentries + { + public int id { get; set; } + public string pod { get; set; } + public string location { get; set; } + public string hostname { get; set; } + public Nullable severity { get; set; } + public Nullable timestamp { get; set; } + public string message { get; set; } + } +} diff --git a/LoggingClient/LoggingClient/Repository/LocationRepository.cs b/LoggingClient/LoggingClient/Repository/LocationRepository.cs index 9998ca0..223a934 100644 --- a/LoggingClient/LoggingClient/Repository/LocationRepository.cs +++ b/LoggingClient/LoggingClient/Repository/LocationRepository.cs @@ -3,6 +3,7 @@ using MySql.Data.MySqlClient; using System; using System.Collections.Generic; using System.Windows; +using System.Linq; namespace LoggingClient.Repository { @@ -33,7 +34,7 @@ namespace LoggingClient.Repository cmd.CommandText = $"INSERT INTO {TableName} ({ColumnsForAdd}) " + $"VALUES " + - $"(parentId = {location.ParentId}, address_fk = {location.AddressId} , designation = '{location.Designation}', building = {location.BuildingNr} , room = {location.RoomNr} )"; + $"(parentId = {location.parentid}, address_fk = {location.address_fk} , designation = '{location.designation}', building = {location.building} , room = {location.room} )"; cmd.ExecuteNonQuery(); } } @@ -53,7 +54,7 @@ namespace LoggingClient.Repository conn.Open(); using (MySqlCommand cmd = conn.CreateCommand()) { - cmd.CommandText = $"DELETE FROM {TableName} WHERE location_id = {location.Id}"; + cmd.CommandText = $"DELETE FROM {TableName} WHERE location_id = {location.location_id}"; cmd.ExecuteNonQuery(); } } @@ -109,26 +110,9 @@ namespace LoggingClient.Repository { try { - using (var conn = new MySqlConnection(ConnectionString)) + using (var context = new inventarisierungsloesungEntities()) { - conn.Open(); - using (MySqlCommand cmd = conn.CreateCommand()) - { - cmd.CommandText = $"SELECT {ColumnsForSelect} FROM {TableName}"; - var reader = cmd.ExecuteReader(); - while (reader.Read()) - { - Locations.Add(new Location( - - reader.GetInt32("location_id"), - reader.GetInt32("parentId"), - reader.GetInt32("address_fk"), - reader.GetValue(reader.GetOrdinal("designation")) as string, - reader.GetInt32("building"), - reader.GetInt32("room") - )); - } - } + return context.Location.ToList(); } } catch (Exception ex) @@ -186,7 +170,7 @@ namespace LoggingClient.Repository using (MySqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = - $"UPDATE {TableName} SET address_fk = {location.Id} , designation = '{location.Designation}', building = {location.BuildingNr} , room = {location.RoomNr} WHERE location_id = {location.Id}"; + $"UPDATE {TableName} SET address_fk = {location.location_id} , designation = '{location.designation}', building = {location.building} , room = {location.room} WHERE location_id = {location.location_id}"; cmd.ExecuteNonQuery(); } } @@ -206,5 +190,28 @@ namespace LoggingClient.Repository { throw new NotImplementedException(); } + + public List GetLocationsWithCte() + { + var ctx = new inventarisierungsloesungEntities(); + var locationsList = new List(); + { + try + { + var result = ctx.Database.SqlQuery("inventarisierungsloesung.cte_locations"); + foreach (Location loc in result) + { + locationsList.Add(loc); + } + } + + catch (Exception e) + { + MessageBox.Show("Es konnte keine Verbindung zur Datenbank hergestellt werden: " + e.Message); + } + ctx.Dispose(); + return locationsList; + } + } } } \ No newline at end of file diff --git a/LoggingClient/LoggingClient/ViewModel/LocationTreeBuilder.cs b/LoggingClient/LoggingClient/ViewModel/LocationTreeBuilder.cs index 4229d79..15d63fd 100644 --- a/LoggingClient/LoggingClient/ViewModel/LocationTreeBuilder.cs +++ b/LoggingClient/LoggingClient/ViewModel/LocationTreeBuilder.cs @@ -20,7 +20,7 @@ namespace LoggingClient.ViewModel private void BuildTree(Node locationNode, List descendants) { - var children = descendants.Where(node => node.ParentId == locationNode.ValueObject.Id).ToArray(); + var children = descendants.Where(node => node.parentid == locationNode.ValueObject.location_id).ToArray(); foreach (var child in children) { var branch = Map(child, locationNode); @@ -35,7 +35,7 @@ namespace LoggingClient.ViewModel private Node FindTreeRoot(List nodes) { - var rootNodes = nodes.Where(node => node.ParentId == 0); + var rootNodes = nodes.Where(node => node.parentid == 0); if (rootNodes.Count() != 1) return new Node(); var rootNode = rootNodes.Single(); nodes.Remove(rootNode); diff --git a/LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs b/LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs index 870f35a..5cf852b 100644 --- a/LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs +++ b/LoggingClient/LoggingClient/ViewModel/LocationViewModel.cs @@ -109,7 +109,8 @@ namespace LoggingClient.ViewModel try { var locationModelRepository = new LocationRepository(TxtConnectionString); - this.Locations = locationModelRepository.GetAll(); + //this.Locations = locationModelRepository.GetAll(); + this.Locations = locationModelRepository.GetLocationsWithCte(); this.LocationTree = new List>(); GenerateLocationTreeFromList(Locations); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocationTree")); @@ -164,8 +165,6 @@ namespace LoggingClient.ViewModel { var locationModelRepository = new LocationRepository(TxtConnectionString); this.Locations = locationModelRepository.GetAll(); - this.LocationTree = new List>(); - GenerateLocationTreeFromList(Locations); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocationTree")); } catch (Exception ex) @@ -178,7 +177,8 @@ namespace LoggingClient.ViewModel { var treeBuilder = new LocationTreeBuilder(); var locationNode = treeBuilder.BuildTree(locationList); - this.LocationTree.Add(locationNode); + LocationTree = new List>(); + LocationTree.Add(locationNode); } private void OnPropertyChanged(string propertyName) diff --git a/LoggingClient/LoggingClient/Views/LocationView.xaml b/LoggingClient/LoggingClient/Views/LocationView.xaml index 70c86b0..e7792ce 100644 --- a/LoggingClient/LoggingClient/Views/LocationView.xaml +++ b/LoggingClient/LoggingClient/Views/LocationView.xaml @@ -18,18 +18,18 @@ - - - - - - + + + + + + - +