Call CTE in a StoredProcedure with EF

Add All Models in DB and Updated Components to match ID of the impoted Tables
This commit is contained in:
francesco 2020-08-29 22:33:50 +02:00
parent 7f6b916549
commit 09b34c0a14
31 changed files with 2378 additions and 120 deletions

View File

@ -87,10 +87,34 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Model\abrechnung.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\address.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\contact.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\credentials.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\Customer.cs"> <Compile Include="Model\Customer.cs">
<DependentUpon>Inventar.tt</DependentUpon> <DependentUpon>Inventar.tt</DependentUpon>
</Compile> </Compile>
<Compile Include="Model\CustomerLinq.cs" /> <Compile Include="Model\CustomerLinq.cs" />
<Compile Include="Model\device.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\deviceport.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\devicetype.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\interface.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\Inventar.Context.cs"> <Compile Include="Model\Inventar.Context.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
@ -106,10 +130,48 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Inventar.edmx</DependentUpon> <DependentUpon>Inventar.edmx</DependentUpon>
</Compile> </Compile>
<Compile Include="Model\kundenkonto.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\log.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\Model.cs" /> <Compile Include="Model\Model.cs" />
<Compile Include="Model\Location.cs" /> <Compile Include="Model\Location.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\network.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\Node.cs" /> <Compile Include="Model\Node.cs" />
<Compile Include="Model\operatingsystem.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\person.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\pointofdelivery.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\produkte.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\produktegruppe.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\SeverityComboBoxItem.cs" /> <Compile Include="Model\SeverityComboBoxItem.cs" />
<Compile Include="Model\softwaredienstleistung.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\town.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\transportmedium.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Model\v_logentries.cs">
<DependentUpon>Inventar.tt</DependentUpon>
</Compile>
<Compile Include="Repository\CustomerRepository.cs" /> <Compile Include="Repository\CustomerRepository.cs" />
<Compile Include="Repository\CustomerRepositoryEF.cs" /> <Compile Include="Repository\CustomerRepositoryEF.cs" />
<Compile Include="Repository\CustomerRepositoryLinq.cs" /> <Compile Include="Repository\CustomerRepositoryLinq.cs" />

View File

@ -9,8 +9,17 @@
namespace LoggingClient.Model namespace LoggingClient.Model
{ {
using System;
using System.Collections.Generic;
public partial class Customer public partial class Customer
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Customer()
{
this.pointofdelivery = new HashSet<pointofdelivery>();
}
public long customer_id { get; set; } public long customer_id { get; set; }
public string firstname { get; set; } public string firstname { get; set; }
public string lastname { get; set; } public string lastname { get; set; }
@ -20,8 +29,10 @@ namespace LoggingClient.Model
public string email { get; set; } public string email { get; set; }
public string url { get; set; } public string url { get; set; }
public string password { 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> pointofdelivery { get; set; }
public Customer(long Id, string FirstName, string LastName, string CustomerNumber, long Customer_fk, string PhoneNumber, string EMail, string URL, string Password) 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.url = URL;
this.password = Password; this.password = Password;
} }
}
}
} }

View File

@ -11,6 +11,7 @@ namespace LoggingClient.Model
{ {
using System; using System;
using System.Data.Entity; using System.Data.Entity;
using System.Data.Entity.Core.Objects;
using System.Data.Entity.Infrastructure; using System.Data.Entity.Infrastructure;
public partial class inventarisierungsloesungEntities : DbContext public partial class inventarisierungsloesungEntities : DbContext
@ -26,5 +27,26 @@ namespace LoggingClient.Model
} }
public virtual DbSet<Customer> Customer { get; set; } public virtual DbSet<Customer> Customer { get; set; }
public virtual DbSet<abrechnung> abrechnung { get; set; }
public virtual DbSet<address> address { get; set; }
public virtual DbSet<contact> contact { get; set; }
public virtual DbSet<credentials> credentials { get; set; }
public virtual DbSet<device> device { get; set; }
public virtual DbSet<deviceport> deviceport { get; set; }
public virtual DbSet<devicetype> devicetype { get; set; }
public virtual DbSet<@interface> @interface { get; set; }
public virtual DbSet<kundenkonto> kundenkonto { get; set; }
public virtual DbSet<Location> Location { get; set; }
public virtual DbSet<log> log { get; set; }
public virtual DbSet<network> network { get; set; }
public virtual DbSet<operatingsystem> operatingsystem { get; set; }
public virtual DbSet<person> person { get; set; }
public virtual DbSet<pointofdelivery> pointofdelivery { get; set; }
public virtual DbSet<produkte> produkte { get; set; }
public virtual DbSet<produktegruppe> produktegruppe { get; set; }
public virtual DbSet<softwaredienstleistung> softwaredienstleistung { get; set; }
public virtual DbSet<town> town { get; set; }
public virtual DbSet<transportmedium> transportmedium { get; set; }
public virtual DbSet<v_logentries> v_logentries { get; set; }
} }
} }

View File

@ -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 // 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 // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model
// is open in the designer. // is open in the designer.

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,51 @@
<!-- Diagram content (shape and connector positions) --> <!-- Diagram content (shape and connector positions) -->
<edmx:Diagrams> <edmx:Diagrams>
<Diagram DiagramId="551c3bcd88d246f39b2988233805b98e" Name="Diagram1"> <Diagram DiagramId="551c3bcd88d246f39b2988233805b98e" Name="Diagram1">
<EntityTypeShape EntityType="inventarisierungsloesungModel.Customer" Width="1.5" PointX="0.75" PointY="0.75" IsExpanded="true" /> <EntityTypeShape EntityType="inventarisierungsloesungModel.Customer" PointX="0.75" PointY="0.75" Width="1.5" IsExpanded="true" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.abrechnung" Width="1.5" PointX="10.125" PointY="6.25" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.address" Width="1.5" PointX="3.375" PointY="6.75" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.contact" Width="1.5" PointX="5.625" PointY="14.125" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.credentials" Width="1.5" PointX="10.125" PointY="22.25" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.device" Width="1.5" PointX="7.875" PointY="10.125" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.deviceport" Width="1.5" PointX="13.125" PointY="11" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.devicetype" Width="1.5" PointX="5.625" PointY="11" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.interface" Width="1.5" PointX="10.125" PointY="10.375" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.kundenkonto" Width="1.5" PointX="0.75" PointY="1.5" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.Location" Width="1.5" PointX="5.625" PointY="6.625" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.log" Width="1.5" PointX="10.125" PointY="24.875" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.network" Width="1.5" PointX="7.875" PointY="7" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.operatingsystem" Width="1.5" PointX="7.875" PointY="17" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.person" Width="1.5" PointX="3.375" PointY="14.25" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.pointofdelivery" Width="1.5" PointX="7.875" PointY="2.625" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.produkte" Width="1.5" PointX="14.625" PointY="5.5" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.produktegruppe" Width="1.5" PointX="12.375" PointY="5.375" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.softwaredienstleistung" Width="1.5" PointX="12.375" PointY="8.5" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.town" Width="1.5" PointX="3.375" PointY="11.25" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.transportmedium" Width="1.5" PointX="10.875" PointY="15.25" />
<EntityTypeShape EntityType="inventarisierungsloesungModel.v_logentries" Width="1.5" PointX="10.625" PointY="0.75" />
<AssociationConnector Association="inventarisierungsloesungModel.abrechnung_abrechnung_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.abrechnung_abrechnung_ibfk_2" />
<AssociationConnector Association="inventarisierungsloesungModel.abrechnung_abrechnung_ibfk_3" />
<AssociationConnector Association="inventarisierungsloesungModel.abrechnung_abrechnung_ibfk_4" />
<AssociationConnector Association="inventarisierungsloesungModel.produktegruppe_produktegruppe_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.softwaredienstleistung_softwaredienstleistung_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.address_address_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.location_location_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.contact_contact_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.pointofdelivery_pointofdelivery_ibfk_2" />
<AssociationConnector Association="inventarisierungsloesungModel.customer_customer_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.pointofdelivery_pointofdelivery_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.device_device_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.device_device_ibfk_2" />
<AssociationConnector Association="inventarisierungsloesungModel.deviceport_deviceport_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.interface_interface_ibfk_2" />
<AssociationConnector Association="inventarisierungsloesungModel.log_log_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.deviceport_deviceport_ibfk_2" />
<AssociationConnector Association="inventarisierungsloesungModel.interface_interface_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.pointofdelivery_pointofdelivery_ibfk_3" />
<AssociationConnector Association="inventarisierungsloesungModel.produkte_produkte_ibfk_1" />
<AssociationConnector Association="inventarisierungsloesungModel.devices_has_credentials" />
<AssociationConnector Association="inventarisierungsloesungModel.devicetype_has_operatingsystem" />
</Diagram> </Diagram>
</edmx:Diagrams> </edmx:Diagrams>
</edmx:Designer> </edmx:Designer>

View File

@ -1,79 +1,52 @@
using System; //------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
namespace LoggingClient.Model namespace LoggingClient.Model
{ {
public class Location : Model<Location> using System;
using System.Collections.Generic;
public partial class Location
{ {
public new int Id { get; set; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
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; }
public Location() public Location()
{ {
this.abrechnung = new HashSet<abrechnung>();
this.device = new HashSet<device>();
this.pointofdelivery = new HashSet<pointofdelivery>();
} }
public Location(int id, int parentId, int addressId, string designation, int buildingNr, int roomNr) public Location(int id, int parentId, int addressId, string designation, int buildingNr, int roomNr)
{ {
this.Id = id; this.location_id = id;
this.ParentId = parentId; this.parentid = parentId;
this.AddressId = addressId; this.address_fk = addressId;
this.Designation = designation; this.designation = designation;
this.BuildingNr = buildingNr; this.building = buildingNr;
this.RoomNr = roomNr; this.room = 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));
} }
public static bool operator !=(Location locA, Location locB) public long location_id { get; set; }
{ public Nullable<long> parentid { get; set; }
return !(locA == locB); 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> abrechnung { get; set; }
public virtual address address { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<device> device { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<pointofdelivery> pointofdelivery { get; set; }
public override string ToString()
{
return Designation;
}
} }
} }

View File

@ -0,0 +1,39 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<produktegruppe>();
this.softwaredienstleistung = new HashSet<softwaredienstleistung>();
}
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> produktegruppe { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<softwaredienstleistung> softwaredienstleistung { get; set; }
}
}

View File

@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<Location>();
}
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<long> po_box { get; set; }
public virtual town town { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Location> Location { get; set; }
}
}

View File

@ -0,0 +1,31 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<pointofdelivery>();
}
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> pointofdelivery { get; set; }
}
}

View File

@ -0,0 +1,31 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<device>();
}
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> device { get; set; }
}
}

View File

@ -0,0 +1,49 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<abrechnung>();
this.deviceport = new HashSet<deviceport>();
this.@interface = new HashSet<@interface>();
this.log = new HashSet<log>();
this.credentials = new HashSet<credentials>();
}
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> 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> 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> log { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<credentials> credentials { get; set; }
}
}

View File

@ -0,0 +1,25 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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; }
}
}

View File

@ -0,0 +1,34 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<device>();
this.operatingsystem = new HashSet<operatingsystem>();
}
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> device { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<operatingsystem> operatingsystem { get; set; }
}
}

View File

@ -0,0 +1,38 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<abrechnung>();
}
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<int> bandwith { get; set; }
public Nullable<short> is_in_use { get; set; }
public string description { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<abrechnung> abrechnung { get; set; }
public virtual device device { get; set; }
public virtual network network { get; set; }
}
}

View File

@ -0,0 +1,31 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<abrechnung>();
this.Customer = new HashSet<Customer>();
}
public long kundenkonto_id { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<abrechnung> abrechnung { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Customer> Customer { get; set; }
}
}

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<short> is_acknowledged { get; set; }
public virtual device device { get; set; }
}
}

View File

@ -0,0 +1,32 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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; }
}
}

View File

@ -0,0 +1,31 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<devicetype>();
}
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> devicetype { get; set; }
}
}

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<contact>();
}
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> contact { get; set; }
}
}

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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; }
}
}

View File

@ -0,0 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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; }
}
}

View File

@ -0,0 +1,33 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<produkte>();
}
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> produkte { get; set; }
}
}

View File

@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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; }
}
}

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<address>();
}
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> address { get; set; }
}
}

View File

@ -0,0 +1,29 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<deviceport>();
}
public long transportmedium_id { get; set; }
public string description { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<deviceport> deviceport { get; set; }
}
}

View File

@ -0,0 +1,25 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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<int> severity { get; set; }
public Nullable<System.DateTime> timestamp { get; set; }
public string message { get; set; }
}
}

View File

@ -3,6 +3,7 @@ using MySql.Data.MySqlClient;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows; using System.Windows;
using System.Linq;
namespace LoggingClient.Repository namespace LoggingClient.Repository
{ {
@ -33,7 +34,7 @@ namespace LoggingClient.Repository
cmd.CommandText = cmd.CommandText =
$"INSERT INTO {TableName} ({ColumnsForAdd}) " + $"INSERT INTO {TableName} ({ColumnsForAdd}) " +
$"VALUES " + $"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(); cmd.ExecuteNonQuery();
} }
} }
@ -53,7 +54,7 @@ namespace LoggingClient.Repository
conn.Open(); conn.Open();
using (MySqlCommand cmd = conn.CreateCommand()) 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(); cmd.ExecuteNonQuery();
} }
} }
@ -109,26 +110,9 @@ namespace LoggingClient.Repository
{ {
try try
{ {
using (var conn = new MySqlConnection(ConnectionString)) using (var context = new inventarisierungsloesungEntities())
{ {
conn.Open(); return context.Location.ToList();
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")
));
}
}
} }
} }
catch (Exception ex) catch (Exception ex)
@ -186,7 +170,7 @@ namespace LoggingClient.Repository
using (MySqlCommand cmd = conn.CreateCommand()) using (MySqlCommand cmd = conn.CreateCommand())
{ {
cmd.CommandText = 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(); cmd.ExecuteNonQuery();
} }
} }
@ -206,5 +190,28 @@ namespace LoggingClient.Repository
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public List<Location> GetLocationsWithCte()
{
var ctx = new inventarisierungsloesungEntities();
var locationsList = new List<Location>();
{
try
{
var result = ctx.Database.SqlQuery<Location>("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;
}
}
} }
} }

View File

@ -20,7 +20,7 @@ namespace LoggingClient.ViewModel
private void BuildTree(Node<Location> locationNode, List<Location> descendants) private void BuildTree(Node<Location> locationNode, List<Location> 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) foreach (var child in children)
{ {
var branch = Map(child, locationNode); var branch = Map(child, locationNode);
@ -35,7 +35,7 @@ namespace LoggingClient.ViewModel
private Node<Location> FindTreeRoot(List<Location> nodes) private Node<Location> FindTreeRoot(List<Location> nodes)
{ {
var rootNodes = nodes.Where(node => node.ParentId == 0); var rootNodes = nodes.Where(node => node.parentid == 0);
if (rootNodes.Count() != 1) return new Node<Location>(); if (rootNodes.Count() != 1) return new Node<Location>();
var rootNode = rootNodes.Single(); var rootNode = rootNodes.Single();
nodes.Remove(rootNode); nodes.Remove(rootNode);

View File

@ -109,7 +109,8 @@ namespace LoggingClient.ViewModel
try try
{ {
var locationModelRepository = new LocationRepository(TxtConnectionString); var locationModelRepository = new LocationRepository(TxtConnectionString);
this.Locations = locationModelRepository.GetAll(); //this.Locations = locationModelRepository.GetAll();
this.Locations = locationModelRepository.GetLocationsWithCte();
this.LocationTree = new List<Node<Location>>(); this.LocationTree = new List<Node<Location>>();
GenerateLocationTreeFromList(Locations); GenerateLocationTreeFromList(Locations);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocationTree")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocationTree"));
@ -164,8 +165,6 @@ namespace LoggingClient.ViewModel
{ {
var locationModelRepository = new LocationRepository(TxtConnectionString); var locationModelRepository = new LocationRepository(TxtConnectionString);
this.Locations = locationModelRepository.GetAll(); this.Locations = locationModelRepository.GetAll();
this.LocationTree = new List<Node<Location>>();
GenerateLocationTreeFromList(Locations);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocationTree")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LocationTree"));
} }
catch (Exception ex) catch (Exception ex)
@ -178,7 +177,8 @@ namespace LoggingClient.ViewModel
{ {
var treeBuilder = new LocationTreeBuilder(); var treeBuilder = new LocationTreeBuilder();
var locationNode = treeBuilder.BuildTree(locationList); var locationNode = treeBuilder.BuildTree(locationList);
this.LocationTree.Add(locationNode); LocationTree = new List<Node<Location>>();
LocationTree.Add(locationNode);
} }
private void OnPropertyChanged(string propertyName) private void OnPropertyChanged(string propertyName)

View File

@ -18,18 +18,18 @@
<Grid HorizontalAlignment="Left" Height="416" VerticalAlignment="Top" Width="773"> <Grid HorizontalAlignment="Left" Height="416" VerticalAlignment="Top" Width="773">
<DataGrid Validation.ErrorTemplate="{x:Null}" CanUserAddRows="False" AutoGenerateColumns="False" HorizontalAlignment="Left" SelectedItem="{Binding MySelectedItem, Mode=TwoWay}" Margin="10,196,0,76" x:Name="DataGridLocations" Width="763" ItemsSource="{Binding Path=Locations}" CanUserResizeRows="False"> <DataGrid Validation.ErrorTemplate="{x:Null}" CanUserAddRows="False" AutoGenerateColumns="False" HorizontalAlignment="Left" SelectedItem="{Binding MySelectedItem, Mode=TwoWay}" Margin="10,196,0,76" x:Name="DataGridLocations" Width="763" ItemsSource="{Binding Path=Locations}" CanUserResizeRows="False">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=Id}" Header="id" Width="1*" IsReadOnly="True" /> <DataGridTextColumn Binding="{Binding Path=location_id}" Header="id" Width="1*" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Path=ParentId}" Header="ParentId" Width="1*" IsReadOnly="True" /> <DataGridTextColumn Binding="{Binding Path=parentid}" Header="ParentId" Width="1*" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Path=AddressId}" Header="AddressId" Width="1*" IsReadOnly="True" /> <DataGridTextColumn Binding="{Binding Path=address_fk}" Header="AddressId" Width="1*" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Path=Designation}" Header="Designation" Width="1*" IsReadOnly="True" /> <DataGridTextColumn Binding="{Binding Path=designation}" Header="Designation" Width="1*" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Path=BuildingNr}" Header="BuildingNr" Width="1*" IsReadOnly="True" /> <DataGridTextColumn Binding="{Binding Path=building}" Header="BuildingNr" Width="1*" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding Path=RoomNr}" Header="RoomNr" Width="1*" IsReadOnly="True" /> <DataGridTextColumn Binding="{Binding Path=room}" Header="RoomNr" Width="1*" IsReadOnly="True" />
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
<TreeView Grid.Row="0" Margin="10,51,0,225" ItemsSource="{Binding LocationTree, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=true, Mode=TwoWay}"> <TreeView Grid.Row="0" Margin="10,51,0,225" ItemsSource="{Binding LocationTree, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=true, Mode=TwoWay}">
<TreeView.ItemTemplate> <TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding ChildNodesList, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=true, Mode=TwoWay}"> <HierarchicalDataTemplate ItemsSource="{Binding ChildNodesList, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=true, Mode=TwoWay}">
<TreeViewItem Header="{Binding}"/> <TreeViewItem Header="{Binding Path=ValueObject.designation}"/>
</HierarchicalDataTemplate> </HierarchicalDataTemplate>
</TreeView.ItemTemplate> </TreeView.ItemTemplate>
</TreeView> </TreeView>