diff --git a/AICore/AICore.csproj b/AICore/AICore.csproj index 55da2ba35..7fac12497 100644 --- a/AICore/AICore.csproj +++ b/AICore/AICore.csproj @@ -48,12 +48,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/AICore/Context/Core/ContextEntryMapperFactory.cs b/AICore/Context/Core/ContextEntryMapperFactory.cs index 5001d03d0..a9174a635 100644 --- a/AICore/Context/Core/ContextEntryMapperFactory.cs +++ b/AICore/Context/Core/ContextEntryMapperFactory.cs @@ -1,11 +1,6 @@ using AICore.Context.Entry; using AICore.Context.EntryMapper; using BeWo.Data.Entities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace AICore.Context.Core { diff --git a/AICore/Context/Core/ContextSummaryFactory.cs b/AICore/Context/Core/ContextSummaryFactory.cs index 7b6a244df..277534948 100644 --- a/AICore/Context/Core/ContextSummaryFactory.cs +++ b/AICore/Context/Core/ContextSummaryFactory.cs @@ -1,86 +1,58 @@ using AICore.Context.Core; using AICore.Context.Entry; -using AICore.Context.EntryMapper; using AICore.Context.Summary; using BeWo.Data.Entities; -using System; +using BS.Shared.Exceptions; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace AICore.Context.SummaryMapper { public static class ContextSummaryFactory { - public static CustomerDetailContextSummary CreateCustomerDetailContextSummary(Customer customer) + public static DetailContextSummary CreateDetailContext(TEntity entity) + where TEntry : DetailContextEntry + where TEntity : BeWoEntityBase, new() { - var entry = ContextEntryMapperFactory.CustomerMapper.MapToNewContext(customer); + object obj = null; - return new CustomerDetailContextSummary(entry); + if (entity is Customer customer) + obj = CreateCustomerDetailContextSummary(customer); + else if (entity is Employee employee) + obj = CreateEmployeeDetailContextSummary(employee); + else if (entity is Person person) + obj = CreatePersonDetailContextSummary(person); + else if (entity is Organisation organisation) + obj = CreateOrganisationDetailContextSummary(organisation); + else if (entity is SupportConcept support) + obj = CreateSupportConceptDetailContextSummary(support); + + if (obj == null) + throw BeWoNotImplementedException.CreateFromInvalidObject(entity); + + return obj as DetailContextSummary; } - public static EmployeeDetailContextSummary CreateEmployeeDetailContextSummary(Employee employee) + public static NavigationContextSummary CreateNavigationContext(IEnumerable entities) + where TEntry : NavigationContextEntry + where TEntity : BeWoEntityBase, new() { - var entry = ContextEntryMapperFactory.EmployeeMapper.MapToNewContext(employee); + object obj = null; - return new EmployeeDetailContextSummary(entry); - } + if (entities is IEnumerable customer) + obj = CreateCustomerNavigationContextSummary(customer); + else if (entities is IEnumerable employee) + obj = CreateEmployeeNavigationContextSummary(employee); + else if (entities is IEnumerable person) + obj = CreatePersonNavigationContextSummary(person); + else if (entities is IEnumerable organisation) + obj = CreateOrganisationNavigationContextSummary(organisation); + else if (entities is IEnumerable support) + obj = CreateSupportConceptNavigationContextSummary(support); - public static PersonDetailContextSummary CreatePersonDetailContextSummary(Person person) - { - var entry = ContextEntryMapperFactory.PersonMapper.MapToNewContext(person); + if (obj == null) + throw BeWoNotImplementedException.CreateFromInvalidObject(entities); - return new PersonDetailContextSummary(entry); - } - - public static OrganisationDetailContextSummary CreateOrganisationDetailContextSummary(Organisation organisation) - { - var entry = ContextEntryMapperFactory.OrganisationMapper.MapToNewContext(organisation); - - return new OrganisationDetailContextSummary(entry); - } - - public static SupportConceptDetailContextSummary CreateSupportConceptDetailContextSummary(SupportConcept supportConcept) - { - var entry = ContextEntryMapperFactory.SupportConceptMapper.MapToNewContext(supportConcept); - - return new SupportConceptDetailContextSummary(entry); - } - - public static CustomerNavigationContextSummary CreateCustomerNavigationContextSummary(IEnumerable customer) - { - var entry = ContextEntryMapperFactory.CustomerNavigationMapper.MapToNewContexts(customer); - - return new CustomerNavigationContextSummary(entry); - } - - public static EmployeeNavigationContextSummary CreateEmployeeNavigationContextSummary(IEnumerable employee) - { - var entry = ContextEntryMapperFactory.EmployeeNavigationMapper.MapToNewContexts(employee); - - return new EmployeeNavigationContextSummary(entry); - } - - public static PersonNavigationContextSummary CreatePersonNavigationContextSummary(IEnumerableperson) - { - var entry = ContextEntryMapperFactory.PersonNavigationMapper.MapToNewContexts(person); - - return new PersonNavigationContextSummary(entry); - } - - public static OrganisationNavigationContextSummary CreateOrganisationNavigationContextSummary(IEnumerableorganisation) - { - var entry = ContextEntryMapperFactory.OrganisationNavigationMapper.MapToNewContexts(organisation); - - return new OrganisationNavigationContextSummary(entry); - } - - public static SupportConceptNavigationContextSummary CreateSupportConceptNavigationContextSummary(IEnumerable supportConcept) - { - var entry = ContextEntryMapperFactory.SupportConceptNavigationMapper.MapToNewContexts(supportConcept); - - return new SupportConceptNavigationContextSummary(entry); + return obj as NavigationContextSummary; } public static ServiceRecordNavigationContextSummary CreateServiceRecordNavigationContextSummary(IEnumerable serviceRecords, Customer customer, string costBearer, string supportConcept) @@ -91,19 +63,74 @@ namespace AICore.Context.SummaryMapper return new ServiceRecordNavigationContextSummary(entries, customer_entry, costBearer, supportConcept); } - public class ServiceRecordNavigationContextSummary : NavigationContextSummary + private static CustomerDetailContextSummary CreateCustomerDetailContextSummary(Customer customer) { - public CustomerNavigationContextEntry Customer { get; set; } - public string CostBearer { get; set; } - public string SupportConcept { get; set; } + var entry = ContextEntryMapperFactory.CustomerMapper.MapToNewContext(customer); - public ServiceRecordNavigationContextSummary(IEnumerable serviceRecords, CustomerNavigationContextEntry customer, string costBearer, string supportConcept) - : base(serviceRecords) - { - Customer = customer; - CostBearer = costBearer; - SupportConcept = supportConcept; - } + return new CustomerDetailContextSummary(entry); + } + + private static EmployeeDetailContextSummary CreateEmployeeDetailContextSummary(Employee employee) + { + var entry = ContextEntryMapperFactory.EmployeeMapper.MapToNewContext(employee); + + return new EmployeeDetailContextSummary(entry); + } + + private static PersonDetailContextSummary CreatePersonDetailContextSummary(Person person) + { + var entry = ContextEntryMapperFactory.PersonMapper.MapToNewContext(person); + + return new PersonDetailContextSummary(entry); + } + + private static OrganisationDetailContextSummary CreateOrganisationDetailContextSummary(Organisation organisation) + { + var entry = ContextEntryMapperFactory.OrganisationMapper.MapToNewContext(organisation); + + return new OrganisationDetailContextSummary(entry); + } + + private static SupportConceptDetailContextSummary CreateSupportConceptDetailContextSummary(SupportConcept supportConcept) + { + var entry = ContextEntryMapperFactory.SupportConceptMapper.MapToNewContext(supportConcept); + + return new SupportConceptDetailContextSummary(entry); + } + + private static CustomerNavigationContextSummary CreateCustomerNavigationContextSummary(IEnumerable customer) + { + var entry = ContextEntryMapperFactory.CustomerNavigationMapper.MapToNewContexts(customer); + + return new CustomerNavigationContextSummary(entry); + } + + private static EmployeeNavigationContextSummary CreateEmployeeNavigationContextSummary(IEnumerable employee) + { + var entry = ContextEntryMapperFactory.EmployeeNavigationMapper.MapToNewContexts(employee); + + return new EmployeeNavigationContextSummary(entry); + } + + private static PersonNavigationContextSummary CreatePersonNavigationContextSummary(IEnumerable person) + { + var entry = ContextEntryMapperFactory.PersonNavigationMapper.MapToNewContexts(person); + + return new PersonNavigationContextSummary(entry); + } + + private static OrganisationNavigationContextSummary CreateOrganisationNavigationContextSummary(IEnumerable organisation) + { + var entry = ContextEntryMapperFactory.OrganisationNavigationMapper.MapToNewContexts(organisation); + + return new OrganisationNavigationContextSummary(entry); + } + + private static SupportConceptNavigationContextSummary CreateSupportConceptNavigationContextSummary(IEnumerable supportConcept) + { + var entry = ContextEntryMapperFactory.SupportConceptNavigationMapper.MapToNewContexts(supportConcept); + + return new SupportConceptNavigationContextSummary(entry); } } } diff --git a/AICore/Context/Entry/BaseContextEntry.cs b/AICore/Context/Entry/BaseContextEntry.cs index 4c45e786a..96df1d2f5 100644 --- a/AICore/Context/Entry/BaseContextEntry.cs +++ b/AICore/Context/Entry/BaseContextEntry.cs @@ -1,131 +1,7 @@ -using BeWo.Data.Entities; -using BS.Shared.DataContracts.Compact; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; - -namespace AICore.Context.Entry +namespace AICore.Context.Entry { public abstract class BaseContextEntry { } - - public abstract class DetailContextEntry : BaseContextEntry - { - - } - - public class CustomerDetailContextEntry : DetailContextEntry - { - - } - - public class EmployeeDetailContextEntry : DetailContextEntry - { - - } - - public class PersonDetailContextEntry : DetailContextEntry - { - - } - - public class OrganisationDetailContextEntry : DetailContextEntry - { - - } - - public class SupportConceptDetailContextEntry : DetailContextEntry - { - - } - - public abstract class NavigationContextEntry : BaseContextEntry - { - - } - - public class CustomerNavigationContextEntry : NavigationContextEntry - { - [JsonPropertyName("Adresse")] - public string AddressString { get; set; } - - [JsonPropertyName("Alias")] - public string CustomerAlias { get; set; } - - [JsonPropertyName("Klient-ID")] - public long CustomerOid { get; set; } - - [JsonPropertyName("Geburtstag")] - public string DateOfBirthString { get; set; } - - [JsonPropertyName("EigenkapitalBeitrag")] - public decimal EquityContribution { get; set; } - - [JsonPropertyName("Name")] - public string EquityConFullNametribution { get; set; } - - [JsonPropertyName("Rechnungsadresse")] - public string InvoiceAddressString { get; set; } - } - public class EmployeeNavigationContextEntry : NavigationContextEntry { - [JsonPropertyName("Mitarbeiter-ID")] - public long EmployeeOid { get; set; } - - [JsonPropertyName("Personalnummer")] - public string PersonnelNumber { get; set; } - - [JsonPropertyName("Name")] - public string FirstNameLastName { get; set; } - } - public class PersonNavigationContextEntry : NavigationContextEntry { - public string AddressString { get; set; } - public DateTime Birthday { get; set; } - public long CustomerOid { get; set; } - public long EmployeeOid { get; set; } - public string FullName { get; set; } - public string Geschlecht { get; set; } - public string Function { get; set; } - } - public class OrganisationNavigationContextEntry : NavigationContextEntry { - public long OrganisationOid { get; set; } - public string Name { get; set; } - public string Name2 { get; set; } - public string DebitorNumber { get; set; } - public string BusinessPartnerId { get; set; } - public string AddressString { get; set; } - public string IKDatenannahmestelle { get; set; } - public string IKKostentrager { get; set; } - public string IKKrankenkasse { get; set; } - } - public class SupportConceptNavigationContextEntry : NavigationContextEntry { - public long SupportConceptOid { get; set; } - public string AddressString { get; set; } - public string AllCostBearerNames { get; set; } - public object CostBearer { get; set; } - public string CostBearerDetailStrings { get; set; } - public long CustomerOid { get; set; } - public DateTime StartDate { get; set; } - public DateTime EndDate { get; set; } - } - - public class ServiceRecordContextEntry : NavigationContextEntry - { - public string ServiceRecordOid { get; set; } - public DateTime Start { get; set; } - public DateTime End { get; set; } - public decimal DurationInStunden { get; set; } - public string CategoryName { get; set; } - public string Name { get; set; } - public string Notice { get; set; } - public decimal DistanceInMeter { get; set; } - public DateTime InsertedOn { get; set; } - public decimal Betrag { get; set; } - public object InsUser { get; set; } - public object Employee { get; set; } - } } diff --git a/AICore/Context/Entry/CustomerDetailContextEntry.cs b/AICore/Context/Entry/CustomerDetailContextEntry.cs new file mode 100644 index 000000000..810a6815e --- /dev/null +++ b/AICore/Context/Entry/CustomerDetailContextEntry.cs @@ -0,0 +1,78 @@ +using BeWo.Data.Entities; +using System; +using System.Text.Json.Serialization; + +namespace AICore.Context.Entry +{ + public class CustomerDetailContextEntry : DetailContextEntry + { + [JsonPropertyName("Klient-ID")] + public long CustomerOid { get; set; } + + [JsonPropertyName("Name")] + public string FullName { get; set; } + + [JsonPropertyName("Alias")] + public string CustomerAlias { get; set; } + + [JsonPropertyName("Geburtstag")] + public DateTime? DateOfBirth { get; set; } + + [JsonPropertyName("Geschlecht")] + public string Sex { get; set; } + + [JsonPropertyName("Nationalität")] + public string NationalitaetDisplayName { get; set; } + + [JsonPropertyName("HatMigrationshintergrund")] + public bool IsMigrant { get; set; } + + [JsonPropertyName("Migrationshintergrund")] + public string Migrationshintergrund { get; set; } + + [JsonPropertyName("Aufenthaltsstatus")] + public string AufenthaltsStatusDisplayName { get; set; } + + [JsonPropertyName("Familienstand")] + public string FamilyStatus { get; set; } + + [JsonPropertyName("Beruf")] + public string Profession { get; set; } + + [JsonPropertyName("Kinder")] + public string Childs { get; set; } + + [JsonPropertyName("Eigenbeteiligung")] + public decimal? EquityContribution { get; set; } + + [JsonPropertyName("Krankenkasse")] + public string HealthInsurance { get; set; } + + [JsonPropertyName("Versichertennummer")] + public string InsuranceNumber { get; set; } + + [JsonPropertyName("Versichertenstatus")] + public string VersichertenStatus { get; set; } + + [JsonPropertyName("Kommentar")] + public string Notice { get; set; } + + [JsonPropertyName("Adressezeile 1")] + public string AddressLine1 { get; set; } + + [JsonPropertyName("Straße")] + public string Street { get; set; } + + [JsonPropertyName("PLZ")] + public string PostalCode { get; set; } + + [JsonPropertyName("Ort")] + public string Town { get; set; } + + [JsonPropertyName("Distanz in km")] + public double? DistanceInMeter { get; set; } + + [JsonPropertyName("Rechnungsadresse")] + public string InvoiceAddress { get; set; } + } +} diff --git a/AICore/Context/Entry/CustomerNavigationContextEntry.cs b/AICore/Context/Entry/CustomerNavigationContextEntry.cs new file mode 100644 index 000000000..2ccc4e982 --- /dev/null +++ b/AICore/Context/Entry/CustomerNavigationContextEntry.cs @@ -0,0 +1,30 @@ +using BeWo.Data.Entities; +using System; +using System.Text.Json.Serialization; + +namespace AICore.Context.Entry +{ + public class CustomerNavigationContextEntry : NavigationContextEntry + { + [JsonPropertyName("Adresse")] + public string AddressString { get; set; } + + [JsonPropertyName("Alias")] + public string CustomerAlias { get; set; } + + [JsonPropertyName("Klient-ID")] + public long CustomerOid { get; set; } + + [JsonPropertyName("Geburtstag")] + public DateTime? DateOfBirth { get; set; } + + [JsonPropertyName("EigenkapitalBeitrag")] + public decimal? EquityContribution { get; set; } + + [JsonPropertyName("FullName")] + public string FullName { get; set; } + + [JsonPropertyName("Rechnungsadresse")] + public string InvoiceAddressString { get; set; } + } +} diff --git a/AICore/Context/Entry/DetailContextEntry.cs b/AICore/Context/Entry/DetailContextEntry.cs new file mode 100644 index 000000000..2b4571801 --- /dev/null +++ b/AICore/Context/Entry/DetailContextEntry.cs @@ -0,0 +1,7 @@ +namespace AICore.Context.Entry +{ + public abstract class DetailContextEntry : BaseContextEntry + { + + } +} diff --git a/AICore/Context/Entry/EmployeeDetailContextEntry.cs b/AICore/Context/Entry/EmployeeDetailContextEntry.cs new file mode 100644 index 000000000..8d6845ed5 --- /dev/null +++ b/AICore/Context/Entry/EmployeeDetailContextEntry.cs @@ -0,0 +1,9 @@ +using BeWo.Data.Entities; + +namespace AICore.Context.Entry +{ + public class EmployeeDetailContextEntry : DetailContextEntry + { + + } +} diff --git a/AICore/Context/Entry/EmployeeNavigationContextEntry.cs b/AICore/Context/Entry/EmployeeNavigationContextEntry.cs new file mode 100644 index 000000000..83af47721 --- /dev/null +++ b/AICore/Context/Entry/EmployeeNavigationContextEntry.cs @@ -0,0 +1,17 @@ +using BeWo.Data.Entities; +using System.Text.Json.Serialization; + +namespace AICore.Context.Entry +{ + public class EmployeeNavigationContextEntry : NavigationContextEntry + { + [JsonPropertyName("Mitarbeiter-ID")] + public long EmployeeOid { get; set; } + + [JsonPropertyName("Personalnummer")] + public string PersonnelNumber { get; set; } + + [JsonPropertyName("Name")] + public string FirstNameLastName { get; set; } + } +} diff --git a/AICore/Context/Entry/NavigationContextEntry.cs b/AICore/Context/Entry/NavigationContextEntry.cs new file mode 100644 index 000000000..6f23e3441 --- /dev/null +++ b/AICore/Context/Entry/NavigationContextEntry.cs @@ -0,0 +1,7 @@ +namespace AICore.Context.Entry +{ + public abstract class NavigationContextEntry : BaseContextEntry + { + + } +} diff --git a/AICore/Context/Entry/OrganisationDetailContextEntry.cs b/AICore/Context/Entry/OrganisationDetailContextEntry.cs new file mode 100644 index 000000000..942494801 --- /dev/null +++ b/AICore/Context/Entry/OrganisationDetailContextEntry.cs @@ -0,0 +1,9 @@ +using BeWo.Data.Entities; + +namespace AICore.Context.Entry +{ + public class OrganisationDetailContextEntry : DetailContextEntry + { + + } +} diff --git a/AICore/Context/Entry/OrganisationNavigationContextEntry.cs b/AICore/Context/Entry/OrganisationNavigationContextEntry.cs new file mode 100644 index 000000000..325ed3702 --- /dev/null +++ b/AICore/Context/Entry/OrganisationNavigationContextEntry.cs @@ -0,0 +1,35 @@ +using BeWo.Data.Entities; +using System.Text.Json.Serialization; + +namespace AICore.Context.Entry +{ + public class OrganisationNavigationContextEntry : NavigationContextEntry + { + [JsonPropertyName("Organisation-ID")] + public long OrganisationOid { get; set; } + + [JsonPropertyName("Name")] + public string Name { get; set; } + + [JsonPropertyName("Abteilung")] + public string Name2 { get; set; } + + [JsonPropertyName("Kundennummer")] + public string DebitorNumber { get; set; } + + [JsonPropertyName("Geschäftspartnernummer")] + public string BusinessPartnerId { get; set; } + + [JsonPropertyName("Adress")] + public string AddressString { get; set; } + + [JsonPropertyName("IKDatenannahmestelle")] + public string IKDatenannahmestelle { get; set; } + + [JsonPropertyName("IKKostentrager")] + public string IKKostentrager { get; set; } + + [JsonPropertyName("IKKrankenkasse")] + public string IKKrankenkasse { get; set; } + } +} diff --git a/AICore/Context/Entry/PersonDetailContextEntry.cs b/AICore/Context/Entry/PersonDetailContextEntry.cs new file mode 100644 index 000000000..861a178da --- /dev/null +++ b/AICore/Context/Entry/PersonDetailContextEntry.cs @@ -0,0 +1,9 @@ +using BeWo.Data.Entities; + +namespace AICore.Context.Entry +{ + public class PersonDetailContextEntry : DetailContextEntry + { + + } +} diff --git a/AICore/Context/Entry/PersonNavigationContextEntry.cs b/AICore/Context/Entry/PersonNavigationContextEntry.cs new file mode 100644 index 000000000..5ae9ad2b2 --- /dev/null +++ b/AICore/Context/Entry/PersonNavigationContextEntry.cs @@ -0,0 +1,30 @@ +using BeWo.Data.Entities; +using System; +using System.Text.Json.Serialization; + +namespace AICore.Context.Entry +{ + public class PersonNavigationContextEntry : NavigationContextEntry + { + [JsonPropertyName("Adresse")] + public string AddressString { get; set; } + + [JsonPropertyName("Geburtstag")] + public DateTime? DateOfBirth { get; set; } + + //[JsonPropertyName("Klient-ID")] + //public string CustomerOid { get; set; } + + //[JsonPropertyName("Mitarbeiter-ID")] + //public string EmployeeOid { get; set; } + + [JsonPropertyName("Name")] + public string FullName { get; set; } + + [JsonPropertyName("Geschlecht")] + public string Geschlecht { get; set; } + + [JsonPropertyName("Funktion")] + public string Function { get; set; } + } +} diff --git a/AICore/Context/Entry/ServiceRecordContextEntry.cs b/AICore/Context/Entry/ServiceRecordContextEntry.cs new file mode 100644 index 000000000..8f45b5952 --- /dev/null +++ b/AICore/Context/Entry/ServiceRecordContextEntry.cs @@ -0,0 +1,57 @@ +using BeWo.Data.Entities; +using System; +using System.Text.Json.Serialization; + +namespace AICore.Context.Entry +{ + public class ServiceRecordContextEntry : NavigationContextEntry + { + [JsonPropertyName("Zeiteintrag-ID")] + public long ServiceRecordOid { get; set; } + + [JsonPropertyName("Startdatum")] + public DateTime? Start { get; set; } + + [JsonPropertyName("Enddatum")] + public DateTime? End { get; set; } + + [JsonPropertyName("Dauer in Minuten")] + public double DurationInMinuten { get; set; } + + [JsonPropertyName("Leistungskategorie")] + public string CategoryName { get; set; } + + [JsonPropertyName("Leistungsbeschreibung")] + public string DescriptionName { get; set; } + + [JsonPropertyName("Dokumentation")] + public string Notice { get; set; } + + [JsonPropertyName("Dokumentation2")] + public string Notice2 { get; set; } + + [JsonPropertyName("Dokumentation3")] + public string Notice3 { get; set; } + + [JsonPropertyName("Dokumentation4")] + public string Notice4 { get; set; } + + [JsonPropertyName("Dokumentation5")] + public string Notice5 { get; set; } + + [JsonPropertyName("Distanze in Meter")] + public decimal? DistanceInMeter { get; set; } + + [JsonPropertyName("Eingetragen am")] + public DateTime InsertedOn { get; set; } + + [JsonPropertyName("Betrag")] + public decimal? Betrag { get; set; } + + [JsonPropertyName("Eingetragen von")] + public string InsUser { get; set; } + + [JsonPropertyName("Mitarbeiter")] + public string Employee { get; set; } + } +} diff --git a/AICore/Context/Entry/SupportConceptDetailContextEntry.cs b/AICore/Context/Entry/SupportConceptDetailContextEntry.cs new file mode 100644 index 000000000..6af458d01 --- /dev/null +++ b/AICore/Context/Entry/SupportConceptDetailContextEntry.cs @@ -0,0 +1,9 @@ +using BeWo.Data.Entities; + +namespace AICore.Context.Entry +{ + public class SupportConceptDetailContextEntry : DetailContextEntry + { + + } +} diff --git a/AICore/Context/Entry/SupportConceptNavigationContextEntry.cs b/AICore/Context/Entry/SupportConceptNavigationContextEntry.cs new file mode 100644 index 000000000..104fd4841 --- /dev/null +++ b/AICore/Context/Entry/SupportConceptNavigationContextEntry.cs @@ -0,0 +1,33 @@ +using BeWo.Data.Entities; +using System; +using System.Text.Json.Serialization; + +namespace AICore.Context.Entry +{ + public class SupportConceptNavigationContextEntry : NavigationContextEntry + { + [JsonPropertyName("Hilfeplan-ID")] + public long SupportConceptOid { get; set; } + + [JsonPropertyName("Adresse")] + public string AddressString { get; set; } + + [JsonPropertyName("Kostentraegernamen")] + public string AllCostBearerNames { get; set; } + + [JsonPropertyName("Kostentraeger")] + public string CostBearer { get; set; } + + [JsonPropertyName("Kostentraeger Details")] + public string CostBearerDetailStrings { get; set; } + + [JsonPropertyName("Klient")] + public object Customer { get; set; } // Typ ist unsicher, daher object + + [JsonPropertyName("Startdatum")] + public DateTime? StartDate { get; set; } + + [JsonPropertyName("Enddatum")] + public DateTime? EndDate { get; set; } + } +} diff --git a/AICore/Context/EntryMapper/BaseContextEntryMapper.cs b/AICore/Context/EntryMapper/BaseContextEntryMapper.cs index 5a2db03af..77141b2fe 100644 --- a/AICore/Context/EntryMapper/BaseContextEntryMapper.cs +++ b/AICore/Context/EntryMapper/BaseContextEntryMapper.cs @@ -1,7 +1,4 @@ using AICore.Context.Entry; -using BeWo.Data.Entities; -using BS.Shared.DataContracts; -using System; using System.Collections.Generic; using System.Linq; @@ -12,7 +9,11 @@ namespace AICore.Context.EntryMapper { public virtual TContext MapToNewContext(TObject pObject) { - return MergeWithObject(pObject, CreateNewContext()); + var context = CreateNewContext(); + + MergeWithObject(pObject, context); + + return context; } public virtual TContext CreateNewContext() @@ -22,125 +23,12 @@ namespace AICore.Context.EntryMapper public virtual IEnumerable MapToNewContexts(IEnumerable pObjects) { - if(pObjects is null || !pObjects.Any()) + if (pObjects is null || !pObjects.Any()) return Enumerable.Empty(); return pObjects.Select(MapToNewContext); } - public abstract TContext MergeWithObject(TObject pDataContract, TContext pContext); - } - - public class CustomerContextEntryMapper : BaseContextEntryMapper - { - public override CustomerDetailContextEntry MergeWithObject(Customer pObject, CustomerDetailContextEntry pContext) - { - throw new NotImplementedException(); - } - } - - public class EmployeeContextEntryMapper : BaseContextEntryMapper - { - public override EmployeeDetailContextEntry MergeWithObject(Employee pObject, EmployeeDetailContextEntry pContext) - { - throw new NotImplementedException(); - } - } - - public class PersonContextEntryMapper : BaseContextEntryMapper - { - public override PersonDetailContextEntry MergeWithObject(Person pObject, PersonDetailContextEntry pContext) - { - throw new NotImplementedException(); - } - } - - public class OrganisationContextEntryMapper : BaseContextEntryMapper - { - public override OrganisationDetailContextEntry MergeWithObject(Organisation pObject, OrganisationDetailContextEntry pContext) - { - throw new NotImplementedException(); - } - } - - public class SupportConceptContextEntryMapper : BaseContextEntryMapper - { - public override SupportConceptDetailContextEntry MergeWithObject(SupportConcept pObject, SupportConceptDetailContextEntry pContext) - { - throw new NotImplementedException(); - } - } - - public class CustomerNavigationContextEntryMapper : BaseContextEntryMapper - { - public override CustomerNavigationContextEntry MergeWithObject(Customer pObject, CustomerNavigationContextEntry pContext) - { - throw new NotImplementedException(); - } - } - - public class EmployeeNavigationContextEntryMapper : BaseContextEntryMapper - { - public override EmployeeNavigationContextEntry MergeWithObject(Employee pObject, EmployeeNavigationContextEntry pContext) - { - throw new NotImplementedException(); - } - } - - public class PersonNavigationContextEntryMapper : BaseContextEntryMapper - { - public override PersonNavigationContextEntry MergeWithObject(Person pObject, PersonNavigationContextEntry pContext) - { - throw new NotImplementedException(); - } - } - - public class OrganisationNavigationContextEntryMapper : BaseContextEntryMapper - { - public override OrganisationNavigationContextEntry MergeWithObject(Organisation pObject, OrganisationNavigationContextEntry pContext) - { - throw new NotImplementedException(); - } - } - - public class SupportConceptNavigationContextEntryMapper : BaseContextEntryMapper - { - public override SupportConceptNavigationContextEntry MergeWithObject(SupportConcept pObject, SupportConceptNavigationContextEntry pContext) - { - throw new NotImplementedException(); - } - } - - public class ServiceRecordContextEntryMapper : BaseContextEntryMapper - { - public override ServiceRecordContextEntry MergeWithObject(ServiceRecord pObject, ServiceRecordContextEntry pContext) - { - throw new NotImplementedException(); - } - - //public override Dictionary ToJsonDictionary(ServiceRecordDC service_record) - //{ - // var record_dict = new Dictionary - // { - // { "Zeiteintrag-ID", service_record.ServiceRecordOid}, - // { "Startdatum", service_record.Start }, - // { "Enddatum", service_record.End }, - // { "Dauer in Stunden", service_record.DurationInStunden }, - // { "Leistungskategorie", service_record.ServiceDescription.Category.Name }, - // { "Leistungsbeschreibung", service_record.ServiceDescription.Name }, - // { "Dokumentation", service_record.Notice - // + "\n" + service_record.Notice2 - // + "\n" + service_record.Notice3 - // + "\n" + service_record.Notice4 - // + "\n" + service_record.Notice5}, - // { "Distanze in Meter", service_record.DistanceInMeter ?? 0 }, - // { "Eingetragen am", service_record.InsertedOn }, - // { "Betrag", service_record.Betrag }, - // { "Eingetragen von", service_record.InsUser }, - // { "Mitarbeiter", service_record.Employee } - // }; - - // return record_dict; - //} + public abstract void MergeWithObject(TObject pDataContract, TContext pContext); } } diff --git a/AICore/Context/EntryMapper/CustomerContextEntryMapper.cs b/AICore/Context/EntryMapper/CustomerContextEntryMapper.cs new file mode 100644 index 000000000..a9ea51ecc --- /dev/null +++ b/AICore/Context/EntryMapper/CustomerContextEntryMapper.cs @@ -0,0 +1,35 @@ +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.EntryMapper +{ + public class CustomerContextEntryMapper : BaseContextEntryMapper + { + public override void MergeWithObject(Customer pObject, CustomerDetailContextEntry pContext) + { + pContext.CustomerOid = pObject.Oid ?? 0; + pContext.FullName = pObject.Person.FirstNameLastName; + pContext.CustomerAlias = pObject.CustomerAlias; + pContext.DateOfBirth = pObject.Person.DateOfBirth; + pContext.Sex = pObject.Person.Sex?.ToString() ?? "null"; + pContext.NationalitaetDisplayName = pObject.Person.Nationalitaet.Value; + pContext.IsMigrant = pObject.Person.IsMigrant; + pContext.Migrationshintergrund = pObject.Person.Migrationshintergrund; + pContext.AufenthaltsStatusDisplayName = pObject.Person.AufenthaltsStatus.Value; + pContext.FamilyStatus = pObject.Person.FamilyStatus?.ToString() ?? "null"; + pContext.Profession = pObject.Person.Profession; + pContext.Childs = pObject.Childs; + pContext.EquityContribution = pObject.EquityContribution; + pContext.HealthInsurance = pObject.HealthInsurance; + pContext.InsuranceNumber = pObject.InsuranceNumber; + pContext.VersichertenStatus = pObject.VersichertenStatus; + pContext.Notice = pObject.Notice; + pContext.AddressLine1 = pObject.Person.Address.AddressLine1; + pContext.Street = pObject.Person.Address.Street; + pContext.PostalCode = pObject.Person.Address.PostalCode; + pContext.Town = pObject.Person.Address.Town; + pContext.DistanceInMeter = pObject.DistanceInMeter; + pContext.InvoiceAddress = "---"; + } + } +} diff --git a/AICore/Context/EntryMapper/CustomerNavigationContextEntryMapper.cs b/AICore/Context/EntryMapper/CustomerNavigationContextEntryMapper.cs new file mode 100644 index 000000000..490ffb1b3 --- /dev/null +++ b/AICore/Context/EntryMapper/CustomerNavigationContextEntryMapper.cs @@ -0,0 +1,21 @@ +using System; +using System.Linq; +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.EntryMapper +{ + public class CustomerNavigationContextEntryMapper : BaseContextEntryMapper + { + public override void MergeWithObject(Customer pObject, CustomerNavigationContextEntry pContext) + { + pContext.AddressString = "---"; + pContext.CustomerAlias = pObject.CustomerAlias; + pContext.CustomerOid = pObject.Oid.Value; + pContext.DateOfBirth = pObject.Person.DateOfBirth; + pContext.EquityContribution = pObject.EquityContribution; + pContext.FullName = pObject.Person.FirstNameLastName; + pContext.InvoiceAddressString = "---"; + } + } +} diff --git a/AICore/Context/EntryMapper/EmployeeContextEntryMapper.cs b/AICore/Context/EntryMapper/EmployeeContextEntryMapper.cs new file mode 100644 index 000000000..8db6c9d37 --- /dev/null +++ b/AICore/Context/EntryMapper/EmployeeContextEntryMapper.cs @@ -0,0 +1,15 @@ +using System; +using System.Linq; +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.EntryMapper +{ + public class EmployeeContextEntryMapper : BaseContextEntryMapper + { + public override void MergeWithObject(Employee pObject, EmployeeDetailContextEntry pContext) + { + throw new NotImplementedException(); + } + } +} diff --git a/AICore/Context/EntryMapper/EmployeeNavigationContextEntryMapper.cs b/AICore/Context/EntryMapper/EmployeeNavigationContextEntryMapper.cs new file mode 100644 index 000000000..b0bf89dd8 --- /dev/null +++ b/AICore/Context/EntryMapper/EmployeeNavigationContextEntryMapper.cs @@ -0,0 +1,17 @@ +using System; +using System.Linq; +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.EntryMapper +{ + public class EmployeeNavigationContextEntryMapper : BaseContextEntryMapper + { + public override void MergeWithObject(Employee pObject, EmployeeNavigationContextEntry pContext) + { + pContext.EmployeeOid = pObject.Oid.Value; + pContext.PersonnelNumber = pObject.PersonnelNumber; + pContext.FirstNameLastName = pObject.Person.FirstNameLastName; + } + } +} diff --git a/AICore/Context/EntryMapper/OrganisationContextEntryMapper.cs b/AICore/Context/EntryMapper/OrganisationContextEntryMapper.cs new file mode 100644 index 000000000..e4bbe2721 --- /dev/null +++ b/AICore/Context/EntryMapper/OrganisationContextEntryMapper.cs @@ -0,0 +1,15 @@ +using System; +using System.Linq; +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.EntryMapper +{ + public class OrganisationContextEntryMapper : BaseContextEntryMapper + { + public override void MergeWithObject(Organisation pObject, OrganisationDetailContextEntry pContext) + { + throw new NotImplementedException(); + } + } +} diff --git a/AICore/Context/EntryMapper/OrganisationNavigationContextEntryMapper.cs b/AICore/Context/EntryMapper/OrganisationNavigationContextEntryMapper.cs new file mode 100644 index 000000000..e32eeadba --- /dev/null +++ b/AICore/Context/EntryMapper/OrganisationNavigationContextEntryMapper.cs @@ -0,0 +1,23 @@ +using System; +using System.Linq; +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.EntryMapper +{ + public class OrganisationNavigationContextEntryMapper : BaseContextEntryMapper + { + public override void MergeWithObject(Organisation pObject, OrganisationNavigationContextEntry pContext) + { + pContext.OrganisationOid = pObject.Oid.Value; + pContext.Name = pObject.Name; + pContext.Name2 = pObject.Name2; + pContext.DebitorNumber = pObject.DebitorNumber; + pContext.BusinessPartnerId = pObject.BusinessPartnerId; + pContext.AddressString = "---"; + pContext.IKDatenannahmestelle = pObject.IKDatenannahmestelle; + pContext.IKKostentrager = pObject.IKKostentrager; + pContext.IKKrankenkasse = pObject.IKKrankenkasse; + } + } +} diff --git a/AICore/Context/EntryMapper/PersonContextEntryMapper.cs b/AICore/Context/EntryMapper/PersonContextEntryMapper.cs new file mode 100644 index 000000000..50bf1a54d --- /dev/null +++ b/AICore/Context/EntryMapper/PersonContextEntryMapper.cs @@ -0,0 +1,15 @@ +using System; +using System.Linq; +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.EntryMapper +{ + public class PersonContextEntryMapper : BaseContextEntryMapper + { + public override void MergeWithObject(Person pObject, PersonDetailContextEntry pContext) + { + throw new NotImplementedException(); + } + } +} diff --git a/AICore/Context/EntryMapper/PersonNavigationContextEntryMapper.cs b/AICore/Context/EntryMapper/PersonNavigationContextEntryMapper.cs new file mode 100644 index 000000000..e25219a9a --- /dev/null +++ b/AICore/Context/EntryMapper/PersonNavigationContextEntryMapper.cs @@ -0,0 +1,21 @@ +using System; +using System.Linq; +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.EntryMapper +{ + public class PersonNavigationContextEntryMapper : BaseContextEntryMapper + { + public override void MergeWithObject(Person pObject, PersonNavigationContextEntry pContext) + { + pContext.AddressString = "---"; + pContext.DateOfBirth = pObject.DateOfBirth; + //pContext.CustomerOid = "---"; + //pContext.EmployeeOid = "---"; + pContext.FullName = pObject.FirstNameLastName; + pContext.Geschlecht = pObject.Sex.ToString(); + pContext.Function = pObject.Function.Value; + } + } +} diff --git a/AICore/Context/EntryMapper/ServiceRecordContextEntryMapper.cs b/AICore/Context/EntryMapper/ServiceRecordContextEntryMapper.cs new file mode 100644 index 000000000..d71f5c79d --- /dev/null +++ b/AICore/Context/EntryMapper/ServiceRecordContextEntryMapper.cs @@ -0,0 +1,30 @@ +using System; +using System.Linq; +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.EntryMapper +{ + public class ServiceRecordContextEntryMapper : BaseContextEntryMapper + { + public override void MergeWithObject(ServiceRecord pObject, ServiceRecordContextEntry pContext) + { + pContext.ServiceRecordOid = pObject.Oid.Value; + pContext.Start = pObject.Start; + pContext.End = pObject.End; + pContext.DurationInMinuten = pObject.DurationMinutes; + pContext.CategoryName = pObject.ServiceDescription.ServiceCategory.Name; + pContext.DescriptionName = pObject.ServiceDescription.Name; + pContext.Notice = pObject.Notice; + pContext.Notice2 = pObject.Notice2; + pContext.Notice3 = pObject.Notice3; + pContext.Notice4 = pObject.Notice4; + pContext.Notice5 = pObject.Notice5; + pContext.DistanceInMeter = pObject.DistanceInMeter; + pContext.InsertedOn = pObject.InsTs.Value; + pContext.Betrag = pObject.Betrag; + pContext.InsUser = pObject.InsUser; + pContext.Employee = pObject.Employee.Person.FirstNameLastName; + } + } +} diff --git a/AICore/Context/EntryMapper/SupportConceptContextEntryMapper.cs b/AICore/Context/EntryMapper/SupportConceptContextEntryMapper.cs new file mode 100644 index 000000000..ac5fb207c --- /dev/null +++ b/AICore/Context/EntryMapper/SupportConceptContextEntryMapper.cs @@ -0,0 +1,15 @@ +using System; +using System.Linq; +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.EntryMapper +{ + public class SupportConceptContextEntryMapper : BaseContextEntryMapper + { + public override void MergeWithObject(SupportConcept pObject, SupportConceptDetailContextEntry pContext) + { + throw new NotImplementedException(); + } + } +} diff --git a/AICore/Context/EntryMapper/SupportConceptNavigationContextEntryMapper.cs b/AICore/Context/EntryMapper/SupportConceptNavigationContextEntryMapper.cs new file mode 100644 index 000000000..ff4b121ff --- /dev/null +++ b/AICore/Context/EntryMapper/SupportConceptNavigationContextEntryMapper.cs @@ -0,0 +1,22 @@ +using System; +using System.Linq; +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.EntryMapper +{ + public class SupportConceptNavigationContextEntryMapper : BaseContextEntryMapper + { + public override void MergeWithObject(SupportConcept pObject, SupportConceptNavigationContextEntry pContext) + { + pContext.SupportConceptOid = pObject.Oid.Value; + pContext.AddressString = "---"; + pContext.AllCostBearerNames = "---";//pObject.AllCostBearerNames; + pContext.CostBearer = "---";//pObject.CostBearer; + pContext.CostBearerDetailStrings = "---";//pObject.CostBearerDetailStrings; + pContext.Customer = pObject.Customer; //Typ ist unsicher, daher object + pContext.StartDate = pObject.StartDate; + pContext.EndDate = pObject.EndDate; + } + } +} diff --git a/AICore/Context/Summary/BaseContextSummary.cs b/AICore/Context/Summary/BaseContextSummary.cs index 571462568..23c96e879 100644 --- a/AICore/Context/Summary/BaseContextSummary.cs +++ b/AICore/Context/Summary/BaseContextSummary.cs @@ -1,115 +1,7 @@ -using AICore.Context.Entry; -using AICore.Context.EntryMapper; -using BeWo.Data.Entities; -using BS.Shared; -using BS.Shared.DataContracts; -using BS.Shared.DataContracts.Compact; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AICore.Context.Summary +namespace AICore.Context.Summary { public abstract class BaseContextSummary { } - - public abstract class DetailContext : BaseContextSummary where T : DetailContextEntry - { - public T DataContext { get; set; } - - protected DetailContext(T dataContext) - { - DataContext = dataContext; - } - } - - public abstract class NavigationContextSummary : BaseContextSummary where T : NavigationContextEntry - { - public IEnumerable DataContext { get; set; } - - protected NavigationContextSummary(IEnumerable dataContext) - { - DataContext = dataContext; - } - } - - public class CustomerDetailContextSummary : DetailContext - { - public CustomerDetailContextSummary(CustomerDetailContextEntry customer) : base(customer) { } - } - - public class EmployeeDetailContextSummary : DetailContext - { - public EmployeeDetailContextSummary(EmployeeDetailContextEntry employee) : base(employee) { } - } - - public class PersonDetailContextSummary : DetailContext - { - public PersonDetailContextSummary(PersonDetailContextEntry person) : base(person) { } - } - - public class OrganisationDetailContextSummary : DetailContext - { - public OrganisationDetailContextSummary(OrganisationDetailContextEntry organisation) : base(organisation) { } - } - - public class SupportConceptDetailContextSummary : DetailContext - { - public SupportConceptDetailContextSummary(SupportConceptDetailContextEntry supportConcept) : base(supportConcept) { } - } - - public class CustomerNavigationContextSummary : NavigationContextSummary - { - public CustomerNavigationContextSummary(IEnumerable customers) : base(customers) { } - } - public class EmployeeNavigationContextSummary : NavigationContextSummary - { - public EmployeeNavigationContextSummary(IEnumerable employee) : base(employee) { } - } - public class PersonNavigationContextSummary : NavigationContextSummary - { - public PersonNavigationContextSummary(IEnumerable person) : base(person) { } - } - public class OrganisationNavigationContextSummary : NavigationContextSummary - { - public OrganisationNavigationContextSummary(IEnumerable organisation) : base(organisation) { } - } - public class SupportConceptNavigationContextSummary : NavigationContextSummary - { - public SupportConceptNavigationContextSummary(IEnumerable supportConcept) : base(supportConcept) { } - } - - public class ServiceRecordNavigationContextSummary : NavigationContextSummary - { - public CustomerNavigationContextEntry Customer { get; set; } - public string CostBearer { get; set; } - public string SupportConcept { get; set; } - - public ServiceRecordNavigationContextSummary(List serviceRecords, CustomerNavigationContextEntry customer, string costBearer, string supportConcept) - : base(serviceRecords) - { - Customer = customer; - CostBearer = costBearer; - SupportConcept = supportConcept; - } - - //var customer = LoadEntity(bewoobjects, TableID.Customer, MapperFactory.CompactCustomerDC_Customer); - //var costbearer = LoadProperty(bewoobjects, TableID.CostBearer, MapperFactory.CompactOrganisationDC_Organisation, dc => dc.Name); - //var supportconcept = LoadProperty(bewoobjects, TableID.SupportConcept, MapperFactory.CompactSupportConceptDC_SupportConcept, dc => $"{dc.StartDate?.Date} - {dc.EndDate?.Date}"); - //var records = LoadEntities(bewoobjects, TableID.ServiceRecord, MapperFactory.ServiceRecordDC_ServiceRecord); - - //var result = new Dictionary - // { - // { TableID.ServiceRecord, records }, - // { TableID.Customer, customer }, - // { TableID.CostBearer, costbearer }, - // { TableID.SupportConcept, supportconcept } - // }; - - // return result; - } } diff --git a/AICore/Context/Summary/CustomerDetailContextSummary.cs b/AICore/Context/Summary/CustomerDetailContextSummary.cs new file mode 100644 index 000000000..859a344ec --- /dev/null +++ b/AICore/Context/Summary/CustomerDetailContextSummary.cs @@ -0,0 +1,10 @@ +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.Summary +{ + public class CustomerDetailContextSummary : DetailContextSummary + { + public CustomerDetailContextSummary(CustomerDetailContextEntry customer) : base(customer) { } + } +} diff --git a/AICore/Context/Summary/CustomerNavigationContextSummary.cs b/AICore/Context/Summary/CustomerNavigationContextSummary.cs new file mode 100644 index 000000000..07656bac9 --- /dev/null +++ b/AICore/Context/Summary/CustomerNavigationContextSummary.cs @@ -0,0 +1,11 @@ +using AICore.Context.Entry; +using BeWo.Data.Entities; +using System.Collections.Generic; + +namespace AICore.Context.Summary +{ + public class CustomerNavigationContextSummary : NavigationContextSummary + { + public CustomerNavigationContextSummary(IEnumerable customers) : base(customers) { } + } +} diff --git a/AICore/Context/Summary/DetailContextSummary.cs b/AICore/Context/Summary/DetailContextSummary.cs new file mode 100644 index 000000000..585e88410 --- /dev/null +++ b/AICore/Context/Summary/DetailContextSummary.cs @@ -0,0 +1,14 @@ +using AICore.Context.Entry; + +namespace AICore.Context.Summary +{ + public abstract class DetailContextSummary : BaseContextSummary where TEntry : DetailContextEntry + { + public TEntry DataContext { get; set; } + + protected DetailContextSummary(TEntry dataContext) + { + DataContext = dataContext; + } + } +} diff --git a/AICore/Context/Summary/EmployeeDetailContextSummary.cs b/AICore/Context/Summary/EmployeeDetailContextSummary.cs new file mode 100644 index 000000000..614a62973 --- /dev/null +++ b/AICore/Context/Summary/EmployeeDetailContextSummary.cs @@ -0,0 +1,10 @@ +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.Summary +{ + public class EmployeeDetailContextSummary : DetailContextSummary + { + public EmployeeDetailContextSummary(EmployeeDetailContextEntry employee) : base(employee) { } + } +} diff --git a/AICore/Context/Summary/EmployeeNavigationContextSummary.cs b/AICore/Context/Summary/EmployeeNavigationContextSummary.cs new file mode 100644 index 000000000..41f507045 --- /dev/null +++ b/AICore/Context/Summary/EmployeeNavigationContextSummary.cs @@ -0,0 +1,11 @@ +using AICore.Context.Entry; +using BeWo.Data.Entities; +using System.Collections.Generic; + +namespace AICore.Context.Summary +{ + public class EmployeeNavigationContextSummary : NavigationContextSummary + { + public EmployeeNavigationContextSummary(IEnumerable employee) : base(employee) { } + } +} diff --git a/AICore/Context/Summary/NavigationContextSummary.cs b/AICore/Context/Summary/NavigationContextSummary.cs new file mode 100644 index 000000000..9872d522f --- /dev/null +++ b/AICore/Context/Summary/NavigationContextSummary.cs @@ -0,0 +1,15 @@ +using AICore.Context.Entry; +using System.Collections.Generic; + +namespace AICore.Context.Summary +{ + public abstract class NavigationContextSummary : BaseContextSummary where TEntry : NavigationContextEntry + { + public IEnumerable DataContext { get; set; } + + protected NavigationContextSummary(IEnumerable dataContext) + { + DataContext = dataContext; + } + } +} diff --git a/AICore/Context/Summary/OrganisationDetailContextSummary.cs b/AICore/Context/Summary/OrganisationDetailContextSummary.cs new file mode 100644 index 000000000..4ad3aae02 --- /dev/null +++ b/AICore/Context/Summary/OrganisationDetailContextSummary.cs @@ -0,0 +1,10 @@ +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.Summary +{ + public class OrganisationDetailContextSummary : DetailContextSummary + { + public OrganisationDetailContextSummary(OrganisationDetailContextEntry organisation) : base(organisation) { } + } +} diff --git a/AICore/Context/Summary/OrganisationNavigationContextSummary.cs b/AICore/Context/Summary/OrganisationNavigationContextSummary.cs new file mode 100644 index 000000000..a626e6332 --- /dev/null +++ b/AICore/Context/Summary/OrganisationNavigationContextSummary.cs @@ -0,0 +1,11 @@ +using AICore.Context.Entry; +using BeWo.Data.Entities; +using System.Collections.Generic; + +namespace AICore.Context.Summary +{ + public class OrganisationNavigationContextSummary : NavigationContextSummary + { + public OrganisationNavigationContextSummary(IEnumerable organisation) : base(organisation) { } + } +} diff --git a/AICore/Context/Summary/PersonDetailContextSummary.cs b/AICore/Context/Summary/PersonDetailContextSummary.cs new file mode 100644 index 000000000..967a47287 --- /dev/null +++ b/AICore/Context/Summary/PersonDetailContextSummary.cs @@ -0,0 +1,10 @@ +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.Summary +{ + public class PersonDetailContextSummary : DetailContextSummary + { + public PersonDetailContextSummary(PersonDetailContextEntry person) : base(person) { } + } +} diff --git a/AICore/Context/Summary/PersonNavigationContextSummary.cs b/AICore/Context/Summary/PersonNavigationContextSummary.cs new file mode 100644 index 000000000..2ecc172f3 --- /dev/null +++ b/AICore/Context/Summary/PersonNavigationContextSummary.cs @@ -0,0 +1,11 @@ +using AICore.Context.Entry; +using BeWo.Data.Entities; +using System.Collections.Generic; + +namespace AICore.Context.Summary +{ + public class PersonNavigationContextSummary : NavigationContextSummary + { + public PersonNavigationContextSummary(IEnumerable person) : base(person) { } + } +} diff --git a/AICore/Context/Summary/ServiceRecordNavigationContextSummary.cs b/AICore/Context/Summary/ServiceRecordNavigationContextSummary.cs new file mode 100644 index 000000000..392980c27 --- /dev/null +++ b/AICore/Context/Summary/ServiceRecordNavigationContextSummary.cs @@ -0,0 +1,36 @@ +using AICore.Context.Entry; +using BeWo.Data.Entities; +using System.Collections.Generic; + +namespace AICore.Context.Summary +{ + public class ServiceRecordNavigationContextSummary : NavigationContextSummary + { + public CustomerNavigationContextEntry Customer { get; set; } + public string CostBearer { get; set; } + public string SupportConcept { get; set; } + + public ServiceRecordNavigationContextSummary(IEnumerable serviceRecords, CustomerNavigationContextEntry customer, string costBearer, string supportConcept) + : base(serviceRecords) + { + Customer = customer; + CostBearer = costBearer; + SupportConcept = supportConcept; + } + + //var customer = LoadEntity(bewoobjects, TableID.Customer, MapperFactory.CompactCustomerDC_Customer); + //var costbearer = LoadProperty(bewoobjects, TableID.CostBearer, MapperFactory.CompactOrganisationDC_Organisation, dc => dc.Name); + //var supportconcept = LoadProperty(bewoobjects, TableID.SupportConcept, MapperFactory.CompactSupportConceptDC_SupportConcept, dc => $"{dc.StartDate?.Date} - {dc.EndDate?.Date}"); + //var records = LoadEntities(bewoobjects, TableID.ServiceRecord, MapperFactory.ServiceRecordDC_ServiceRecord); + + //var result = new Dictionary + // { + // { TableID.ServiceRecord, records }, + // { TableID.Customer, customer }, + // { TableID.CostBearer, costbearer }, + // { TableID.SupportConcept, supportconcept } + // }; + + // return result; + } +} diff --git a/AICore/Context/Summary/SupportConceptDetailContextSummary.cs b/AICore/Context/Summary/SupportConceptDetailContextSummary.cs new file mode 100644 index 000000000..2ad64f34a --- /dev/null +++ b/AICore/Context/Summary/SupportConceptDetailContextSummary.cs @@ -0,0 +1,10 @@ +using AICore.Context.Entry; +using BeWo.Data.Entities; + +namespace AICore.Context.Summary +{ + public class SupportConceptDetailContextSummary : DetailContextSummary + { + public SupportConceptDetailContextSummary(SupportConceptDetailContextEntry supportConcept) : base(supportConcept) { } + } +} diff --git a/AICore/Context/Summary/SupportConceptNavigationContextSummary.cs b/AICore/Context/Summary/SupportConceptNavigationContextSummary.cs new file mode 100644 index 000000000..4b81b5a9c --- /dev/null +++ b/AICore/Context/Summary/SupportConceptNavigationContextSummary.cs @@ -0,0 +1,11 @@ +using AICore.Context.Entry; +using BeWo.Data.Entities; +using System.Collections.Generic; + +namespace AICore.Context.Summary +{ + public class SupportConceptNavigationContextSummary : NavigationContextSummary + { + public SupportConceptNavigationContextSummary(IEnumerable supportConcept) : base(supportConcept) { } + } +} diff --git a/AICore/Prompt/Core/AiUtils.cs b/AICore/Prompt/Core/AiUtils.cs index ab6241a8e..f4dd262f8 100644 --- a/AICore/Prompt/Core/AiUtils.cs +++ b/AICore/Prompt/Core/AiUtils.cs @@ -1,16 +1,8 @@ -using BS.Shared; -using BS.Shared.Exceptions; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AICore.Prompt.Core +namespace AICore.Prompt.Core { public static class AiUtils { - + } } diff --git a/AICore/Prompt/Factories/BaseAiPromptFactory.cs b/AICore/Prompt/Factories/BaseAiPromptFactory.cs deleted file mode 100644 index 55358a7c0..000000000 --- a/AICore/Prompt/Factories/BaseAiPromptFactory.cs +++ /dev/null @@ -1,306 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using AICore.Context.Summary; -using AICore.Context.SummaryMapper; -using BeWo.Data.Access; -using BeWo.Data.Entities; -using BeWo.ServiceUtils.Core; -using BS.Shared; -using BS.Shared.Exceptions; -using BS.Shared.Translation; - -namespace AICore.Prompt.Factories -{ - public abstract class BaseAiPromptFactory - { - public string CreateSystemInstructions(AiContextType uicontext, Dictionary bewoobjects) - { - var sb = new StringBuilder(); - - sb.AppendLine(getCustomSystemPrompt()); - - sb.AppendLine($"Ich befinde mich aktuell in der \"{Translator.Translate(uicontext)}\" meiner Anwendung."); - sb.AppendLine("Es ist kein Filter gesetzt."); - - if (bewoobjects is null || bewoobjects.Count == 0) - { - sb.AppendLine("Dir wurden keine Daten bereitgestellt."); - } - else - { - sb.AppendLine("Du erhälst folgendes:"); - var parsed = LoadContext(uicontext, bewoobjects); - sb.AppendLine(parsed); - } - - return sb.ToString(); - } - - private string LoadContext(AiContextType uicontext, Dictionary bewoobjects) - { - var context = GetContext(uicontext, bewoobjects); - - var parsed = Parse(uicontext, null); - - return parsed; - } - - protected virtual string Parse(AiContextType uicontext, Dictionary data) - { - throw new NotImplementedException(); - } - - protected BaseContextSummary GetContext(AiContextType uicontext, Dictionary bewoobjects) - { - switch (uicontext) - { - case AiContextType.SupportConcept: - case AiContextType.Customer: - case AiContextType.Person: - case AiContextType.Employee: - case AiContextType.Organisation: - return GetNavigationContext(uicontext, bewoobjects); - case AiContextType.ServiceRecord: - return GetServiceRecordsContext(bewoobjects); - case AiContextType.CustomerSingle: - case AiContextType.PersonSingle: - case AiContextType.EmployeeSingle: - return GetSingleContext(uicontext, bewoobjects); - default: - break; - } - - throw BeWoNotImplementedException.CreateFromEnum(uicontext); - } - - private BaseContextSummary GetNavigationContext(AiContextType uicontext, Dictionary bewoobjects) - { - switch (uicontext) - { - case AiContextType.SupportConcept: - - return new SupportConceptNavigationContextSummary(LoadEntities(bewoobjects, TableID.SupportConcept)); - case AiContextType.Customer: - return new CustomerNavigationContextSummary(LoadEntities(bewoobjects, TableID.Customer)); - case AiContextType.Person: - return new PersonNavigationContextSummary(LoadEntities(bewoobjects, TableID.Person)); - case AiContextType.Employee: - return new EmployeeNavigationContextSummary(LoadEntities(bewoobjects, TableID.Employee)); - case AiContextType.Organisation: - return new OrganisationNavigationContextSummary(LoadEntities(bewoobjects, TableID.Organisation)); - } - - throw BeWoNotImplementedException.CreateFromEnum(uicontext); - } - - private BaseContextSummary GetServiceRecordsContext(Dictionary bewoobjects) - { - - - var context = new ServiceRecordNavigationContext() - } - - private BaseContextSummary GetSingleContext(AiContextType uicontext, Dictionary bewoobjects) - { - switch (uicontext) - { - case AiContextType.CustomerSingle: - return new CustomerDetailContextSummary(LoadEntity(bewoobjects, TableID.Customer)); - case AiContextType.PersonSingle: - return new PersonDetailContextSummary(LoadEntity(bewoobjects, TableID.Person)); - case AiContextType.EmployeeSingle: - return new EmployeeDetailContextSummary(LoadEntity(bewoobjects, TableID.Employee)); - default: - break; - } - - throw BeWoNotImplementedException.CreateFromEnum(uicontext); - } - - public Dictionary LoadContext(int uicontext, Dictionary bewoobjects) - { - var result = new Dictionary(); - - switch (uicontext) - { - case 0: return LoadNavigationContext(TableID.SupportConcept, bewoobjects); - case 1: return LoadNavigationContext(TableID.Customer, bewoobjects); - case 2: return LoadNavigationContext(TableID.Person, bewoobjects); - case 3: return LoadNavigationContext(TableID.Employee, bewoobjects); - case 4: return LoadNavigationContext(TableID.Organisation, bewoobjects); - //case 5: return "Team Navigation"; - //case 6: return "Dokumente Navigation"; - //case 7: return "Benutzer Navigation"; - //case 8: return "Benutzergruppe Navigation"; - //case 9: return "Bericht Navigation"; - //case 10: return "Planer Navigation"; - //case 11: return "Wohnheim Navigation"; - //case 12: return "Vertretungen Navigation"; - //case 13: return "Kunden-Team Navigation"; - //case 14: return "Terminplanung Navigation"; - //case 15: return "Finanz Navigation"; - //case 16: return "Verwaltung Navigation"; - //case 17: return "KI-Gesprächs Navigation"; - //case 18: return "KI-Gesprächs Popup Navigation"; - case 19: return LoadServiceRecordsContext(bewoobjects); - case 20: return LoadSingleContext(TableID.Customer, bewoobjects); - //case 21: return "Person Einzelansicht Navigation"; - //case 22: return "Mitarbeiter Einzelansicht Navigation"; - default: - throw new NotImplementedException($"UI Kontext {uicontext} ist nicht implementiert."); - //Alternativ könnte man auch einen Standard-String zurückgeben, - //z.B. return "Unbekannter UI-Kontext"; - } - } - - private Dictionary LoadNavigationContext(TableID tableid, Dictionary bewoobjects) - { - IList> entities; - - switch (tableid) - { - case TableID.Person: - entities = LoadEntities(bewoobjects, tableid, MapperFactory.CompactPersonDC_Person); - break; - case TableID.Customer: - entities = LoadEntities(bewoobjects, tableid, MapperFactory.CompactCustomerDC_Customer); - break; - case TableID.Employee: - entities = LoadEntities(bewoobjects, tableid, MapperFactory.CompactEmployeeDC_Employee); - break; - case TableID.SupportConcept: - entities = LoadEntities(bewoobjects, tableid, MapperFactory.CompactSupportConceptDC_SupportConcept); - break; - case TableID.Organisation: - entities = LoadEntities(bewoobjects, tableid, MapperFactory.CompactOrganisationDC_Organisation, (entity, dc) => - { - if (entity.Address != null) - { - dc.AddressLine1 = entity.Address.AddressLine1; - dc.Street = entity.Address.Street; - dc.PostalCode = entity.Address.PostalCode; - dc.Town = entity.Address.Town; - } - }); - break; - default: - throw new NotImplementedException($"TableID {tableid} not implemented as navigation context"); - } - - var result = new Dictionary>> - { - { tableid, entities.ToList() } - }; - - return result; - } - - private Dictionary LoadSingleContext(TableID tableid, Dictionary bewoobjects) - { - var result = new Dictionary>(); - - Dictionary entity; - - switch (tableid) - { - case TableID.Person: - entity = LoadEntity(bewoobjects, tableid, MapperFactory.PersonDC_Person); - break; - case TableID.Customer: - entity = LoadEntity(bewoobjects, tableid, MapperFactory.CustomerDC_Customer); - break; - case TableID.Employee: - entity = LoadEntity(bewoobjects, tableid, MapperFactory.EmployeeDC_Employee); - break; - case TableID.SupportConcept: - entity = LoadEntity(bewoobjects, tableid, MapperFactory.SupportConceptDC_SupportConcept); - break; - //case TableID.Organisation: - // entity = LoadEntity(bewoobjects, tableid, MapperFactory.OrganisationDC_OrganisationMapper, (entity, dc) => - // { - // if (entity.Address != null) - // { - // dc.AddressLine1 = entity.Address.AddressLine1; - // dc.Street = entity.Address.Street; - // dc.PostalCode = entity.Address.PostalCode; - // dc.Town = entity.Address.Town; - // } - // }); - // break; - default: - throw new NotImplementedException($"TableID {tableid} not implemented as navigation context"); - } - - return result; - } - - private TRet LoadProperty - (Dictionary bewoobjects, TableID tid, Func getPropertyFunc) - where TEntity : BeWoEntityBase, new() - { - if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) - return default; - - var entity = DAOFactory.GenericDAO.GetByID(oids[0]); - var property = getPropertyFunc(entity); - - return property; - } - - private TEntity LoadEntity - (Dictionary bewoobjects, TableID tid) - where TEntity : BeWoEntityBase, new() - { - if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) - return null; - - var entity = DAOFactory.GenericDAO.GetByID(oids[0]); - - return entity; - } - - private List LoadEntities - (Dictionary bewoobjects, TableID tid) - where TEntity : BeWoEntityBase, new() - { - if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) - return null; - - var entities = DAOFactory.GenericDAO.GetByIDs(oids); - - //if(afterLoad != null) - //{ - // foreach( var entity in entities) - // { - // afterLoad(entity); - // } - //} - - return entities; - } - - private string getSystemPrompt(int i) - { - var assembly = Assembly.GetExecutingAssembly(); - var resourceName = $"AICore.Prompt.SystemPrompts.system_prompt{i}.txt"; - - using (Stream stream = assembly.GetManifestResourceStream(resourceName)) - using (StreamReader reader = new StreamReader(stream)) - { - string result = reader.ReadToEnd(); - return result; - } - } - - private string getCustomSystemPrompt() - { - var path = MergedConfig.GetSetting("AiSystemPromptPath"); - - return File.ReadAllText(path); - } - } -} diff --git a/AICore/Prompt/Factories/JsonAiPromptFactory.cs b/AICore/Prompt/Factories/JsonAiPromptFactory.cs index f4f82ab9f..4c720cde5 100644 --- a/AICore/Prompt/Factories/JsonAiPromptFactory.cs +++ b/AICore/Prompt/Factories/JsonAiPromptFactory.cs @@ -1,10 +1,201 @@ -namespace AICore.Prompt.Factories +using AICore.Context.Entry; +using AICore.Context.Summary; +using AICore.Context.SummaryMapper; +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.ServiceUtils.Core; +using BS.Shared; +using BS.Shared.Exceptions; +using BS.Shared.Translation; +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using System.Text.Json; + +namespace AICore.Prompt.Factories { - public class JsonAiPromptFactory : BaseAiPromptFactory + public class JsonAiPromptFactory { - //protected override string Parse(int uicontext, object data) - //{ - - //} + public string CreateSystemInstructions(AiContextType uicontext, Dictionary bewoobjects) + { + var sb = new StringBuilder(); + + sb.AppendLine(getCustomSystemPrompt()); + + sb.AppendLine($"Ich befinde mich aktuell in der \"{Translator.Translate(uicontext)}\" meiner Anwendung."); + sb.AppendLine("Es ist kein Filter gesetzt."); + + if (bewoobjects is null || bewoobjects.Count == 0) + { + sb.AppendLine("Dir wurden keine Daten bereitgestellt."); + } + else + { + sb.AppendLine("Du erhälst folgendes:"); + var parsed = LoadContext(uicontext, bewoobjects); + sb.AppendLine(parsed); + } + + return sb.ToString(); + } + + private string LoadContext(AiContextType uicontext, Dictionary bewoobjects) + { + var context = GetContext(uicontext, bewoobjects); + + var parsed = Parse(uicontext, context); + + return parsed; + } + + protected virtual string Parse(AiContextType uicontext, BaseContextSummary context) + { + var str = JsonSerializer.Serialize(context); + + return str; + } + + protected BaseContextSummary GetContext(AiContextType uicontext, Dictionary bewoobjects) + { + switch (uicontext) + { + case AiContextType.SupportConcept: + return GetNavigationContext(bewoobjects); + case AiContextType.Customer: + return GetNavigationContext(bewoobjects); + case AiContextType.Person: + return GetNavigationContext(bewoobjects); + case AiContextType.Employee: + return GetNavigationContext(bewoobjects); + case AiContextType.Organisation: + return GetNavigationContext(bewoobjects); + case AiContextType.ServiceRecord: + return GetServiceRecordsContext(bewoobjects); + case AiContextType.CustomerSingle: + return GetDetailContext(bewoobjects); + case AiContextType.PersonSingle: + return GetDetailContext(bewoobjects); + case AiContextType.EmployeeSingle: + return GetDetailContext(bewoobjects); + default: + throw BeWoNotImplementedException.CreateFromEnum(uicontext); + } + } + + private DetailContextSummary GetDetailContext(Dictionary bewoobjects) + where TEntry : DetailContextEntry + where TEntity : BeWoEntityBase, new() + { + var entity = LoadEntity(bewoobjects); + + var context = ContextSummaryFactory.CreateDetailContext(entity); + + return context; + } + + private NavigationContextSummary GetNavigationContext(Dictionary bewoobjects) + where TEntry : NavigationContextEntry + where TEntity : BeWoEntityBase, new() + { + var entities = LoadEntities(bewoobjects); + + var context = ContextSummaryFactory.CreateNavigationContext(entities); + + return context; + } + + private ServiceRecordNavigationContextSummary GetServiceRecordsContext(Dictionary bewoobjects) + { + var customer = LoadEntity(bewoobjects); + var costbearer = LoadProperty(bewoobjects, dc => dc.Name); + var supportconcept = LoadProperty(bewoobjects, dc => $"{dc.StartDate?.Date} - {dc.EndDate?.Date}"); + var records = LoadEntities(bewoobjects); + + var context = ContextSummaryFactory.CreateServiceRecordNavigationContextSummary(records, customer, costbearer, supportconcept); + + return context; + } + + private TRet LoadProperty + (Dictionary bewoobjects, Func getPropertyFunc) + where TEntity : BeWoEntityBase, new() + { + var tid = GetTableId(); + + if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) + return default; + + var entity = DAOFactory.GenericDAO.GetByID(oids[0]); + var property = getPropertyFunc(entity); + + return property; + } + + private TEntity LoadEntity + (Dictionary bewoobjects) + where TEntity : BeWoEntityBase, new() + { + var tid = GetTableId(); + + if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) + return null; + + var entity = DAOFactory.GenericDAO.GetByID(oids[0]); + + return entity; + } + + private List LoadEntities + (Dictionary bewoobjects) + where TEntity : BeWoEntityBase, new() + { + var instance = new TEntity(); + var tid = GetTableId(); + + if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) + return null; + + var entities = DAOFactory.GenericDAO.GetByIDs(oids); + + //if(afterLoad != null) + //{ + // foreach( var entity in entities) + // { + // afterLoad(entity); + // } + //} + + return entities; + } + + private TableID GetTableId(TEntity entity = null) where TEntity : BeWoEntityBase, new() + { + if (entity == null) + entity = new TEntity(); + + return entity.Tid; + } + + private string getSystemPrompt(int i) + { + var assembly = Assembly.GetExecutingAssembly(); + var resourceName = $"AICore.Prompt.SystemPrompts.system_prompt{i}.txt"; + + using (Stream stream = assembly.GetManifestResourceStream(resourceName)) + using (StreamReader reader = new StreamReader(stream)) + { + string result = reader.ReadToEnd(); + return result; + } + } + + private string getCustomSystemPrompt() + { + var path = MergedConfig.GetSetting("AiSystemPromptPath"); + + return File.ReadAllText(path); + } } } diff --git a/AICore/Prompt/Models/AiConversationContext.cs b/AICore/Prompt/Models/AiConversationContext.cs index 54638ee97..4d2c21618 100644 --- a/AICore/Prompt/Models/AiConversationContext.cs +++ b/AICore/Prompt/Models/AiConversationContext.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace AICore.Prompt.Models { @@ -13,7 +9,7 @@ namespace AICore.Prompt.Models public AiConversationContext() { - + } } } diff --git a/AICore/Properties/AssemblyInfo.cs b/AICore/Properties/AssemblyInfo.cs index 5c6bf3ef8..cc67b94d8 100644 --- a/AICore/Properties/AssemblyInfo.cs +++ b/AICore/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // Allgemeine Informationen über eine Assembly werden über die folgenden diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs index c4f41b203..428799441 100644 --- a/BeWo/BeWoApp.xaml.cs +++ b/BeWo/BeWoApp.xaml.cs @@ -632,7 +632,7 @@ namespace BeWo //AppSettings.AllowGkvAbrechnung = true; //AppSettings.AllowGkvAbrechnung = false; //showInfoButtonInCalender = true; - //IsInDeveloperMode = true; + IsInDeveloperMode = true; //IsInDeveloperMode = false; //AppSettings.ModuleAiEnabled = true; //AppSettings.ModuleAiSettingsEnabled = false; diff --git a/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs b/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs index 6d349add9..23821adab 100644 --- a/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs +++ b/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs @@ -28,7 +28,7 @@ namespace BeWo.ServiceProxy [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/GetAiConversations", ReplyAction="http://tempuri.org/IAiEnhancedService/GetAiConversationsResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/GetAiConversationsBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - System.Collections.Generic.List GetAiConversations(int uicontext, System.Nullable oid); + System.Collections.Generic.List GetAiConversations(BS.Shared.AiContextType uicontext, System.Nullable oid); [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAiEnhancedService/CreateAiConversation", ReplyAction="http://tempuri.org/IAiEnhancedService/CreateAiConversationResponse")] [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IAiEnhancedService/CreateAiConversationBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] @@ -106,7 +106,7 @@ namespace BeWo.ServiceProxy return base.Channel.GetAiModels(); } - public System.Collections.Generic.List GetAiConversations(int uicontext, System.Nullable oid) + public System.Collections.Generic.List GetAiConversations(BS.Shared.AiContextType uicontext, System.Nullable oid) { return base.Channel.GetAiConversations(uicontext, oid); } diff --git a/BeWo/Services/BeWoControlFactory.cs b/BeWo/Services/BeWoControlFactory.cs index 51e4f1807..41440d551 100644 --- a/BeWo/Services/BeWoControlFactory.cs +++ b/BeWo/Services/BeWoControlFactory.cs @@ -23,46 +23,42 @@ namespace BeWo.Services return control; } - private string getStyleString(UIContext uIContext) { + private string getStyleString(AiContextType uIContext) { switch (uIContext) { - case UIContext.SupportConcept: return "ModuleAiControlSupportConceptStyle"; - case UIContext.Customer: return "ModuleAiControlCustomerStyle"; - case UIContext.Person: return "ModuleAiControlPersonStyle"; - case UIContext.Employee: return "ModuleAiControlEmployeeStyle"; - case UIContext.Organisation: return "ModuleAiControlOrganisationStyle"; - case UIContext.Team: + case AiContextType.SupportConcept: return "ModuleAiControlSupportConceptStyle"; + case AiContextType.Customer: return "ModuleAiControlCustomerStyle"; + case AiContextType.Person: return "ModuleAiControlPersonStyle"; + case AiContextType.Employee: return "ModuleAiControlEmployeeStyle"; + case AiContextType.Organisation: return "ModuleAiControlOrganisationStyle"; + case AiContextType.Team: break; - case UIContext.Dokumente: + case AiContextType.Dokumente: break; - case UIContext.User: + case AiContextType.User: break; - case UIContext.UserGroup: + case AiContextType.UserGroup: break; - case UIContext.Report: + case AiContextType.Report: break; - case UIContext.Scheduler: + case AiContextType.Scheduler: break; - case UIContext.Wohnheim: + case AiContextType.Wohnheim: break; - case UIContext.Vertretungen: + case AiContextType.Vertretungen: break; - case UIContext.CustomerTeam: + case AiContextType.CustomerTeam: break; - case UIContext.Scheduling: + case AiContextType.Scheduling: break; - case UIContext.Finance: + case AiContextType.Finance: break; - case UIContext.Administration: + case AiContextType.Administration: break; - case UIContext.AiConversation: - break; - case UIContext.AiConversationPopup: - break; - case UIContext.ServiceRecord: return "ModuleAiControlZeiterfassungStyle"; - case UIContext.CustomerSingle: return "ModuleAiControlCustomerStyle"; - case UIContext.PersonSingle: return "ModuleAiControlPersonStyle"; - case UIContext.EmployeeSingle: return "ModuleAiControlEmployeeStyle"; + case AiContextType.ServiceRecord: return "ModuleAiControlZeiterfassungStyle"; + case AiContextType.CustomerSingle: return "ModuleAiControlCustomerStyle"; + case AiContextType.PersonSingle: return "ModuleAiControlPersonStyle"; + case AiContextType.EmployeeSingle: return "ModuleAiControlEmployeeStyle"; } return null; diff --git a/BeWo/Services/BeWoWindowFactory.cs b/BeWo/Services/BeWoWindowFactory.cs index 9c5be9ccd..a6fa7dbc8 100644 --- a/BeWo/Services/BeWoWindowFactory.cs +++ b/BeWo/Services/BeWoWindowFactory.cs @@ -15,15 +15,15 @@ namespace BeWo.Services { internal class BeWoWindowFactory : IWindowFactory { - public Dictionary UIContext2Header { get; set; } = new Dictionary() + public Dictionary UIContext2Header { get; set; } = new Dictionary() { - {UIContext.ServiceRecord, "KI Chat: Zeiterfassung" }, - {UIContext.Customer, "KI Chat: Klienten Übersicht" }, - {UIContext.Person, "KI Chat: Personen Übersicht" }, - {UIContext.Employee, "KI Chat: Mitarbeiter Übersicht" }, - {UIContext.Organisation, "KI Chat: Organisation Übersicht" }, - {UIContext.SupportConcept, "KI Chat: Hilfeplan Übersicht" }, - {UIContext.CustomerSingle, "KI Chat: Klient" }, + {AiContextType.ServiceRecord, "KI Chat: Zeiterfassung" }, + {AiContextType.Customer, "KI Chat: Klienten Übersicht" }, + {AiContextType.Person, "KI Chat: Personen Übersicht" }, + {AiContextType.Employee, "KI Chat: Mitarbeiter Übersicht" }, + {AiContextType.Organisation, "KI Chat: Organisation Übersicht" }, + {AiContextType.SupportConcept, "KI Chat: Hilfeplan Übersicht" }, + {AiContextType.CustomerSingle, "KI Chat: Klient" }, }; public AnimatedBeWoWindow GetAiConversationWindow(AiConversationChatViewModel viewModel, Control control, double height = 600, double width = 1200) diff --git a/BeWo/View/Detail/CustomerView.xaml.cs b/BeWo/View/Detail/CustomerView.xaml.cs index 1c6c8e171..7ccba17be 100644 --- a/BeWo/View/Detail/CustomerView.xaml.cs +++ b/BeWo/View/Detail/CustomerView.xaml.cs @@ -320,7 +320,7 @@ namespace BeWo.View.Detail var customer_oid = ViewModel.DataContract.CustomerOid; var context = GetVisibleInformationReferences(); - var vm = VMFactory.CreateAiConversationChatViewModel(UIContext.CustomerSingle, context, customer_oid); + var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.CustomerSingle, context, customer_oid); return vm; } diff --git a/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml.cs b/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml.cs index ea38c71eb..f3449f14b 100644 --- a/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml.cs +++ b/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml.cs @@ -5106,7 +5106,7 @@ namespace BeWo.View.Detail.Zeiterfassung var context = ViewModel.GetVisibleInformationReferences(records); var oid = supportConceptSelectionControl.SelectedItem.SupportConceptTreeNodeDC.SupportConcept.SupportConceptOid; - var vm = VMFactory.CreateAiConversationChatViewModel(UIContext.ServiceRecord, context, oid); + var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.ServiceRecord, context, oid); return vm; } diff --git a/BeWo/View/Navigation/CustomerNavigationView.xaml.cs b/BeWo/View/Navigation/CustomerNavigationView.xaml.cs index 3a4841312..c66a7d1a3 100644 --- a/BeWo/View/Navigation/CustomerNavigationView.xaml.cs +++ b/BeWo/View/Navigation/CustomerNavigationView.xaml.cs @@ -207,7 +207,7 @@ namespace BeWo.View.Navigation { var context = GetVisibleInformationReferences(); - var vm = VMFactory.CreateAiConversationChatViewModel(UIContext.Customer, context); + var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.Customer, context); return vm; } diff --git a/BeWo/View/Navigation/EmployeeNavigationView.xaml.cs b/BeWo/View/Navigation/EmployeeNavigationView.xaml.cs index 4c19bdc4c..c715c313c 100644 --- a/BeWo/View/Navigation/EmployeeNavigationView.xaml.cs +++ b/BeWo/View/Navigation/EmployeeNavigationView.xaml.cs @@ -113,7 +113,7 @@ namespace BeWo.View.Navigation { var context = GetVisibleInformationReferences(); - var vm = VMFactory.CreateAiConversationChatViewModel(UIContext.Employee, context); + var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.Employee, context); return vm; } diff --git a/BeWo/View/Navigation/OrganisationNavigationView.xaml.cs b/BeWo/View/Navigation/OrganisationNavigationView.xaml.cs index 68e30031d..240e9067d 100644 --- a/BeWo/View/Navigation/OrganisationNavigationView.xaml.cs +++ b/BeWo/View/Navigation/OrganisationNavigationView.xaml.cs @@ -79,7 +79,7 @@ namespace BeWo.View.Navigation { var context = GetVisibleInformationReferences(); - var vm = VMFactory.CreateAiConversationChatViewModel(UIContext.Organisation, context); + var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.Organisation, context); return vm; } diff --git a/BeWo/View/Navigation/PersonNavigationView.xaml.cs b/BeWo/View/Navigation/PersonNavigationView.xaml.cs index c28b417c0..9aaf07cde 100644 --- a/BeWo/View/Navigation/PersonNavigationView.xaml.cs +++ b/BeWo/View/Navigation/PersonNavigationView.xaml.cs @@ -116,7 +116,7 @@ namespace BeWo.View.Navigation { var context = GetVisibleInformationReferences(); - var vm = VMFactory.CreateAiConversationChatViewModel(UIContext.Person, context); + var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.Person, context); return vm; } diff --git a/BeWo/View/Navigation/SupportConceptNavigationView.xaml.cs b/BeWo/View/Navigation/SupportConceptNavigationView.xaml.cs index 07b329135..047bdf9bb 100644 --- a/BeWo/View/Navigation/SupportConceptNavigationView.xaml.cs +++ b/BeWo/View/Navigation/SupportConceptNavigationView.xaml.cs @@ -230,7 +230,7 @@ namespace BeWo.View.Navigation { var context = GetVisibleInformationReferences(); - var vm = VMFactory.CreateAiConversationChatViewModel(UIContext.SupportConcept, context); + var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.SupportConcept, context); return vm; } diff --git a/BeWo/ViewModel/VMFactory.cs b/BeWo/ViewModel/VMFactory.cs index a6427013c..83f525f3b 100644 --- a/BeWo/ViewModel/VMFactory.cs +++ b/BeWo/ViewModel/VMFactory.cs @@ -910,7 +910,7 @@ namespace BeWo.ViewModel einheit_vm_list.VMList.Sort(WohneinheitVM.Compare); } - public static AiConversationChatViewModel CreateAiConversationChatViewModel(UIContext uIContext, Dictionary bewoObjects, long? reference_oid = null) + public static AiConversationChatViewModel CreateAiConversationChatViewModel(AiContextType uIContext, Dictionary bewoObjects, long? reference_oid = null) { var vm = new AiConversationChatViewModel(); @@ -921,10 +921,10 @@ namespace BeWo.ViewModel return vm; } - public static void CreateAiConversationListVM(UIContext uIContext, long? reference_oid, Action callback) + public static void CreateAiConversationListVM(AiContextType uIContext, long? reference_oid, Action callback) { ServiceFacade.DoAiEnhancedServiceAsnyc( - s => s.GetAiConversations((int)uIContext, reference_oid), + s => s.GetAiConversations(uIContext, reference_oid), cb => { cb.Reverse(); diff --git a/BeWo/ViewModel/View/AiConversationChatViewModel.cs b/BeWo/ViewModel/View/AiConversationChatViewModel.cs index 021d4fe65..5a46a5bb6 100644 --- a/BeWo/ViewModel/View/AiConversationChatViewModel.cs +++ b/BeWo/ViewModel/View/AiConversationChatViewModel.cs @@ -151,7 +151,7 @@ namespace BeWo.ViewModel.View } public bool IsNewConversationVisible => ListVM.SelectedVM is null; - public UIContext UIContext { get; set; } + public AiContextType UIContext { get; set; } public long? ReferenceObjectOid { get; set; } public Dictionary ContextBeWoObjects { get; set; } @@ -167,7 +167,7 @@ namespace BeWo.ViewModel.View conv.Created = DateTime.Now; conv.Updated = DateTime.Now; - conv.UIContext = (int)UIContext; + conv.UIContext = UIContext; conv.ContextBeWoObjects = ContextBeWoObjects; conv.Messages = new List() { diff --git a/Service/DCEntityMapper/AbstractIDCEntityMapper.cs b/Service/DCEntityMapper/AbstractIDCEntityMapper.cs index 01cc68145..798d41e70 100644 --- a/Service/DCEntityMapper/AbstractIDCEntityMapper.cs +++ b/Service/DCEntityMapper/AbstractIDCEntityMapper.cs @@ -11,7 +11,7 @@ using BS.Shared.Extensions; namespace BeWo.Service.DCEntityMapper { - public abstract class AbstractIDCEntityMapper : IDCEntityMapper, IJsonMapper + public abstract class AbstractIDCEntityMapper : IDCEntityMapper where TDC : class, new() where TEntity : BeWoEntityBase, new() { public bool ConcurrencyCheck(long? pDataContractVersion, BeWoEntityBase pEntity) @@ -158,36 +158,37 @@ namespace BeWo.Service.DCEntityMapper protected abstract bool AreDCAndEntityEqual(TDC pDC, TEntity pEntity); - public virtual Dictionary ToJsonDictionary(TDC pDC) - { - throw new NotImplementedException("ToJsonDictionary"); - } + // Ausgelagert in AiCore - Kann bei Zeit entfernt werden + //public virtual Dictionary ToJsonDictionary(TDC pDC) + //{ + // throw new NotImplementedException("ToJsonDictionary"); + //} - public Dictionary ToJsonDictionary(TEntity pEntity) - { - var dc = MapToNewDC(pEntity); - var dict = ToJsonDictionary(dc); - return dict; - } + //public Dictionary ToJsonDictionary(TEntity pEntity) + //{ + // var dc = MapToNewDC(pEntity); + // var dict = ToJsonDictionary(dc); + // return dict; + //} - public IList> ToJsonDictionary(IList pEntities) - { - var dcs = MapToNewDCs(pEntities); - var dicts = ToJsonDictionary(dcs); - return dicts; - } + //public IList> ToJsonDictionary(IList pEntities) + //{ + // var dcs = MapToNewDCs(pEntities); + // var dicts = ToJsonDictionary(dcs); + // return dicts; + //} - public IList> ToJsonDictionary(IList pDCs) - { - var dicts = new List>(); + //public IList> ToJsonDictionary(IList pDCs) + //{ + // var dicts = new List>(); - if (pDCs == null) - return dicts; + // if (pDCs == null) + // return dicts; - foreach (var dc in pDCs) - dicts.Add(ToJsonDictionary(dc)); + // foreach (var dc in pDCs) + // dicts.Add(ToJsonDictionary(dc)); - return dicts; - } + // return dicts; + //} } } \ No newline at end of file diff --git a/Service/DCEntityMapper/CustomerDC_Customer.cs b/Service/DCEntityMapper/CustomerDC_Customer.cs index 712944d17..78e4792fe 100644 --- a/Service/DCEntityMapper/CustomerDC_Customer.cs +++ b/Service/DCEntityMapper/CustomerDC_Customer.cs @@ -432,43 +432,5 @@ namespace BeWo.Service.DCEntityMapper return pDC.CustomerOid == pEntity.Oid; } - - public override Dictionary ToJsonDictionary(CustomerDC c) - { - var jsonObject = new Dictionary() - { - {"Klient-ID", c.CustomerOid }, - { "Name", $"{c.FirstName} {c.LastName}"}, - {"Alias", c.CustomerAlias }, - { "Geburtstag", c.DateOfBirth }, - {"Geschlecht", c.Sex.ToString() }, - {"Nationalität", c.Nationalitaet?.DisplayName }, - {"HatMigrationshintergrund", c.IsMigrant }, - {"Migrationshintergrund", c.Migrationshintergrund }, - {"Aufenthaltsstatus", c.AufenthaltsStatus?.DisplayName }, - {"Familienstand", c.FamilyStatus.ToString() }, - {"Beruf", c.Profession }, - {"Kinder", c.Childs }, - {"Eigenbeteiligung", c.EquityContribution }, - {"Krankenkasse", c.HealthInsurance }, - {"Versichertennummer", c.InsuranceNumber }, - {"Versichertenstatus", c.VersichertenStatus }, - {"Kommentar", c.Notice }, - {"Adressezeile 1", c.AddressLine1 }, - {"Straße", c.Street }, - {"PLZ", c.PostalCode }, - {"Ort", c.Town }, - {"Distanz in km", c.DistanceInMeter }, - {"Rechnungsadresse", new Dictionary() - { - { "Adresszeile 1", c.InvoiceAddressLine1 }, - { "Strasse ", c.InvoiceAddressStreet}, - { "Ort", c.InvoiceAddressTown }, - { "PLZ", c.InvoiceAddressPostalCode }, - }} - }; - - return jsonObject; - } } } \ No newline at end of file diff --git a/Service/Plugins/AiService2.cs b/Service/Plugins/AiService2.cs index 4a63b68e6..f2edae52e 100644 --- a/Service/Plugins/AiService2.cs +++ b/Service/Plugins/AiService2.cs @@ -75,7 +75,7 @@ namespace BeWo.Service.Plugins // ======================[ Conversations ]====================== - public IEnumerable GetAiConversations(int uicontext, long? oid) + public IEnumerable GetAiConversations(AiContextType uicontext, long? oid) { // SearchDAO var current_user = UserRightHelper.GetLoggedInUserWithOid(); @@ -95,7 +95,7 @@ namespace BeWo.Service.Plugins var main_ref_obj = conv.ContextBeWoObjects?.FirstOrDefault(); // ServiceRecord - if (uicontext == 19) + if (uicontext == AiContextType.ServiceRecord) main_ref_obj = conv.ContextBeWoObjects.FirstOrDefault(x => x.Tid == TableID.SupportConcept); if (main_ref_obj?.Oid != ref_oid) @@ -271,7 +271,7 @@ namespace BeWo.Service.Plugins return models; } - private AiConversation createAiConversation(int uicontext, Dictionary context, long modell_oid, AiDataContextType context_Type) + private AiConversation createAiConversation(AiContextType uicontext, Dictionary context, long modell_oid, AiDataContextType context_Type) { var current_user = UserRightHelper.GetLoggedInUserWithOid(); var factory = getFactory(context_Type); @@ -302,7 +302,7 @@ namespace BeWo.Service.Plugins return conv; } - private BaseAiPromptFactory getFactory(AiDataContextType context_Type) + private JsonAiPromptFactory getFactory(AiDataContextType context_Type) { if (context_Type == AiDataContextType.json) return new JsonAiPromptFactory(); diff --git a/Service/ServiceContracts/IAiEnhancedService.cs b/Service/ServiceContracts/IAiEnhancedService.cs index 8e4cc979f..5dfe8cf3d 100644 --- a/Service/ServiceContracts/IAiEnhancedService.cs +++ b/Service/ServiceContracts/IAiEnhancedService.cs @@ -33,7 +33,7 @@ namespace BeWo.Service.ServiceContracts [FaultContract(typeof(BeWoFault))] [OperationContract] [RequirePermission(UserRightType.AiModuleView, UserRightType.AiModuleView2)] - IEnumerable GetAiConversations(int uicontext, long? oid); + IEnumerable GetAiConversations(AiContextType uicontext, long? oid); [FaultContract(typeof(BeWoFault))] [OperationContract] diff --git a/Service/ServiceImplementations/AiEnhancedServiceImp.cs b/Service/ServiceImplementations/AiEnhancedServiceImp.cs index 43f98f2ce..6b32b6df4 100644 --- a/Service/ServiceImplementations/AiEnhancedServiceImp.cs +++ b/Service/ServiceImplementations/AiEnhancedServiceImp.cs @@ -1,5 +1,6 @@ using BeWo.Service.Plugins; using BeWo.Service.ServiceContracts; +using BS.Shared; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Feature.AI; using System.Collections.Generic; @@ -13,7 +14,7 @@ namespace BeWo.Service.ServiceImplementations public AiConfigDC GetAiConfig() => GetAiService().GetAiConfig(); public AiConfigDC UpdateAiConfig(AiConfigDC toUpdate) => GetAiService().UpdateAiConfig(toUpdate); public IEnumerable GetAiModels() => GetAiService().GetAiModels(); - public IEnumerable GetAiConversations(int uicontext, long? oid) => GetAiService().GetAiConversations(uicontext, oid); + public IEnumerable GetAiConversations(AiContextType uicontext, long? oid) => GetAiService().GetAiConversations(uicontext, oid); public AiConversationDC CreateAiConversation(AiConversationDC conversation, long modell_oid) => GetAiService().CreateAiConversation(conversation, modell_oid); public AiConversationDC CreateAiConversationWithMessage(AiConversationDC conversation, long modell_oid, string message) => GetAiService().CreateAiConversationWithMessage(conversation, modell_oid, message); public AiConversationDC CloneAiConversation(long conversation_oid, long? last_message_oid) => GetAiService().CloneAiConversation(conversation_oid, last_message_oid); diff --git a/Shared/Exceptions/BeWoNotImplementedException.cs b/Shared/Exceptions/BeWoNotImplementedException.cs index bfa7bc210..51979a424 100644 --- a/Shared/Exceptions/BeWoNotImplementedException.cs +++ b/Shared/Exceptions/BeWoNotImplementedException.cs @@ -32,5 +32,13 @@ namespace BS.Shared.Exceptions return new BeWoNotImplementedException($"{type} {value} ist nicht implementiert."); } + + public static BeWoNotImplementedException CreateFromInvalidObject(object obj) + { + var type = obj.GetType().Name; + var str = obj.ToString(); + + return new BeWoNotImplementedException($"{type}, {str}"); + } } }