Laden über DC

Feature - Data getrennt
Feature <<< AICore
AICore: Verbindung BeWoPlaner -> MikeAiService
This commit is contained in:
2025-09-03 13:40:35 +02:00
parent 625ec07445
commit 9da8c92ca7
47 changed files with 830 additions and 316 deletions

View File

@@ -112,10 +112,6 @@
<EmbeddedResource Include="Prompt\SystemPrompts\system_prompt3.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Server\ApiFacade\ApiFacade.csproj">
<Project>{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}</Project>
<Name>ApiFacade</Name>
</ProjectReference>
<ProjectReference Include="..\ServiceUtils\ServiceUtils.csproj">
<Project>{EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57}</Project>
<Name>ServiceUtils</Name>

View File

@@ -2,7 +2,7 @@
using AICore.Context.EntryMapper;
using AICore.Context.EntryMapper.Detail;
using AICore.Context.EntryMapper.Navigation;
using BeWo.Data.Entities;
using BS.Shared.DataContracts.Compact;
namespace AICore.Context.Core
{
@@ -21,6 +21,6 @@ namespace AICore.Context.Core
public static SupportConceptNavigationContextEntryMapper SupportConceptNavigationMapper { get; } = new SupportConceptNavigationContextEntryMapper();
public static ServiceRecordContextEntryMapper ServiceRecordMapper { get; } = new ServiceRecordContextEntryMapper();
public static BaseContextEntryMapper<Customer, CustomerNavigationContextEntry> ServiceRecordCustomerMapper { get; } = new CustomerNavigationContextEntryMapper();
public static BaseContextEntryMapper<CompactCustomerDC, CustomerNavigationContextEntry> ServiceRecordCustomerMapper { get; } = new CustomerNavigationContextEntryMapper();
}
}

View File

@@ -2,7 +2,8 @@
using AICore.Context.Entry;
using AICore.Context.Entry.Navigation;
using AICore.Context.Summary;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Exceptions;
using System.Collections.Generic;
@@ -12,19 +13,19 @@ namespace AICore.Context.SummaryMapper
{
public static DetailContextSummary<TEntry, TEntity> CreateDetailContext<TEntry, TEntity>(TEntity entity)
where TEntry : DetailContextEntry<TEntity>
where TEntity : BeWoEntityBase, new()
where TEntity : IDataContract, new()
{
object obj = null;
if (entity is Customer customer)
if (entity is CustomerDC customer)
obj = CreateCustomerDetailContextSummary(customer);
else if (entity is Employee employee)
else if (entity is EmployeeDC employee)
obj = CreateEmployeeDetailContextSummary(employee);
else if (entity is Person person)
else if (entity is PersonDC person)
obj = CreatePersonDetailContextSummary(person);
else if (entity is Organisation organisation)
else if (entity is OrganisationDC organisation)
obj = CreateOrganisationDetailContextSummary(organisation);
else if (entity is SupportConcept support)
else if (entity is SupportConceptDC support)
obj = CreateSupportConceptDetailContextSummary(support);
if (obj == null)
@@ -35,19 +36,19 @@ namespace AICore.Context.SummaryMapper
public static NavigationContextSummary<TEntry, TEntity> CreateNavigationContext<TEntry, TEntity>(IEnumerable<TEntity> entities)
where TEntry : NavigationContextEntry<TEntity>
where TEntity : BeWoEntityBase, new()
where TEntity : IDataContract, new()
{
object obj = null;
if (entities is IEnumerable<Customer> customer)
if (entities is IEnumerable<CompactCustomerDC> customer)
obj = CreateCustomerNavigationContextSummary(customer);
else if (entities is IEnumerable<Employee> employee)
else if (entities is IEnumerable<CompactEmployeeDC> employee)
obj = CreateEmployeeNavigationContextSummary(employee);
else if (entities is IEnumerable<Person> person)
else if (entities is IEnumerable<CompactPersonDC> person)
obj = CreatePersonNavigationContextSummary(person);
else if (entities is IEnumerable<Organisation> organisation)
else if (entities is IEnumerable<CompactOrganisationDC> organisation)
obj = CreateOrganisationNavigationContextSummary(organisation);
else if (entities is IEnumerable<SupportConcept> support)
else if (entities is IEnumerable<CompactSupportConceptDC> support)
obj = CreateSupportConceptNavigationContextSummary(support);
if (obj == null)
@@ -56,7 +57,7 @@ namespace AICore.Context.SummaryMapper
return obj as NavigationContextSummary<TEntry, TEntity>;
}
public static ServiceRecordNavigationContextSummary CreateServiceRecordNavigationContextSummary(IEnumerable<ServiceRecord> serviceRecords, Customer customer, string costBearer, string supportConcept)
public static ServiceRecordNavigationContextSummary CreateServiceRecordNavigationContextSummary(IEnumerable<ServiceRecordDC> serviceRecords, CompactCustomerDC customer, string costBearer, string supportConcept)
{
var entries = ContextEntryMapperFactory.ServiceRecordMapper.MapToNewContexts(serviceRecords);
var customer_entry = ContextEntryMapperFactory.ServiceRecordCustomerMapper.MapToNewContext(customer);
@@ -64,70 +65,70 @@ namespace AICore.Context.SummaryMapper
return new ServiceRecordNavigationContextSummary(entries, customer_entry, costBearer, supportConcept);
}
private static CustomerDetailContextSummary CreateCustomerDetailContextSummary(Customer customer)
private static CustomerDetailContextSummary CreateCustomerDetailContextSummary(CustomerDC customer)
{
var entry = ContextEntryMapperFactory.CustomerMapper.MapToNewContext(customer);
return new CustomerDetailContextSummary(entry);
}
private static EmployeeDetailContextSummary CreateEmployeeDetailContextSummary(Employee employee)
private static EmployeeDetailContextSummary CreateEmployeeDetailContextSummary(EmployeeDC employee)
{
var entry = ContextEntryMapperFactory.EmployeeMapper.MapToNewContext(employee);
return new EmployeeDetailContextSummary(entry);
}
private static PersonDetailContextSummary CreatePersonDetailContextSummary(Person person)
private static PersonDetailContextSummary CreatePersonDetailContextSummary(PersonDC person)
{
var entry = ContextEntryMapperFactory.PersonMapper.MapToNewContext(person);
return new PersonDetailContextSummary(entry);
}
private static OrganisationDetailContextSummary CreateOrganisationDetailContextSummary(Organisation organisation)
private static OrganisationDetailContextSummary CreateOrganisationDetailContextSummary(OrganisationDC organisation)
{
var entry = ContextEntryMapperFactory.OrganisationMapper.MapToNewContext(organisation);
return new OrganisationDetailContextSummary(entry);
}
private static SupportConceptDetailContextSummary CreateSupportConceptDetailContextSummary(SupportConcept supportConcept)
private static SupportConceptDetailContextSummary CreateSupportConceptDetailContextSummary(SupportConceptDC supportConcept)
{
var entry = ContextEntryMapperFactory.SupportConceptMapper.MapToNewContext(supportConcept);
return new SupportConceptDetailContextSummary(entry);
}
private static CustomerNavigationContextSummary CreateCustomerNavigationContextSummary(IEnumerable<Customer> customer)
private static CustomerNavigationContextSummary CreateCustomerNavigationContextSummary(IEnumerable<CompactCustomerDC> customer)
{
var entry = ContextEntryMapperFactory.CustomerNavigationMapper.MapToNewContexts(customer);
return new CustomerNavigationContextSummary(entry);
}
private static EmployeeNavigationContextSummary CreateEmployeeNavigationContextSummary(IEnumerable<Employee> employee)
private static EmployeeNavigationContextSummary CreateEmployeeNavigationContextSummary(IEnumerable<CompactEmployeeDC> employee)
{
var entry = ContextEntryMapperFactory.EmployeeNavigationMapper.MapToNewContexts(employee);
return new EmployeeNavigationContextSummary(entry);
}
private static PersonNavigationContextSummary CreatePersonNavigationContextSummary(IEnumerable<Person> person)
private static PersonNavigationContextSummary CreatePersonNavigationContextSummary(IEnumerable<CompactPersonDC> person)
{
var entry = ContextEntryMapperFactory.PersonNavigationMapper.MapToNewContexts(person);
return new PersonNavigationContextSummary(entry);
}
private static OrganisationNavigationContextSummary CreateOrganisationNavigationContextSummary(IEnumerable<Organisation> organisation)
private static OrganisationNavigationContextSummary CreateOrganisationNavigationContextSummary(IEnumerable<CompactOrganisationDC> organisation)
{
var entry = ContextEntryMapperFactory.OrganisationNavigationMapper.MapToNewContexts(organisation);
return new OrganisationNavigationContextSummary(entry);
}
private static SupportConceptNavigationContextSummary CreateSupportConceptNavigationContextSummary(IEnumerable<SupportConcept> supportConcept)
private static SupportConceptNavigationContextSummary CreateSupportConceptNavigationContextSummary(IEnumerable<CompactSupportConceptDC> supportConcept)
{
var entry = ContextEntryMapperFactory.SupportConceptNavigationMapper.MapToNewContexts(supportConcept);

View File

@@ -1,10 +1,10 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
using System;
using System.Text.Json.Serialization;
namespace AICore.Context.Entry
{
public class CustomerDetailContextEntry : DetailContextEntry<Customer>
public class CustomerDetailContextEntry : DetailContextEntry<CustomerDC>
{
[JsonPropertyName("Klient-ID")]
public long CustomerOid { get; set; }

View File

@@ -1,8 +1,8 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.Entry
{
public class EmployeeDetailContextEntry : DetailContextEntry<Employee>
public class EmployeeDetailContextEntry : DetailContextEntry<EmployeeDC>
{
}

View File

@@ -1,8 +1,8 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.Entry
{
public class OrganisationDetailContextEntry : DetailContextEntry<Organisation>
public class OrganisationDetailContextEntry : DetailContextEntry<OrganisationDC>
{
}

View File

@@ -1,8 +1,8 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.Entry
{
public class PersonDetailContextEntry : DetailContextEntry<Person>
public class PersonDetailContextEntry : DetailContextEntry<PersonDC>
{
}

View File

@@ -1,8 +1,8 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.Entry
{
public class SupportConceptDetailContextEntry : DetailContextEntry<SupportConcept>
public class SupportConceptDetailContextEntry : DetailContextEntry<SupportConceptDC>
{
}

View File

@@ -1,10 +1,10 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts.Compact;
using System;
using System.Text.Json.Serialization;
namespace AICore.Context.Entry.Navigation
{
public class CustomerNavigationContextEntry : NavigationContextEntry<Customer>
public class CustomerNavigationContextEntry : NavigationContextEntry<CompactCustomerDC>
{
[JsonPropertyName("Adresse")]
public string AddressString { get; set; }

View File

@@ -1,9 +1,9 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts.Compact;
using System.Text.Json.Serialization;
namespace AICore.Context.Entry.Navigation
{
public class EmployeeNavigationContextEntry : NavigationContextEntry<Employee>
public class EmployeeNavigationContextEntry : NavigationContextEntry<CompactEmployeeDC>
{
[JsonPropertyName("Mitarbeiter-ID")]
public long EmployeeOid { get; set; }

View File

@@ -1,9 +1,9 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts.Compact;
using System.Text.Json.Serialization;
namespace AICore.Context.Entry.Navigation
{
public class OrganisationNavigationContextEntry : NavigationContextEntry<Organisation>
public class OrganisationNavigationContextEntry : NavigationContextEntry<CompactOrganisationDC>
{
[JsonPropertyName("Organisation-ID")]
public long OrganisationOid { get; set; }

View File

@@ -1,10 +1,10 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts.Compact;
using System;
using System.Text.Json.Serialization;
namespace AICore.Context.Entry.Navigation
{
public class PersonNavigationContextEntry : NavigationContextEntry<Person>
public class PersonNavigationContextEntry : NavigationContextEntry<CompactPersonDC>
{
[JsonPropertyName("Adresse")]
public string AddressString { get; set; }

View File

@@ -1,10 +1,10 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
using System;
using System.Text.Json.Serialization;
namespace AICore.Context.Entry.Navigation
{
public class ServiceRecordContextEntry : NavigationContextEntry<ServiceRecord>
public class ServiceRecordContextEntry : NavigationContextEntry<ServiceRecordDC>
{
[JsonPropertyName("Zeiteintrag-ID")]
public long ServiceRecordOid { get; set; }

View File

@@ -1,10 +1,10 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts.Compact;
using System;
using System.Text.Json.Serialization;
namespace AICore.Context.Entry.Navigation
{
public class SupportConceptNavigationContextEntry : NavigationContextEntry<SupportConcept>
public class SupportConceptNavigationContextEntry : NavigationContextEntry<CompactSupportConceptDC>
{
[JsonPropertyName("Hilfeplan-ID")]
public long SupportConceptOid { get; set; }

View File

@@ -1,35 +1,36 @@
using AICore.Context.Entry;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
namespace AICore.Context.EntryMapper.Detail
{
public class CustomerContextEntryMapper : BaseContextEntryMapper<Customer, CustomerDetailContextEntry>
public class CustomerContextEntryMapper : BaseContextEntryMapper<CustomerDC, CustomerDetailContextEntry>
{
public override void MergeWithObject(Customer pObject, CustomerDetailContextEntry pContext)
public override void MergeWithObject(CustomerDC pObject, CustomerDetailContextEntry pContext)
{
pContext.CustomerOid = pObject.Oid ?? 0;
pContext.FullName = pObject.Person.FirstNameLastName;
pContext.CustomerOid = pObject.CustomerOid ?? -2;
pContext.FullName = pObject.GetLastNameFirstName();
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 ?? "null";
pContext.FamilyStatus = pObject.Person.FamilyStatus?.ToString() ?? "null";
pContext.Profession = pObject.Person.Profession;
pContext.DateOfBirth = pObject.DateOfBirth;
pContext.Sex = pObject.Sex?.ToString() ?? "null";
pContext.NationalitaetDisplayName = pObject.Nationalitaet?.TypeDescription ?? "null";
pContext.IsMigrant = pObject.IsMigrant;
pContext.Migrationshintergrund = pObject.Migrationshintergrund;
pContext.AufenthaltsStatusDisplayName = pObject.AufenthaltsStatus?.TypeDescription ?? "null";
pContext.FamilyStatus = pObject.FamilyStatus?.ToString() ?? "null";
pContext.Profession = pObject.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.AddressLine1 = pObject.AddressLine1;
pContext.Street = pObject.Street;
pContext.PostalCode = pObject.PostalCode;
pContext.Town = pObject.Town;
pContext.DistanceInMeter = pObject.DistanceInMeter;
pContext.InvoiceAddress = pObject.Person.InvoiceAddress?.ToSingleLine() ?? "null";
pContext.InvoiceAddress = pObject.GetInvoiceAddressSingleLine() ?? "null";
}
}
}

View File

@@ -1,13 +1,13 @@
using System;
using System.Linq;
using AICore.Context.Entry;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.EntryMapper.Detail
{
public class EmployeeContextEntryMapper : BaseContextEntryMapper<Employee, EmployeeDetailContextEntry>
public class EmployeeContextEntryMapper : BaseContextEntryMapper<EmployeeDC, EmployeeDetailContextEntry>
{
public override void MergeWithObject(Employee pObject, EmployeeDetailContextEntry pContext)
public override void MergeWithObject(EmployeeDC pObject, EmployeeDetailContextEntry pContext)
{
throw new NotImplementedException();
}

View File

@@ -1,13 +1,13 @@
using System;
using System.Linq;
using AICore.Context.Entry;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.EntryMapper.Detail
{
public class OrganisationContextEntryMapper : BaseContextEntryMapper<Organisation, OrganisationDetailContextEntry>
public class OrganisationContextEntryMapper : BaseContextEntryMapper<OrganisationDC, OrganisationDetailContextEntry>
{
public override void MergeWithObject(Organisation pObject, OrganisationDetailContextEntry pContext)
public override void MergeWithObject(OrganisationDC pObject, OrganisationDetailContextEntry pContext)
{
throw new NotImplementedException();
}

View File

@@ -1,13 +1,13 @@
using System;
using System.Linq;
using AICore.Context.Entry;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.EntryMapper.Detail
{
public class PersonContextEntryMapper : BaseContextEntryMapper<Person, PersonDetailContextEntry>
public class PersonContextEntryMapper : BaseContextEntryMapper<PersonDC, PersonDetailContextEntry>
{
public override void MergeWithObject(Person pObject, PersonDetailContextEntry pContext)
public override void MergeWithObject(PersonDC pObject, PersonDetailContextEntry pContext)
{
throw new NotImplementedException();
}

View File

@@ -1,19 +1,19 @@
using System;
using System.Linq;
using AICore.Context.Entry.Navigation;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.EntryMapper.Detail
{
public class ServiceRecordContextEntryMapper : BaseContextEntryMapper<ServiceRecord, ServiceRecordContextEntry>
public class ServiceRecordContextEntryMapper : BaseContextEntryMapper<ServiceRecordDC, ServiceRecordContextEntry>
{
public override void MergeWithObject(ServiceRecord pObject, ServiceRecordContextEntry pContext)
public override void MergeWithObject(ServiceRecordDC pObject, ServiceRecordContextEntry pContext)
{
pContext.ServiceRecordOid = pObject.Oid.Value;
pContext.ServiceRecordOid = pObject.ServiceRecordOid.Value;
pContext.Start = pObject.Start;
pContext.End = pObject.End;
pContext.DurationInMinuten = pObject.DurationMinutes;
pContext.CategoryName = pObject.ServiceDescription.ServiceCategory.Name;
pContext.DurationInMinuten = GetDurationMinutes(pObject);
pContext.CategoryName = pObject.ServiceDescription.CategoryName;
pContext.DescriptionName = pObject.ServiceDescription.Name;
pContext.Notice = pObject.Notice;
pContext.Notice2 = pObject.Notice2;
@@ -21,10 +21,22 @@ namespace AICore.Context.EntryMapper.Detail
pContext.Notice4 = pObject.Notice4;
pContext.Notice5 = pObject.Notice5;
pContext.DistanceInMeter = pObject.DistanceInMeter;
pContext.InsertedOn = pObject.InsTs.Value;
pContext.InsertedOn = pObject.InsertedOn.Value;
pContext.Betrag = pObject.Betrag;
pContext.InsUser = pObject.InsUser;
pContext.Employee = pObject.Employee.Person.FirstNameLastName;
pContext.Employee = pObject.Employee.FirstNameLastName;
}
public virtual double GetDurationMinutes(ServiceRecordDC pObject)
{
if (pObject.GroupOid.HasValue)
{
return (double)pObject.RoundedDuration;
}
else
{
return (pObject.End.Value - pObject.Start.Value).TotalMinutes;
}
}
}
}

View File

@@ -1,13 +1,13 @@
using System;
using System.Linq;
using AICore.Context.Entry;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
namespace AICore.Context.EntryMapper.Detail
{
public class SupportConceptContextEntryMapper : BaseContextEntryMapper<SupportConcept, SupportConceptDetailContextEntry>
public class SupportConceptContextEntryMapper : BaseContextEntryMapper<SupportConceptDC, SupportConceptDetailContextEntry>
{
public override void MergeWithObject(SupportConcept pObject, SupportConceptDetailContextEntry pContext)
public override void MergeWithObject(SupportConceptDC pObject, SupportConceptDetailContextEntry pContext)
{
throw new NotImplementedException();
}

View File

@@ -1,19 +1,20 @@
using System;
using System.Linq;
using AICore.Context.Entry.Navigation;
using BeWo.Data.Entities;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
namespace AICore.Context.EntryMapper.Navigation
{
public class CustomerNavigationContextEntryMapper : BaseContextEntryMapper<Customer, CustomerNavigationContextEntry>
public class CustomerNavigationContextEntryMapper : BaseContextEntryMapper<CompactCustomerDC, CustomerNavigationContextEntry>
{
public override void MergeWithObject(Customer pObject, CustomerNavigationContextEntry pContext)
public override void MergeWithObject(CompactCustomerDC pObject, CustomerNavigationContextEntry pContext)
{
pContext.AddressString = pObject.Person.Address?.ToSingleLine() ?? "null";
pContext.AddressString = pObject.GetSingleAddressLine() ?? "null";
pContext.CustomerAlias = pObject.CustomerAlias;
pContext.CustomerOid = pObject.Oid.Value;
pContext.DateOfBirth = pObject.Person.DateOfBirth;
pContext.FullName = pObject.Person.FirstNameLastName;
pContext.DateOfBirth = pObject.DateOfBirth;
pContext.FullName = pObject.GetLastNameFirstName();
pContext.Teams = "CustomerService";
pContext.Bezugspersonen = "CustomerService";
}

View File

@@ -2,82 +2,20 @@
using System.Collections.Generic;
using System.Linq;
using AICore.Context.Entry.Navigation;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BS.Shared.DataContracts.Compact;
using BS.Shared.DataContracts;
using BeWo.Data.Security;
using BS.Shared;
using BS.Shared.Extensions;
namespace AICore.Context.EntryMapper.Navigation
{
public class EmployeeNavigationContextEntryMapper : BaseContextEntryMapper<Employee, EmployeeNavigationContextEntry>
public class EmployeeNavigationContextEntryMapper : BaseContextEntryMapper<CompactEmployeeDC, EmployeeNavigationContextEntry>
{
public override void MergeWithObject(Employee pObject, EmployeeNavigationContextEntry pContext)
public override void MergeWithObject(CompactEmployeeDC pObject, EmployeeNavigationContextEntry pContext)
{
pContext.EmployeeOid = pObject.Oid.Value;
pContext.EmployeeOid = pObject.EmployeeOid;
pContext.PersonnelNumber = pObject.PersonnelNumber;
pContext.FirstNameLastName = pObject.Person.FirstNameLastName;
pContext.FirstNameLastName = pObject.GetFirstNameLastName();
}
//public virtual List<CompactEmployeeDC> GetAllCompactEmployees()
//{
// var employees = DAOFactory.GenericDAO.GetAll<Employee>();
// var teams = GetAllTeamsCompact();
// foreach (var employee in employees)
// {
// var team_oids = new List<long>();
// foreach (var team in teams)
// {
// if (team.MemberList.Contains(employee))
// {
// var team_oid = team.Oid.Value;
// team_oids.Add(team_oid);
// }
// }
// if (team_oids.Count > 0)
// {
// foreach (var oid in dc.TeamOids)
// {
// var team = teamDCs.FirstOrDefault(t => t.TeamOid == oid);
// if (team != null)
// {
// if (dc.RelatedTeams == null)
// dc.RelatedTeams = "Teams: " + team.Name + ", ";
// else
// dc.RelatedTeams += team.Name + ", ";
// }
// }
// }
// }
// return dcs;
//}
//public virtual IEnumerable<Team> GetAllTeamsCompact()
//{
// var loggedInUser = UserRightHelper.GetLoggedInUser();
// if (UserRightHelper.UserHasRight(loggedInUser, UserRightType.TeamView_ViewAll))
// {
// return DAOFactory.GenericDAO.GetAllActive<Team>();
// }
// if (UserRightHelper.UserHasRight(loggedInUser, UserRightType.TeamView_ViewMyTeams))
// {
// var teams = DAOFactory.SearchDAO.FindAllActiveTeamsOfEmployee(loggedInUser.Employee.Oid.Value);
// return teams;
// }
// return new List<Team>();
//}
}
}

View File

@@ -1,18 +1,19 @@
using System;
using System.Linq;
using AICore.Context.Entry.Navigation;
using BeWo.Data.Entities;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
namespace AICore.Context.EntryMapper.Navigation
{
public class OrganisationNavigationContextEntryMapper : BaseContextEntryMapper<Organisation, OrganisationNavigationContextEntry>
public class OrganisationNavigationContextEntryMapper : BaseContextEntryMapper<CompactOrganisationDC, OrganisationNavigationContextEntry>
{
public override void MergeWithObject(Organisation pObject, OrganisationNavigationContextEntry pContext)
public override void MergeWithObject(CompactOrganisationDC pObject, OrganisationNavigationContextEntry pContext)
{
pContext.OrganisationOid = pObject.Oid.Value;
pContext.OrganisationOid = pObject.OrganisationOid;
pContext.Name = pObject.Name;
pContext.Funktion = pObject.Function?.Value;
pContext.AddressString = pObject.Address?.ToSingleLine() ?? "null";
pContext.Funktion = pObject.Function;
pContext.AddressString = pObject.GetSingleAddressLine();
pContext.IKDatenannahmestelle = pObject.IKDatenannahmestelle;
pContext.IKKostentrager = pObject.IKKostentrager;
pContext.IKKrankenkasse = pObject.IKKrankenkasse;

View File

@@ -1,28 +1,28 @@
using System;
using System.Linq;
using AICore.Context.Entry.Navigation;
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
using BS.Shared;
using BS.Shared.Extensions;
using BS.Shared.DataContracts.Compact;
namespace AICore.Context.EntryMapper.Navigation
{
public class PersonNavigationContextEntryMapper : BaseContextEntryMapper<Person, PersonNavigationContextEntry>
public class PersonNavigationContextEntryMapper : BaseContextEntryMapper<CompactPersonDC, PersonNavigationContextEntry>
{
public override void MergeWithObject(Person pObject, PersonNavigationContextEntry pContext)
public override void MergeWithObject(CompactPersonDC pObject, PersonNavigationContextEntry pContext)
{
pContext.AddressString = pObject.Address?.ToSingleLine() ?? "null";
pContext.AddressString = pObject.GetSingleAddressLine() ?? "null";
//pContext.DateOfBirth = pObject.DateOfBirth;
pContext.FullName = pObject.LastNameFirstName;
pContext.Title = pObject.Title?.Value;
pContext.FullName = pObject.GetLastNameFirstName();
pContext.Title = pObject.Title;
//pContext.Geschlecht = pObject.Sex?.ToString();
pContext.Function = pObject.Function?.Value;
pContext.Function = pObject.Function;
pContext.Tel = pObject.Contacts.GetPrivatePhoneNumber();
pContext.Fax = pObject.Contacts.GetPrivateFaxNumber();
pContext.Mobil = pObject.Contacts.GetPrivateMobilePhoneNumber();
pContext.Email = pObject.Contacts.GetPrivateMailNumber();
pContext.Tel = pObject.Communication1;
pContext.Mobil = pObject.Communication2;
pContext.Email = pObject.Communication3;
pContext.Fax = pObject.Communication4;
}
}
}

View File

@@ -4,96 +4,22 @@ using System.Linq;
using System.Text;
using AICore.Context.Core;
using AICore.Context.Entry.Navigation;
using BeWo.Data.Entities;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
namespace AICore.Context.EntryMapper.Navigation
{
public class SupportConceptNavigationContextEntryMapper : BaseContextEntryMapper<SupportConcept, SupportConceptNavigationContextEntry>
public class SupportConceptNavigationContextEntryMapper : BaseContextEntryMapper<CompactSupportConceptDC, SupportConceptNavigationContextEntry>
{
public override void MergeWithObject(SupportConcept pObject, SupportConceptNavigationContextEntry pContext)
public override void MergeWithObject(CompactSupportConceptDC pObject, SupportConceptNavigationContextEntry pContext)
{
pContext.SupportConceptOid = pObject.Oid.Value;
pContext.AddressString = pObject.Customer.Person.Address.ToSingleLine();
pContext.CostBearerDetailStrings = CreateCostBearerDetailStrings(pObject).ToArray();
pContext.CustomerName = pObject.Customer.Person.LastNameFirstName;
pContext.SupportConceptOid = pObject.SupportConceptOid;
pContext.AddressString = pObject.Customer.GetSingleAddressLine();
pContext.CostBearerDetailStrings = pObject.CostBearerDetailStrings?.ToArray();
pContext.CustomerName = pObject.Customer.GetFirstNameLastName();
pContext.CustomerAlias = pObject.Customer.CustomerAlias;
pContext.CustomerDateOfBirth = pObject.Customer.Person.DateOfBirth;
pContext.CustomerPostcode = pObject.Customer.Person.Address.PostalCode;
}
private List<string> CreateCostBearerDetailStrings(SupportConcept pObject)
{
var rtn = new List<string>();
foreach (var cb2sc in pObject.CostBearer2SupportConceptList)
{
DateTime? from = null;
DateTime? to = null;
from = cb2sc.ApprovedStartDate;
to = cb2sc.ApprovedEndDate;
if (from == null)
{
from = cb2sc.RequestedStartDate;
}
if (to == null)
{
to = cb2sc.RequestedEndDate;
}
StringBuilder cbstr = new StringBuilder();
if (from != null && to != null)
{
cbstr.Append(from.Value.ToShortDateString());
cbstr.Append(" - ");
cbstr.Append(to.Value.ToShortDateString());
}
if (pObject.Customer.TerminationDate.HasValue)
{
String grund = "";
if (!String.IsNullOrEmpty(pObject.Customer.TerminationReason?.Value))
{
grund = ", Begründung: " + pObject.Customer.TerminationReason.Value;
}
cbstr.Append(String.Format(" (Betreuung beendet am: {0:dd.MM.yyyy}{1})", pObject.Customer.TerminationDate, grund));
}
if (cbstr.Length > 0)
{
cbstr.Append(" ");
}
if (cb2sc.CostBearer.Organisation != null)
{
cbstr.Append(cb2sc.CostBearer.Organisation.Name);
}
if (cb2sc.ApprovedStartDate == null)
{
cbstr.Append(" nicht bewilligt!");
}
String str = cbstr.ToString();
if (!String.IsNullOrEmpty(cb2sc.CustomerReferenceNumber))
{
str = String.Format("{0}, {1}", str, cb2sc.CustomerReferenceNumber);
}
if (!String.IsNullOrEmpty(cb2sc.AuswahlBezeichnung))
{
str = String.Format("{0} {1}", cb2sc.AuswahlBezeichnung, str);
}
rtn.Add(str);
}
return rtn;
pContext.CustomerDateOfBirth = pObject.Customer.DateOfBirth;
pContext.CustomerPostcode = pObject.Customer.PostalCode;
}
}
}

View File

@@ -1,7 +1,6 @@
using BeWo.ServiceUtils.Core;
using BS.Shared.DataContracts.Feature.AI;
using BS.Shared.DataContracts;
using BS.Shared.Interface;
using System;
using System.Collections.Generic;
using System.IO;

View File

@@ -7,7 +7,7 @@ using System;
using System.Linq;
using System.Net.Sockets;
using System.Net;
using BeWo.Server.ApiFacade.Core;
using BS.Shared.ApiFacade;
namespace AICore.Facade.LLM
{

View File

@@ -1,4 +1,4 @@
using BeWo.Data.Entities;
using BS.Shared.DataContracts;
using BS.Shared.Exceptions;
using System.Collections.Generic;
@@ -6,7 +6,7 @@ namespace AICore.Prompt.Core
{
public static class AiUtils
{
public static void CheckTokenSize(IList<AiConversationMessage> messages, string modelName, int max_context_size)
public static void CheckTokenSize(IList<AiConversationMessageDC> messages, string modelName, int max_context_size)
{
var buffer = 500;
@@ -28,7 +28,7 @@ namespace AICore.Prompt.Core
}
}
private static int CalculateTokensByModel(IList<AiConversationMessage> messages, string modelName)
private static int CalculateTokensByModel(IList<AiConversationMessageDC> messages, string modelName)
{
var count = 0;

View File

@@ -3,7 +3,6 @@ using BeWo.ViewModel.ListViewModel;
using BS.Shared.DataContracts;
using BS.Shared;
using BS.Shared.DataContracts.Light;
using BS.Shared.Interface;
using BS.Shared.Translation;
using System;
using System.Collections.Generic;

View File

@@ -53,8 +53,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AI", "AI", "{084C391D-FCE1-
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AiCoreUnitTest", "AiCoreUnitTest\AiCoreUnitTest.csproj", "{68C1F8EA-7828-4E46-8F04-91105C55860E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiFacade", "Server\ApiFacade\ApiFacade.csproj", "{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
@@ -237,18 +235,6 @@ Global
{68C1F8EA-7828-4E46-8F04-91105C55860E}.Release|Any CPU.Build.0 = Release|Any CPU
{68C1F8EA-7828-4E46-8F04-91105C55860E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{68C1F8EA-7828-4E46-8F04-91105C55860E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}.Debug|.NET.ActiveCfg = Debug|Any CPU
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}.Debug|.NET.Build.0 = Debug|Any CPU
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}.Release|.NET.ActiveCfg = Release|Any CPU
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}.Release|.NET.Build.0 = Release|Any CPU
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}.Release|Any CPU.Build.0 = Release|Any CPU
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -272,7 +258,6 @@ Global
{EC2349FB-7FE0-4AD1-B28B-A7A27AF80A57} = {FEB0336B-F053-40B6-92DD-7DE56AB9408A}
{084C391D-FCE1-4984-87FA-F8F9CFCC6A4F} = {CCD6B644-49E7-4A11-BD8F-607088A4AC83}
{68C1F8EA-7828-4E46-8F04-91105C55860E} = {084C391D-FCE1-4984-87FA-F8F9CFCC6A4F}
{4B2F3959-3CDA-4514-83A2-FA3C24E57BB7} = {FEB0336B-F053-40B6-92DD-7DE56AB9408A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5352BE53-F2FD-442F-85A8-4157599AA153}

View File

@@ -58,21 +58,5 @@ namespace BeWo.Data.Entities
{
return string.IsNullOrWhiteSpace(Street + Town + PostalCode);
}
public virtual string ToSingleLine()
{
var parts = new List<string>
{
AddressLine1,
AddressLine2,
Street,
PostalCode,
Town,
State,
Country
};
return string.Join(", ", parts.Where(p => !string.IsNullOrWhiteSpace(p)));
}
}
}

View File

@@ -5,7 +5,6 @@ using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.DataContracts.Light;
using BS.Shared.Extensions;
using BS.Shared.Interface;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@@ -0,0 +1,231 @@
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.Exceptions;
using BS.Shared.Interface;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Security;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace BS.Shared.ApiFacade
{
public class HttpClientFacade
{
public HttpClientFacade(string base_url, string api_key, bool directConntect = true)
{
if (string.IsNullOrEmpty(base_url))
throw new ArgumentNullException("HttpClient: base_url is missing");
if (string.IsNullOrWhiteSpace(api_key))
throw new ArgumentNullException("HttpClient: token is missing");
Base_Url = base_url;
SetToken(api_key);
DirectConnect = directConntect;
}
public bool DirectConnect { get; private set; }
public string Base_Url { get; private set; }
public HttpMethod Method { get; set; } = HttpMethod.Get;
public Dictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
public Dictionary<string, string> Parameters { get; set; } = new Dictionary<string, string>();
public string ContentType { get; set; } = "application/x-www-form-urlencoded";
public Encoding Encoding { get; set; } = Encoding.UTF8;
public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(30);
/// <summary>
/// Führt einen Request aus, erwartet einen komplexen Datentyp: Schaue Verweise für Beispiele.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="method"></param>
/// <param name="anonymousType"></param>
/// <param name="extractor"></param>
/// <returns></returns>
public virtual async Task<ApiResponse<T>> GetAnonymousTypeAsync<T>(string method, T anonymousType, IApiErrorExtractor extractor)
{
var http_response = await getResponseAsync(method).ConfigureAwait(false);
if (!http_response.IsSuccessStatusCode)
{
return ApiResponse<T>.FailureResponse(AppError.ApiResponseFailed, http_response.ReasonPhrase, (int)http_response.StatusCode);
}
var json = await http_response.Content.ReadAsStringAsync().ConfigureAwait(false);
return parse(() => JsonConvert.DeserializeAnonymousType<T>(json, anonymousType), json, extractor);
}
/// <summary>
/// Führt einen Request aus, erwartet einen einfachen Datentyp wie: string, int, decimal, byte[] -
/// Liste kann gerne erweitert werden
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="method"></param>
/// <param name="extractor"></param>
/// <returns></returns>
/// <exception cref="BeWoInvalidOperationException"></exception>
public virtual async Task<ApiResponse<T>> GetAsync<T>(string method, IApiErrorExtractor extractor)
{
var http_response = await getResponseAsync(method).ConfigureAwait(false);
if (!http_response.IsSuccessStatusCode)
{
return ApiResponse<T>.FailureResponse(AppError.ApiResponseFailed, http_response.ReasonPhrase, (int)http_response.StatusCode);
}
var content = await http_response.Content.ReadAsStringAsync().ConfigureAwait(false);
object result;
var type = typeof(T);
if (type == typeof(string))
{
result = content;
}
else if (type == typeof(int))
{
result = int.Parse(content);
}
else if (type == typeof(decimal))
{
result = decimal.Parse(content);
}
else if (type == typeof(byte[]))
{
result = await http_response.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
}
else
{
throw new BeWoInvalidOperationException(AppError.UnsupportedType(typeof(T)));
}
return parse(() => (T)result, content, extractor);
}
private static bool ServerCertificateCustomValidation(HttpRequestMessage requestMessage, X509Certificate2 certificate, X509Chain chain, SslPolicyErrors sslErrors)
{
// It is possible to inspect the certificate provided by the server.
Console.WriteLine($"Requested URI: {requestMessage.RequestUri}");
Console.WriteLine($"Effective date: {certificate?.GetEffectiveDateString()}");
Console.WriteLine($"Exp date: {certificate?.GetExpirationDateString()}");
Console.WriteLine($"Issuer: {certificate?.Issuer}");
Console.WriteLine($"Subject: {certificate?.Subject}");
// Based on the custom logic it is possible to decide whether the client considers certificate valid or not
Console.WriteLine($"Errors: {sslErrors}");
return sslErrors == SslPolicyErrors.None;
}
private protected virtual async Task<HttpResponseMessage> getResponseAsync(string method)
{
var handler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = ServerCertificateCustomValidation,
SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls,
};
using (var client = new HttpClient(handler) { Timeout = Timeout })
{
var requestUri = BS.Shared.Core.Utilities.WebUtils.CombineUrl(Base_Url, method);
if (Method == HttpMethod.Get && Parameters.Count > 0)
{
var query = string.Join("&", Parameters.Select(p => $"{Uri.EscapeDataString(p.Key)}={Uri.EscapeDataString(p.Value)}"));
requestUri += (Base_Url.Contains("?") ? "&" : "?") + query;
}
using (var request = new HttpRequestMessage(Method, requestUri))
{
await checkForDirect(request).ConfigureAwait(false);
// Add headers
foreach (var header in Headers)
request.Headers.TryAddWithoutValidation(header.Key, header.Value);
// Add body if POST or PUT
if (Method == HttpMethod.Post || Method == HttpMethod.Put)
{
var content = new FormUrlEncodedContent(Parameters);
var bytes = await content.ReadAsByteArrayAsync().ConfigureAwait(false);
request.Content = new ByteArrayContent(bytes);
request.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(ContentType);
}
return await client.SendAsync(request).ConfigureAwait(false);
}
}
}
private protected async Task checkForDirect(HttpRequestMessage request)
{
if (!DirectConnect || request.RequestUri is null)
return;
var host = request.RequestUri.DnsSafeHost;
var isSslSession = request.RequestUri.ToString().StartsWith("https://");
try
{
// DNS-Auflösung für den Hostnamen durchführen
var ipAddresses = await Dns.GetHostAddressesAsync(host).ConfigureAwait(false);
// Erste verfügbare IP-Adresse verwenden (IPv4 bevorzugen)
var targetIp = ipAddresses.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork)
?? ipAddresses.FirstOrDefault();
if (targetIp != null)
{
request.RequestUri = new Uri($"{(isSslSession ? "https://" : "http://")}{targetIp}{request.RequestUri.PathAndQuery}");
request.Headers.Host = host;
}
}
catch (Exception ex)
{
// Fallback: Original URI beibehalten bei DNS-Fehlern
// Optional: Logging des Fehlers
Console.WriteLine($"DNS resolution failed for {host}: {ex.Message}");
}
}
private void SetToken(string api_key)
{
var key = nameof(HttpRequestHeader.Authorization);
var token = $"Bearer {api_key}";
if (Headers.ContainsKey(key))
{
Headers[key] = token;
}
else
{
Headers.Add(key, token);
}
}
private ApiResponse<T> parse<T>(Func<T> func, string json, IApiErrorExtractor errorExtractor)
{
try
{
// Versuch, die erwartete Struktur zu deserialisieren
var data = func();
return ApiResponse<T>.SuccessResponse(data);
}
catch (JsonException)
{
// Falls normale Deserialisierung fehlschlägt, versuche Fehler zu extrahieren
return ApiResponse<T>.FailureResponse(AppError.JsonParsingError, errorExtractor.ExtractError(json).ToList());
}
}
}
}

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
namespace BS.Shared.ApiFacade
{
public class JsonHttpClientFacade : HttpClientFacade
{
public object JsonObject { get; set; }
public JsonHttpClientFacade(string base_url, string api_key, bool directConnect = true) : base(base_url, api_key, directConnect)
{
ContentType = "application/json";
Method = HttpMethod.Post;
}
private protected override async Task<HttpResponseMessage> getResponseAsync(string method)
{
using (var client = new HttpClient { Timeout = Timeout })
{
var requestUri = BS.Shared.Core.Utilities.WebUtils.CombineUrl(Base_Url, method);
using (var request = new HttpRequestMessage(Method, requestUri))
{
await checkForDirect(request).ConfigureAwait(false);
// Add headers
foreach (var header in Headers)
request.Headers.TryAddWithoutValidation(header.Key, header.Value);
// Add body if POST or PUT
if (Method == HttpMethod.Post || Method == HttpMethod.Put)
{
var json = JsonConvert.SerializeObject(JsonObject);
request.Content = new StringContent(json, Encoding, "application/json");
}
return await client.SendAsync(request).ConfigureAwait(false);
}
}
}
}
}

View File

@@ -0,0 +1,268 @@
using BS.Shared.Extensions;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
namespace BS.Shared.ApiFacade
{
public class WebClientFacade
{
//
// GET
//
protected TRes SendGet<TRes>(string sub_url, string token = null)
=> Get<TRes>(sub_url, token);
protected Task<TRes> SendGetAsync<TRes>(string sub_url, string token = null)
=> GetAsync<TRes>(sub_url, token);
//
// POST
//
protected TRes SendPostUploadString<TReq, TRes>(string sub_url, TReq req, string token = null)
=> SendUploadString<TReq, TRes>(sub_url, "POST", req, token);
protected TRes SendPostUploadValues<TReq, TRes>(string sub_url, TReq req, string token = null)
=> SendUploadValues<TReq, TRes>(sub_url, "POST", req, token);
protected byte[] SendPostUploadValuesRaw<TReq>(string sub_url, TReq req, string token = null)
=> SendUploadValuesRaw(sub_url, "POST", req, token);
protected Task<TRes> SendPostUploadStringAsync<TReq, TRes>(string sub_url, TReq req, string token = null)
=> SendUploadStringAsync<TReq, TRes>(sub_url, "POST", req, token);
protected Task<TRes> SendPostUploadValuesAsync<TReq, TRes>(string sub_url, TReq req, string token = null)
=> SendUploadValuesAsync<TReq, TRes>(sub_url, "POST", req, token);
protected Task<byte[]> SendPostUploadValuesAsyncRaw<TReq, TRes>(string sub_url, TReq req, string token = null)
=> SendUploadValuesRawAsync<TReq, TRes>(sub_url, "POST", req, token);
#region private
//
// Requests
//
private TRes Get<TRes>(string sub_url, string token = null)
{
var url = getUrl(sub_url);
string response = Get(url, token);
return deserialize<TRes>(response);
}
private TRes SendUploadString<TReq, TRes>(string sub_url, string method, TReq req, string token = null)
{
var data = serializeJson(req);
var url = getUrl(sub_url);
string response = SendUploadString<TRes>(url, method, data, token);
return deserialize<TRes>(response);
}
private TRes SendUploadValues<TReq, TRes>(string sub_url, string method, TReq req, string token = null)
{
var data = serialize(req);
var url = getUrl(sub_url);
string response = SendUploadValues(url, method, data, token);
return deserialize<TRes>(response);
}
private byte[] SendUploadValuesRaw<TReq>(string sub_url, string method, TReq req, string token = null)
{
var data = serialize(req);
var url = getUrl(sub_url);
var response = SendUploadValuesRaww(url, method, data, token);
return response;
}
private async Task<TRes> GetAsync<TRes>(string sub_url, string token = null)
{
var url = getUrl(sub_url);
string response = await GetAsync(url, token);
return deserialize<TRes>(response);
}
private async Task<TRes> SendUploadStringAsync<TReq, TRes>(string sub_url, string method, TReq req, string token = null)
{
var data = serializeJson(req);
var url = getUrl(sub_url);
string response = await SendUploadStringAsync<TRes>(url, method, data, token);
return deserialize<TRes>(response);
}
private async Task<TRes> SendUploadValuesAsync<TReq, TRes>(string sub_url, string method, TReq req, string token = null)
{
var data = serialize(req);
var url = getUrl(sub_url);
string response = await SendUploadValuesAsync(url, method, data, token);
return deserialize<TRes>(response);
}
private async Task<byte[]> SendUploadValuesRawAsync<TReq, TRes>(string sub_url, string method, TReq req, string token = null)
{
var data = serialize(req);
var url = getUrl(sub_url);
var response = await SendUploadValuesRawAsync(url, method, data, token);
return response;
}
//
// String
//
private string Get(string url, string token = null)
=> exec(true, client => client.DownloadString(url), token);
private string SendUploadString<T>(string url, string method, string request, string token = null)
=> exec(false, client => client.UploadString(url, method, request), token);
private string SendUploadValues<T>(string url, string method, T request, string token = null)
=> exec(false, client => Encoding.UTF8.GetString(client.UploadValues(url, method, request?.ToNameValueCollection())), token);
private byte[] SendUploadValuesRaww<T>(string url, string method, T request, string token = null)
=> execraw(false, client => client.UploadValues(url, method, request?.ToNameValueCollection()), token);
private Task<string> GetAsync(string url, string token = null)
=> execasync(true, client => client.DownloadStringTaskAsync(url), token);
private Task<string> SendUploadStringAsync<T>(string url, string method, string request, string token = null)
=> execasync(false, client => client.UploadStringTaskAsync(url, method, request), token);
private Task<string> SendUploadValuesAsync<T>(string url, string method, T request, string token = null)
=> execasync(false, async client => Encoding.UTF8.GetString(await client.UploadValuesTaskAsync(url, method, request?.ToNameValueCollection()).ConfigureAwait(false)), token);
private Task<byte[]> SendUploadValuesRawAsync<T>(string url, string method, T request, string token = null)
=> execasyncraw(false, async client => await client.UploadValuesTaskAsync(url, method, request?.ToNameValueCollection()).ConfigureAwait(false), token);
//
// Base
//
private string exec(bool override_header, Func<WebClient, string> action, string token = null)
{
string response;
using (WebClient client = new WebClient())
{
//client.Encoding = Encoding.Default;
client.Encoding = Encoding.UTF8;
if (override_header)
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
if (token != null)
client.Headers.Set(HttpRequestHeader.Authorization, "Bearer " + token);
response = action(client);
}
return response;
}
private byte[] execraw(bool override_header, Func<WebClient, byte[]> action, string token = null)
{
byte[] response;
using (WebClient client = new WebClient())
{
//client.Encoding = Encoding.Default;
client.Encoding = Encoding.UTF8;
if (override_header)
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
if (token != null)
client.Headers.Set(HttpRequestHeader.Authorization, "Bearer " + token);
response = action(client);
}
return response;
}
private async Task<string> execasync(bool override_header, Func<WebClient, Task<string>> action, string token = null)
{
string response;
using (WebClient client = new WebClient())
{
//client.Encoding = Encoding.Default;
client.Encoding = Encoding.UTF8;
if (override_header)
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
if (token != null)
client.Headers.Set(HttpRequestHeader.Authorization, "Bearer " + token);
response = await action(client);
}
return response;
}
private async Task<byte[]> execasyncraw(bool override_header, Func<WebClient, Task<byte[]>> action, string token = null)
{
byte[] response;
using (WebClient client = new WebClient())
{
//client.Encoding = Encoding.Default;
client.Encoding = Encoding.UTF8;
if (override_header)
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
if (token != null)
client.Headers.Set(HttpRequestHeader.Authorization, "Bearer " + token);
response = await action(client);
}
return response;
}
private T deserialize<T>(string input)
{
if (string.IsNullOrEmpty(input))
return default;
if (typeof(T) == typeof(string))
return (T)(object)input;
if (typeof(T) == typeof(byte[]))
return (T)(object)Encoding.UTF8.GetBytes(input);
var t = JsonConvert.DeserializeObject<T>(input);
return t;
}
private IDictionary<string, string> serialize<T>(T input)
{
return input?.ToKeyValue();
}
private string serializeJson<T>(T input)
{
if (typeof(T) == typeof(string))
return input as string;
var t = JsonConvert.SerializeObject(input);
return t;
}
#endregion
protected virtual string getKey()
{
return null;
}
protected virtual string getUrl()
{
return null;
}
private string getUrl(string sub_url)
{
var root = getUrl();
var baseUri = new Uri(root);
var uri = new Uri(baseUri, sub_url);
var url = uri.ToString();
return url;
}
}
}

View File

@@ -1,5 +1,4 @@
using BS.Shared.DataContracts;
using BS.Shared.Interface;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@@ -1,5 +1,4 @@
using BS.Shared.Core;
using BS.Shared.Interface;
using DevExpress.XtraRichEdit.Import.Html;
using Newtonsoft.Json;
using System;

View File

@@ -1,4 +1,6 @@
using System;
using BS.Shared.Extensions;
using BS.Shared.Interface.Abstract;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.Serialization;
@@ -8,8 +10,8 @@ namespace BS.Shared.DataContracts.Compact
[DataContract, Serializable]
[DebuggerDisplay("{LastName}, {FirstName}")]
public partial class CompactCustomerDC : IDataContract
{
public partial class CompactCustomerDC : IDataContract, IPersonNameable, IAddressable
{
private Dictionary<long, string> _CostBearerReferenceNumbers;
private Dictionary<long, string> _VarFieldValues;
private Dictionary<long, string> _VarFieldDefs;
@@ -67,7 +69,9 @@ namespace BS.Shared.DataContracts.Compact
[DataMember]
public string PostalCode { get; set; }
[DataMember]
public string Postalcode => throw new NotImplementedException();
[DataMember]
public Sex? Sex { get; set; }
[DataMember]
@@ -155,6 +159,10 @@ namespace BS.Shared.DataContracts.Compact
[DataMember]
public bool IsSubstitutionNeeded { get; set; }
//public List<VarFieldDC> VarFields { get; set; }
}
public string AddressLine1 => null;
public string AddressLine2 => null;
public string State => null;
public string Country => null;
}
}

View File

@@ -2,12 +2,13 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.Serialization;
using BS.Shared.Interface.Abstract;
namespace BS.Shared.DataContracts.Compact
{
[DataContract, Serializable]
[DebuggerDisplay("{EmployeeOid}: {LastName}, {FirstName}")]
public partial class CompactEmployeeDC : IDataContract
public partial class CompactEmployeeDC : IDataContract, IPersonNameable
{
private List<long> _RelatedCustomerOIDList;

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using BS.Shared.Interface.Abstract;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.Serialization;
@@ -7,7 +8,7 @@ namespace BS.Shared.DataContracts.Compact
[DataContract]
[DebuggerDisplay("{Name}")]
public partial class CompactOrganisationDC : IDataContract
public partial class CompactOrganisationDC : IDataContract, IAddressable
{
private List<CostRatePeriodDC> _CostRatePeriods;
@@ -105,5 +106,10 @@ namespace BS.Shared.DataContracts.Compact
[DataMember]
public string BusinessPartnerId { get; set; }
}
public string AddressLine2 => null;
public string State => null;
public string Country => null;
}
}

View File

@@ -1,12 +1,13 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using BS.Shared.Interface.Abstract;
namespace BS.Shared.DataContracts.Compact
{
[DataContract]
public partial class CompactPersonDC : IDataContract
{
public partial class CompactPersonDC : IDataContract, IPersonNameable, IAddressable
{
[DataMember]
public ActivationTypeId ActivationType { get; set; }
@@ -75,5 +76,10 @@ namespace BS.Shared.DataContracts.Compact
[DataMember]
public Sex? Geschlecht { get; set; }
}
public string AddressLine1 => null;
public string AddressLine2 => null;
public string State => null;
public string Country => null;
}
}

View File

@@ -3,11 +3,13 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using BS.Shared.Core;
using BS.Shared.Extensions;
using BS.Shared.Interface.Abstract;
namespace BS.Shared.DataContracts
{
[DataContract]
public class PersonDC : IDataContract
public class PersonDC : IDataContract, IPersonNameable, IAddressable
{
private List<ContactDC> _ContactInformations;
@@ -73,6 +75,10 @@ namespace BS.Shared.DataContracts
}
}
public string AddressLine2 => null;
public string State => null;
public string Country => null;
public bool ContainsAddressData()
{
return !Utils.AreAllNullOrEmpty(this.AddressLine1, this.Street, this.PostalCode, this.Town);
@@ -93,5 +99,9 @@ namespace BS.Shared.DataContracts
return !Utils.AreAllNullOrEmpty(this.FirstName, this.LastName, this.DateOfBirth, this.Sex, this.Profession, this.Abbreviation);
}
public string GetInvoiceAddressSingleLine()
{
return AddressExtensions.ToSingleAddressLine(InvoiceAddressLine1, InvoiceAddressLine2, InvoiceAddressStreet, InvoiceAddressPostalCode, InvoiceAddressTown);
}
}
}

View File

@@ -0,0 +1,34 @@
using BS.Shared.Interface.Abstract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BS.Shared.Extensions
{
public static class AddressExtensions
{
public static string ToSingleAddressLine(string addressline1, string addressline2, string street, string postalcode, string town, string state = null, string country = null)
{
var parts = new List<string>
{
addressline1,
addressline2,
street,
postalcode,
town,
state,
country
};
return string.Join(", ", parts.Where(p => !string.IsNullOrWhiteSpace(p)));
}
public static string GetSingleAddressLine(this IAddressable addressable)
{
return ToSingleAddressLine(addressable.AddressLine1, addressable.AddressLine2, addressable.Street, addressable.PostalCode, addressable.Town, addressable.State, addressable.Country);
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BS.Shared.Interface.Abstract;
namespace BS.Shared.Extensions
{
public static class PersonNameableExtensions
{
public static string GetFirstNameLastName(this IPersonNameable personNameable, bool withcomma = false)
{
return $"{personNameable.FirstName}{(withcomma ? "," : null)} {personNameable.LastName}";
}
public static string GetLastNameFirstName(this IPersonNameable personNameable, bool withcomma = true)
{
return $"{personNameable.LastName}{(withcomma ? "," : null)} {personNameable.FirstName}";
}
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BS.Shared.Interface.Abstract
{
public interface IAddressable
{
string AddressLine1 { get; }
string AddressLine2 { get; }
string Street { get; }
string PostalCode { get; }
string Town { get; }
string State { get; }
string Country { get; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BS.Shared.Interface.Abstract
{
public interface IPersonNameable
{
string FirstName { get; }
string LastName { get; }
}
}

View File

@@ -134,6 +134,9 @@
<Reference Include="System.Xaml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ApiFacade\HttpClientFacade.cs" />
<Compile Include="ApiFacade\JsonHttpClientFacade.cs" />
<Compile Include="ApiFacade\WebClientFacade.cs" />
<Compile Include="AppSender\GkvSender.cs" />
<Compile Include="Attributes\RequireNoTenantAttribute.cs" />
<Compile Include="Attributes\RequirePermissionAttribute.cs" />
@@ -391,14 +394,18 @@
<Compile Include="Extensions\EnumExtensions.cs" />
<Compile Include="Extensions\GkvAbrechnungExtensions.cs" />
<Compile Include="Extensions\GridExtensions.cs" />
<Compile Include="Extensions\AddressExtensions.cs" />
<Compile Include="Extensions\ICollectionExtensions.cs" />
<Compile Include="Extensions\IDictionaryTExtensions.cs" />
<Compile Include="Extensions\PersonNameableExtensions.cs" />
<Compile Include="Extensions\TimeIntervalExtensions.cs" />
<Compile Include="Interface\Abstract\IAddressable.cs" />
<Compile Include="Interface\IApiErrorExtractor.cs" />
<Compile Include="Interface\IContact.cs" />
<Compile Include="Interface\IGkvAbrechnung.cs" />
<Compile Include="Interface\IGkvTransferProtokoll.cs" />
<Compile Include="Interface\IInvoiceBase.cs" />
<Compile Include="Interface\Abstract\IPersonNameable.cs" />
<Compile Include="Interface\IOrganisation.cs" />
<Compile Include="Interface\IInvoiceItem.cs" />
<Compile Include="Interface\ISupportConcept.cs" />