From 7f6b9165498f7117b69ed9b5d6b9149343ce582d Mon Sep 17 00:00:00 2001 From: francesco Date: Sat, 29 Aug 2020 15:47:12 +0200 Subject: [PATCH 1/5] Refactoring Repositories --- .../LoggingClient/LoggingClient.csproj | 1 - .../Repository/CustomerRepository.cs | 38 +++++--- .../Repository/LocationRepository.cs | 38 +++++--- .../Repository/LoggingRepository.cs | 79 ++++++++++++++--- .../Repository/RepositoryBase.cs | 86 ------------------- 5 files changed, 116 insertions(+), 126 deletions(-) delete mode 100644 LoggingClient/LoggingClient/Repository/RepositoryBase.cs diff --git a/LoggingClient/LoggingClient/LoggingClient.csproj b/LoggingClient/LoggingClient/LoggingClient.csproj index 7732333..27b2442 100644 --- a/LoggingClient/LoggingClient/LoggingClient.csproj +++ b/LoggingClient/LoggingClient/LoggingClient.csproj @@ -116,7 +116,6 @@ - diff --git a/LoggingClient/LoggingClient/Repository/CustomerRepository.cs b/LoggingClient/LoggingClient/Repository/CustomerRepository.cs index c2c6a78..3417855 100644 --- a/LoggingClient/LoggingClient/Repository/CustomerRepository.cs +++ b/LoggingClient/LoggingClient/Repository/CustomerRepository.cs @@ -6,44 +6,56 @@ using System.Windows; namespace LoggingClient.Repository { - public class CustomerRepository : RepositoryBase + public class CustomerRepository : IRepositoryBase { - public CustomerRepository(string connectionString) : base(connectionString) + public CustomerRepository(string connectionString) { + this.ConnectionString = connectionString; Customers = new List(); } + protected string ConnectionString { get; } - public override string TableName => "customer"; + public string TableName => "customer"; - public override string ColumnsForSelect => "customer_id, firstname, lastname, customernumber, kundenkonto_fk, tel, email, url, password"; + public string ColumnsForSelect => "customer_id, firstname, lastname, customernumber, kundenkonto_fk, tel, email, url, password"; - public override string ColumnsForAdd => "firstname, lastname, customernumber, kundenkonto_fk, tel, email, url, password"; + public string ColumnsForAdd => "firstname, lastname, customernumber, kundenkonto_fk, tel, email, url, password"; - public override string PrimaryKeyFromTable => "customer_id"; + public string PrimaryKeyFromTable => "customer_id"; public List Customers { get; set; } - public override void Add(Customer entity) + public void Add(Customer entity) { throw new System.NotImplementedException(); } - public override void CallStoredProcedure(Customer entity) + public void CallStoredProcedure(Customer entity) { throw new System.NotImplementedException(); } - public override void Delete(Customer entity) + public long Count(string whereCondition, Dictionary parameterValues) + { + throw new NotImplementedException(); + } + + public long Count() + { + throw new NotImplementedException(); + } + + public void Delete(Customer entity) { throw new System.NotImplementedException(); } - public override List GetAll(string whereCondition, Dictionary parameterValues) + public List GetAll(string whereCondition, Dictionary parameterValues) { throw new System.NotImplementedException(); } - public override List GetAll() + public List GetAll() { try { @@ -78,12 +90,12 @@ namespace LoggingClient.Repository return Customers; } - public override Customer GetSingle

(P pkValue) + public Customer GetSingle

(P pkValue) { throw new System.NotImplementedException(); } - public override void Update(Customer entity) + public void Update(Customer entity) { throw new System.NotImplementedException(); } diff --git a/LoggingClient/LoggingClient/Repository/LocationRepository.cs b/LoggingClient/LoggingClient/Repository/LocationRepository.cs index 55f1635..9998ca0 100644 --- a/LoggingClient/LoggingClient/Repository/LocationRepository.cs +++ b/LoggingClient/LoggingClient/Repository/LocationRepository.cs @@ -6,20 +6,22 @@ using System.Windows; namespace LoggingClient.Repository { - public class LocationRepository : RepositoryBase + public class LocationRepository : IRepositoryBase { - public override string TableName => "Location"; - public override string ColumnsForSelect => "location_id, parentId, address_fk, designation, building, room"; - public override string ColumnsForAdd => "parentId, address_fk, designation, building, room"; - public override string PrimaryKeyFromTable => "location_id"; + public string TableName => "Location"; + public string ColumnsForSelect => "location_id, parentId, address_fk, designation, building, room"; + public string ColumnsForAdd => "parentId, address_fk, designation, building, room"; + public string PrimaryKeyFromTable => "location_id"; public List Locations { get; set; } public Location _Locations { get; set; } - public LocationRepository(string connectionString) : base(connectionString) + protected string ConnectionString { get; } + public LocationRepository(string connectionString) { + this.ConnectionString = connectionString; Locations = new List(); } - public override void Add(Location location) + public void Add(Location location) { try { @@ -42,7 +44,7 @@ namespace LoggingClient.Repository } } - public override void Delete(Location location) + public void Delete(Location location) { try { @@ -62,7 +64,7 @@ namespace LoggingClient.Repository } } - public override List GetAll(string whereCondition, Dictionary parameterValues) + public List GetAll(string whereCondition, Dictionary parameterValues) { var whereCon = whereCondition; if (parameterValues.Count > 0 && whereCondition != null) @@ -103,7 +105,7 @@ namespace LoggingClient.Repository return Locations; } - public override List GetAll() + public List GetAll() { try { @@ -136,12 +138,12 @@ namespace LoggingClient.Repository return Locations; } - public override void CallStoredProcedure(Location entity) + public void CallStoredProcedure(Location entity) { throw new System.NotSupportedException(); } - public override Location GetSingle

(P pkValue) + public Location GetSingle

(P pkValue) { try { @@ -174,7 +176,7 @@ namespace LoggingClient.Repository return _Locations; } - public override void Update(Location location) + public void Update(Location location) { try { @@ -194,5 +196,15 @@ namespace LoggingClient.Repository MessageBox.Show("Error occurred: " + ex.Message); } } + + public long Count(string whereCondition, Dictionary parameterValues) + { + throw new NotImplementedException(); + } + + public long Count() + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/LoggingClient/LoggingClient/Repository/LoggingRepository.cs b/LoggingClient/LoggingClient/Repository/LoggingRepository.cs index 3fbedad..92756bf 100644 --- a/LoggingClient/LoggingClient/Repository/LoggingRepository.cs +++ b/LoggingClient/LoggingClient/Repository/LoggingRepository.cs @@ -12,22 +12,25 @@ using LoggingClient.Model; namespace LoggingClient.Repository { - class LoggingRepository : RepositoryBase + class LoggingRepository : IRepositoryBase { - public override string TableName => "v_logentries"; - public override string ColumnsForSelect => "id, pod, location, hostname, severity, timestamp, message"; - public override string ColumnsForAdd { get; } - public override string PrimaryKeyFromTable => "id"; + public string TableName => "v_logentries"; + public string ColumnsForSelect => "id, pod, location, hostname, severity, timestamp, message"; + public string ColumnsForAdd { get; } + public string PrimaryKeyFromTable => "id"; public List Logs { get; set; } public Logging _Logs { get; set; } - public LoggingRepository(string connectionString) : base(connectionString) + protected string ConnectionString { get; } + + public LoggingRepository(string connectionString) { + ConnectionString = connectionString; Logs = new List(); } - public override Logging GetSingle

(P pkValue) + public Logging GetSingle

(P pkValue) { try { @@ -60,7 +63,7 @@ namespace LoggingClient.Repository } return _Logs; } - public override void Add(Logging newLogModelEntry) + public void Add(Logging newLogModelEntry) { try { @@ -86,15 +89,15 @@ namespace LoggingClient.Repository MessageBox.Show("Error occurred: " + ex.Message); } } - public override void Delete(Logging entity) + public void Delete(Logging entity) { throw new System.NotSupportedException(); } - public override void Update(Logging entity) + public void Update(Logging entity) { throw new System.NotSupportedException(); } - public override List GetAll(string whereCondition, Dictionary parameterValues) + public List GetAll(string whereCondition, Dictionary parameterValues) { var whereCon = whereCondition; if (parameterValues.Count > 0 && whereCondition != null) @@ -135,7 +138,7 @@ namespace LoggingClient.Repository } return Logs; } - public override List GetAll() + public List GetAll() { try { @@ -168,7 +171,7 @@ namespace LoggingClient.Repository } return Logs; } - public override void CallStoredProcedure(Logging logModelEntry) + public void CallStoredProcedure(Logging logModelEntry) { try { @@ -189,5 +192,55 @@ namespace LoggingClient.Repository MessageBox.Show(ex.ToString()); } } + + public long Count(string whereCondition, Dictionary parameterValues) + { + var whereCon = whereCondition; + if (parameterValues.Count > 0 && whereCondition != null) + { + foreach (KeyValuePair p in parameterValues) + { + whereCon = whereCon.Replace($"@{p.Key}", p.Value.ToString()); + } + } + try + { + using (var conn = new MySqlConnection(this.ConnectionString)) + { + using (var cmd = conn.CreateCommand()) + { + conn.Open(); + cmd.CommandText = $"select count(*) from {this.TableName} where {whereCon}"; + return (long)cmd.ExecuteScalar(); + } + } + } + catch (Exception ex) + { + MessageBox.Show("Error occurred: " + ex.Message); + return -1; + } + } + + public long Count() + { + try + { + using (var conn = new MySqlConnection(this.ConnectionString)) + { + using (var cmd = conn.CreateCommand()) + { + conn.Open(); + cmd.CommandText = $"select count(*) from {this.TableName}"; + return (long)cmd.ExecuteScalar(); + } + } + } + catch (Exception ex) + { + MessageBox.Show("Error occurred: " + ex.Message); + return -1; + } + } } } \ No newline at end of file diff --git a/LoggingClient/LoggingClient/Repository/RepositoryBase.cs b/LoggingClient/LoggingClient/Repository/RepositoryBase.cs deleted file mode 100644 index f2289f9..0000000 --- a/LoggingClient/LoggingClient/Repository/RepositoryBase.cs +++ /dev/null @@ -1,86 +0,0 @@ -using MySql.Data.MySqlClient; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows; - -namespace LoggingClient.Repository -{ - public abstract class RepositoryBase : IRepositoryBase - { - protected RepositoryBase(string connectionString) - { - this.ConnectionString = connectionString; - } - protected string ConnectionString { get; } - public abstract M GetSingle

(P pkValue); - - public abstract void Add(M entity); - - public abstract void Delete(M entity); - - public abstract void Update(M entity); - public abstract List GetAll(string whereCondition, Dictionary parameterValues); - - public abstract List GetAll(); - - public abstract void CallStoredProcedure(M entity); - - public IQueryable Query(string whereCondition, Dictionary parameterValues) - { - throw new System.NotSupportedException(); - } - public long Count(string whereCondition, Dictionary parameterValues) - { - var whereCon = whereCondition; - if (parameterValues.Count > 0 && whereCondition != null) - { - foreach (KeyValuePair p in parameterValues) - { - whereCon = whereCon.Replace($"@{p.Key}", p.Value.ToString()); - } - } - try - { - using (var conn = new MySqlConnection(this.ConnectionString)) - { - using (var cmd = conn.CreateCommand()) - { - conn.Open(); - cmd.CommandText = $"select count(*) from {this.TableName} where {whereCon}"; - return (long)cmd.ExecuteScalar(); - } - } - } - catch (Exception ex) - { - MessageBox.Show("Error occurred: " + ex.Message); - return -1; - } - } - public long Count() - { - try - { - using (var conn = new MySqlConnection(this.ConnectionString)) - { - using (var cmd = conn.CreateCommand()) - { - conn.Open(); - cmd.CommandText = $"select count(*) from {this.TableName}"; - return (long)cmd.ExecuteScalar(); - } - } - } - catch (Exception ex) - { - MessageBox.Show("Error occurred: " + ex.Message); - return -1; - } - } - public abstract string TableName { get; } - public abstract string ColumnsForSelect { get; } - public abstract string ColumnsForAdd { get; } - public abstract string PrimaryKeyFromTable { get; } - } -} \ No newline at end of file From 09b34c0a14d59f40dc865ba98e991a83419ae6d9 Mon Sep 17 00:00:00 2001 From: francesco Date: Sat, 29 Aug 2020 22:33:50 +0200 Subject: [PATCH 2/5] 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 @@ - - - - - - + + + + + + - + From 67010177f0bb8f3e00c320ff846b21927ce9343d Mon Sep 17 00:00:00 2001 From: francesco Date: Sun, 30 Aug 2020 14:08:03 +0200 Subject: [PATCH 3/5] Renaming Komponenten umbenannt --- LoggingClient/LoggingClient/LoggingClient.csproj | 13 +++++++++++++ LoggingClient/LoggingClient/MainWindow.xaml.cs | 2 +- .../LoggingClient/Repository/LocationRepository.cs | 2 +- .../LoggingClient/ViewModel/Commands/BaseCommand.cs | 6 +----- .../LoggingClient/ViewModel/NavigationViewModel.cs | 7 ++++--- LoggingClient/LoggingClient/packages.config | 4 ++++ 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/LoggingClient/LoggingClient/LoggingClient.csproj b/LoggingClient/LoggingClient/LoggingClient.csproj index 582f905..cd4372b 100644 --- a/LoggingClient/LoggingClient/LoggingClient.csproj +++ b/LoggingClient/LoggingClient/LoggingClient.csproj @@ -38,6 +38,9 @@ + + ..\packages\Autofac.5.2.0\lib\net461\Autofac.dll + ..\packages\BouncyCastle.1.8.3.1\lib\BouncyCastle.Crypto.dll @@ -53,11 +56,15 @@ ..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll + + ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + ..\packages\MySql.Data.8.0.16\lib\net452\MySql.Data.dll + @@ -66,8 +73,14 @@ + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + diff --git a/LoggingClient/LoggingClient/MainWindow.xaml.cs b/LoggingClient/LoggingClient/MainWindow.xaml.cs index 1905dfe..e6f56ce 100644 --- a/LoggingClient/LoggingClient/MainWindow.xaml.cs +++ b/LoggingClient/LoggingClient/MainWindow.xaml.cs @@ -1,5 +1,5 @@ using System.Windows; -using WpfControlNugget.ViewModel; +using LoggingClient.ViewModel; namespace LoggingClient { diff --git a/LoggingClient/LoggingClient/Repository/LocationRepository.cs b/LoggingClient/LoggingClient/Repository/LocationRepository.cs index 223a934..2acc3c9 100644 --- a/LoggingClient/LoggingClient/Repository/LocationRepository.cs +++ b/LoggingClient/LoggingClient/Repository/LocationRepository.cs @@ -207,7 +207,7 @@ namespace LoggingClient.Repository catch (Exception e) { - MessageBox.Show("Es konnte keine Verbindung zur Datenbank hergestellt werden: " + e.Message); + MessageBox.Show("Error occurred: " + e.Message); } ctx.Dispose(); return locationsList; diff --git a/LoggingClient/LoggingClient/ViewModel/Commands/BaseCommand.cs b/LoggingClient/LoggingClient/ViewModel/Commands/BaseCommand.cs index e394e5c..ac6cc2e 100644 --- a/LoggingClient/LoggingClient/ViewModel/Commands/BaseCommand.cs +++ b/LoggingClient/LoggingClient/ViewModel/Commands/BaseCommand.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Input; -namespace WpfControlNugget.ViewModel.Commands +namespace LoggingClient.ViewModel.Commands { public class BaseCommand : ICommand { diff --git a/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs b/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs index d2e4855..830c2c1 100644 --- a/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs +++ b/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs @@ -1,9 +1,10 @@ -using LoggingClient.ViewModel; +using LoggingClient.Repository; +using LoggingClient.ViewModel.Commands; +using System; using System.ComponentModel; using System.Windows.Input; -using WpfControlNugget.ViewModel.Commands; -namespace WpfControlNugget.ViewModel +namespace LoggingClient.ViewModel { class NavigationViewModel : INotifyPropertyChanged { diff --git a/LoggingClient/LoggingClient/packages.config b/LoggingClient/LoggingClient/packages.config index a3e76e1..09e7a8f 100644 --- a/LoggingClient/LoggingClient/packages.config +++ b/LoggingClient/LoggingClient/packages.config @@ -1,7 +1,11 @@  + + + + \ No newline at end of file From 11d8ac7ba14b319659f21be7d57b0af0efa1ddf0 Mon Sep 17 00:00:00 2001 From: francesco Date: Wed, 16 Sep 2020 14:56:25 +0200 Subject: [PATCH 4/5] Minor Changes Namespaces, Whitespace --- LoggingClient/LoggingClient/App.xaml.cs | 2 +- LoggingClient/LoggingClient/Views/LocationView.xaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LoggingClient/LoggingClient/App.xaml.cs b/LoggingClient/LoggingClient/App.xaml.cs index 87019bc..7c1519a 100644 --- a/LoggingClient/LoggingClient/App.xaml.cs +++ b/LoggingClient/LoggingClient/App.xaml.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Threading.Tasks; using System.Windows; -namespace WpfControlNugget +namespace LoggingClient { /// /// Interaction logic for App.xaml diff --git a/LoggingClient/LoggingClient/Views/LocationView.xaml b/LoggingClient/LoggingClient/Views/LocationView.xaml index e7792ce..0e89e05 100644 --- a/LoggingClient/LoggingClient/Views/LocationView.xaml +++ b/LoggingClient/LoggingClient/Views/LocationView.xaml @@ -29,7 +29,7 @@ - + From 0f743122c16edde504d8e15de176e3bb5c01cde3 Mon Sep 17 00:00:00 2001 From: francesco Date: Wed, 16 Sep 2020 17:52:27 +0200 Subject: [PATCH 5/5] Implementing IoC for ViewModel --- .../LoggingClient/Container/Builder.cs | 31 +++++++++++++++++++ .../LoggingClient/LoggingClient.csproj | 1 + .../LoggingClient/MainWindow.xaml.cs | 14 +++++---- .../Repository/CustomerRepositoryEF.cs | 2 +- .../ViewModel/NavigationViewModel.cs | 14 +++++---- 5 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 LoggingClient/LoggingClient/Container/Builder.cs diff --git a/LoggingClient/LoggingClient/Container/Builder.cs b/LoggingClient/LoggingClient/Container/Builder.cs new file mode 100644 index 0000000..285a2e6 --- /dev/null +++ b/LoggingClient/LoggingClient/Container/Builder.cs @@ -0,0 +1,31 @@ +using Autofac; +using LoggingClient.Model; +using LoggingClient.Repository; +using LoggingClient.ViewModel; + +namespace LoggingClient.Container +{ + public class Builder + { + public static IContainer BuildAutofacContainer() + { + var builder = new ContainerBuilder(); + + // ViewModel + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterType().As(); + builder.RegisterType().As(); + + + // Repositories + builder.RegisterType().As>(); + builder.RegisterType().As>(); + builder.RegisterType().As>(); + builder.RegisterType().As>(); + builder.RegisterType().As>(); + + return builder.Build(); + } + } +} diff --git a/LoggingClient/LoggingClient/LoggingClient.csproj b/LoggingClient/LoggingClient/LoggingClient.csproj index cd4372b..be7aa1c 100644 --- a/LoggingClient/LoggingClient/LoggingClient.csproj +++ b/LoggingClient/LoggingClient/LoggingClient.csproj @@ -100,6 +100,7 @@ MSBuild:Compile Designer + Inventar.tt diff --git a/LoggingClient/LoggingClient/MainWindow.xaml.cs b/LoggingClient/LoggingClient/MainWindow.xaml.cs index e6f56ce..dd8d708 100644 --- a/LoggingClient/LoggingClient/MainWindow.xaml.cs +++ b/LoggingClient/LoggingClient/MainWindow.xaml.cs @@ -1,4 +1,4 @@ -using System.Windows; +using System.Windows; using LoggingClient.ViewModel; namespace LoggingClient @@ -6,12 +6,14 @@ namespace LoggingClient /// /// Interaction logic for MainWindow.xaml /// - public partial class MainWindow : Window - { + public partial class MainWindow : Window + { public MainWindow() { InitializeComponent(); - this.DataContext = new NavigationViewModel(); - } - } + //Container = Builder.BuildAutofacContainer(); + //DataContext = Container.Resolve(); + DataContext = new NavigationViewModel(); + } + } } \ No newline at end of file diff --git a/LoggingClient/LoggingClient/Repository/CustomerRepositoryEF.cs b/LoggingClient/LoggingClient/Repository/CustomerRepositoryEF.cs index a78b8f6..348f671 100644 --- a/LoggingClient/LoggingClient/Repository/CustomerRepositoryEF.cs +++ b/LoggingClient/LoggingClient/Repository/CustomerRepositoryEF.cs @@ -6,7 +6,7 @@ using System.Linq; namespace LoggingClient.Repository { - public class CustomerRepositoryEF + public class CustomerRepositoryEF : IRepositoryBase { public CustomerRepositoryEF() { diff --git a/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs b/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs index 830c2c1..c2c3876 100644 --- a/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs +++ b/LoggingClient/LoggingClient/ViewModel/NavigationViewModel.cs @@ -1,8 +1,9 @@ -using LoggingClient.Repository; +using LoggingClient.Container; using LoggingClient.ViewModel.Commands; -using System; using System.ComponentModel; using System.Windows.Input; +using Autofac; +using IContainer = Autofac.IContainer; namespace LoggingClient.ViewModel { @@ -18,26 +19,27 @@ namespace LoggingClient.ViewModel get => _selectedViewModel; set { _selectedViewModel = value; OnPropertyChanged("SelectedViewModel"); } } - + private IContainer container; public NavigationViewModel() { LogsCommand = new BaseCommand(OpenLogs); LocationsCommand = new BaseCommand(OpenLocations); CustomersCommand = new BaseCommand(OpenCustomers); + container = Builder.BuildAutofacContainer(); } private void OpenLogs(object obj) { - SelectedViewModel = new LogViewModel(); + SelectedViewModel = container.Resolve(); } private void OpenLocations(object obj) { - SelectedViewModel = new LocationViewModel(); + SelectedViewModel = container.Resolve(); } private void OpenCustomers(object obj) { - SelectedViewModel = new CustomerViewModel(); + SelectedViewModel = container.Resolve(); } public event PropertyChangedEventHandler PropertyChanged;