CustomerView Buttons

This commit is contained in:
2025-04-15 16:28:17 +02:00
parent dc6195e74d
commit b3ee248806
9 changed files with 139 additions and 25 deletions

View File

@@ -804,6 +804,7 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="10" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Rectangle Height="6" Fill="{StaticResource CustomerContentBrush}" /> <Rectangle Height="6" Fill="{StaticResource CustomerContentBrush}" />
@@ -3786,10 +3787,10 @@
Selector.Selected="tabitem_log_Selected" /> Selector.Selected="tabitem_log_Selected" />
</TabControl> </TabControl>
<Border <Border
Grid.Row="2" Grid.Row="3"
Grid.ColumnSpan="3" Grid.ColumnSpan="3"
Height="40" Height="40"
Margin="0,10,0,0" Margin="0,0,0,0"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
Background="#FF000000"> Background="#FF000000">
<Border.OpacityMask> <Border.OpacityMask>
@@ -3798,12 +3799,40 @@
<GradientStop Offset="1" Color="#33FFFFFF" /> <GradientStop Offset="1" Color="#33FFFFFF" />
</LinearGradientBrush> </LinearGradientBrush>
</Border.OpacityMask> </Border.OpacityMask>
</Border> </Border>
<StackPanel <StackPanel
Grid.Row="2" Grid.Row="3"
Grid.ColumnSpan="3"
Margin="0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Orientation="Horizontal">
<StackPanel.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\..\Styles\ModernOrangeBlack.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</StackPanel.Resources>
<Button
x:Name="btnOpenAi2"
Margin="10,0,0,0"
Command="{Binding Path=OpenAiWindowCommand, RelativeSource={RelativeSource AncestorType={x:Type localView:BeWoView}}}"
Content="AI Chat Window"
Style="{StaticResource NavigationToolbarButtonStyle}" />
<Button
x:Name="btnOpenAi3"
Margin="10,0,0,0"
Command="{Binding Path=OpenAiPopupCommand, RelativeSource={RelativeSource AncestorType={x:Type localView:BeWoView}}}"
Content="AI Chat Popup"
Style="{StaticResource NavigationToolbarButtonStyle}" />
</StackPanel>
<StackPanel
Grid.Row="3"
Grid.ColumnSpan="3" Grid.ColumnSpan="3"
Height="Auto" Height="Auto"
Margin="5,10,0,0" Margin="5,0,0,0"
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Center" VerticalAlignment="Center"
Orientation="Horizontal"> Orientation="Horizontal">

View File

@@ -51,6 +51,9 @@ using Hyperlink = System.Windows.Documents.Hyperlink;
using MessageBox = System.Windows.MessageBox; using MessageBox = System.Windows.MessageBox;
using VerticalAlignment = System.Windows.VerticalAlignment; using VerticalAlignment = System.Windows.VerticalAlignment;
using BeWo.AI; using BeWo.AI;
using BeWo.View.Navigation;
using DevExpress.Mvvm;
using System.Collections;
namespace BeWo.View.Detail namespace BeWo.View.Detail
{ {
@@ -96,10 +99,12 @@ namespace BeWo.View.Detail
public CustomerView(CustomerVM pCustomerVM) public CustomerView(CustomerVM pCustomerVM)
{ {
InitializeComponent(); InitializeComponent();
DataContext = ViewModel;
DataContext = ViewModel; OpenAiWindowCommand = new DelegateCommand(OpenAiWindow, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView));
OpenAiPopupCommand = new DelegateCommand(OpenAiPopup, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView2));
BehinderungsartenSelection.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => this.Dispatch(() => { PopupBehinderungsarten.IsOpen = false; }))); BehinderungsartenSelection.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => this.Dispatch(() => { PopupBehinderungsarten.IsOpen = false; })));
MerkzeichenSelection.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => this.Dispatch(() => { PopupMerkzeichen.IsOpen = false; }))); MerkzeichenSelection.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => this.Dispatch(() => { PopupMerkzeichen.IsOpen = false; })));
_AlleEintragKategorien = pCustomerVM.EintragKategorien; _AlleEintragKategorien = pCustomerVM.EintragKategorien;
@@ -289,7 +294,40 @@ namespace BeWo.View.Detail
#endif #endif
} }
void Image_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e) public DelegateCommand OpenAiWindowCommand { get; }
public DelegateCommand OpenAiPopupCommand { get; }
public Dictionary<TableID, long[]> GetVisibleInformationReferences()
{
var visible = ViewModel;
return GetVisibleInformationReferences(visible);
}
private Dictionary<TableID, long[]> GetVisibleInformationReferences(CustomerVM customer)
{
var dict = new Dictionary<TableID, long[]>() {
{ TableID.Customer, new long[]{customer.DataContract.CustomerOid.Value } }
};
return dict;
}
private void OpenAiWindow()
{
var context = GetVisibleInformationReferences();
MainControl.WindowService.ShowAiConversationWindow(UIContext.CustomerSingle, context);
}
private void OpenAiPopup()
{
var context = GetVisibleInformationReferences();
MainControl.WindowService.ShowAiConversationModalViewWindow(UIContext.CustomerSingle, context);
}
void Image_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e)
{ {
_ViewModel.CustomerImage = Img.EditValue as byte[]; _ViewModel.CustomerImage = Img.EditValue as byte[];
} }
@@ -361,7 +399,7 @@ namespace BeWo.View.Detail
//get { return BeWoApp.Tenant == "demo" && BeWoApp.UserName == "demo"; } //get { return BeWoApp.Tenant == "demo" && BeWoApp.UserName == "demo"; }
} }
private void Log(string log) private void Log(string log)
{ {
if (ShouldLog) if (ShouldLog)
{ {

View File

@@ -5,12 +5,13 @@ using System.Linq;
using BeWo.Data.Entities; using BeWo.Data.Entities;
using BeWo.Service.Core; using BeWo.Service.Core;
using BeWo.Service.Interfaces;
using BS.Shared; using BS.Shared;
using BS.Shared.Extensions; using BS.Shared.Extensions;
namespace BeWo.Service.DCEntityMapper namespace BeWo.Service.DCEntityMapper
{ {
public abstract class AbstractIDCEntityMapper<TEntity, TDC> : IDCEntityMapper<TEntity, TDC> public abstract class AbstractIDCEntityMapper<TEntity, TDC> : IDCEntityMapper<TEntity, TDC>, IJsonMapper<TEntity, TDC>
where TDC : new() where TEntity : BeWoEntityBase, new() where TDC : new() where TEntity : BeWoEntityBase, new()
{ {
public bool ConcurrencyCheck(long? pDataContractVersion, BeWoEntityBase pEntity) public bool ConcurrencyCheck(long? pDataContractVersion, BeWoEntityBase pEntity)

View File

@@ -347,5 +347,10 @@ namespace BeWo.Service.DCEntityMapper
return pDC.CustomerOid == pEntity.Oid; return pDC.CustomerOid == pEntity.Oid;
} }
public override Dictionary<string, object> ToJsonDictionary(CustomerDC pDC)
{
return base.ToJsonDictionary(pDC);
}
} }
} }

View File

@@ -19,10 +19,5 @@ namespace BeWo.Service.DCEntityMapper
TDC MergeWithDC(TEntity pEntity, TDC pDataContract); TDC MergeWithDC(TEntity pEntity, TDC pDataContract);
TEntity MergeWithEntity(TDC pDataContract, TEntity pEntity); TEntity MergeWithEntity(TDC pDataContract, TEntity pEntity);
Dictionary<string, object> ToJsonDictionary(TDC pDC);
Dictionary<string, object> ToJsonDictionary(TEntity pEntity);
IList<Dictionary<string, object>> ToJsonDictionary(IList<TEntity> pEntities);
IList<Dictionary<string, object>> ToJsonDictionary(IList<TDC> pDCs);
} }
} }

View File

@@ -0,0 +1,18 @@
using BeWo.Data.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeWo.Service.Interfaces
{
public interface IJsonMapper<TEntity, TDC>
where TDC : new() where TEntity : BeWoEntityBase, new()
{
Dictionary<string, object> ToJsonDictionary(TDC pDC);
Dictionary<string, object> ToJsonDictionary(TEntity pEntity);
IList<Dictionary<string, object>> ToJsonDictionary(IList<TEntity> pEntities);
IList<Dictionary<string, object>> ToJsonDictionary(IList<TDC> pDCs);
}
}

View File

@@ -417,6 +417,7 @@
<Compile Include="Import\TextAbschnittReader.cs" /> <Compile Include="Import\TextAbschnittReader.cs" />
<Compile Include="Import\TextAbschnitt.cs" /> <Compile Include="Import\TextAbschnitt.cs" />
<Compile Include="Import\Perseh\PersehReader.cs" /> <Compile Include="Import\Perseh\PersehReader.cs" />
<Compile Include="Interfaces\IJsonMapper.cs" />
<Compile Include="Invoicing\ApprovalPeriod.cs" /> <Compile Include="Invoicing\ApprovalPeriod.cs" />
<Compile Include="Invoicing\GeneralInvoiceCreation.cs" /> <Compile Include="Invoicing\GeneralInvoiceCreation.cs" />
<Compile Include="Invoicing\SbdDefaultInvoiceCreation.cs" /> <Compile Include="Invoicing\SbdDefaultInvoiceCreation.cs" />
@@ -546,7 +547,7 @@
<Compile Include="ServiceImplementations\ValueListServiceImp.cs" /> <Compile Include="ServiceImplementations\ValueListServiceImp.cs" />
<Compile Include="Configuration\AppSettings.cs" /> <Compile Include="Configuration\AppSettings.cs" />
<Compile Include="ServiceProxy\OpenWebUIFacade.cs" /> <Compile Include="ServiceProxy\OpenWebUIFacade.cs" />
<Compile Include="ServiceUtils\AiSystemBuilder.cs" /> <Compile Include="AI\AiPromptFactory.cs" />
<Compile Include="ServiceUtils\DistanceCalculator\AddressRouteManager.cs" /> <Compile Include="ServiceUtils\DistanceCalculator\AddressRouteManager.cs" />
<Compile Include="ServiceUtils\DistanceCalculator\AddressRouteMatrix.cs" /> <Compile Include="ServiceUtils\DistanceCalculator\AddressRouteMatrix.cs" />
<Compile Include="ServiceUtils\DistanceCalculator\GoogleDistanceMatrixAPI.cs" /> <Compile Include="ServiceUtils\DistanceCalculator\GoogleDistanceMatrixAPI.cs" />

View File

@@ -2,6 +2,7 @@
using BeWo.Data.Access; using BeWo.Data.Access;
using BeWo.Data.Entities; using BeWo.Data.Entities;
using BeWo.Data.Security; using BeWo.Data.Security;
using BeWo.Service.AI;
using BeWo.Service.DCEntityMapper; using BeWo.Service.DCEntityMapper;
using BeWo.Service.ServiceContracts; using BeWo.Service.ServiceContracts;
using BeWo.Service.ServiceProxy; using BeWo.Service.ServiceProxy;
@@ -82,7 +83,7 @@ namespace BeWo.Service.ServiceImplementations
{ {
var current_user = UserRightHelper.GetLoggedInUserWithOid(); var current_user = UserRightHelper.GetLoggedInUserWithOid();
var system_prompt = AiSystemBuilder.CreateSystemInstructions(conversation.UIContext, conversation.ContextBeWoObjects); var system_prompt = AiPromptFactory.CreateSystemInstructions(conversation.UIContext, conversation.ContextBeWoObjects);
var conv = new AiConversation(); var conv = new AiConversation();
conv.Created = DateTime.Now; conv.Created = DateTime.Now;

View File

@@ -16,9 +16,9 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
namespace BeWo.Service.ServiceUtils namespace BeWo.Service.AI
{ {
public static class AiSystemBuilder public static class AiPromptFactory
{ {
public static string CreateSystemInstructions(int uicontext, Dictionary<TableID, long[]> bewoobjects) public static string CreateSystemInstructions(int uicontext, Dictionary<TableID, long[]> bewoobjects)
{ {
@@ -87,11 +87,15 @@ namespace BeWo.Service.ServiceUtils
case 17: break; case 17: break;
case 18: break; case 18: break;
case 19: return createServiceRecordContext(bewoobjects); case 19: return createServiceRecordContext(bewoobjects);
case 20: break;
case 21: break;
case 22: break;
} }
throw new NotImplementedException("UI Context unknown"); throw new NotImplementedException("UI Context unknown");
} }
#region Navigation
private static Dictionary<string, object> createSupportConceptNavigationContext(Dictionary<TableID, long[]> bewoobjects) private static Dictionary<string, object> createSupportConceptNavigationContext(Dictionary<TableID, long[]> bewoobjects)
{ {
var supports = LoadEntities(bewoobjects, TableID.SupportConcept, MapperFactory.CompactSupportConceptDC_SupportConcept); var supports = LoadEntities(bewoobjects, TableID.SupportConcept, MapperFactory.CompactSupportConceptDC_SupportConcept);
@@ -177,9 +181,9 @@ namespace BeWo.Service.ServiceUtils
var sub_dict = new Dictionary<string, object>() var sub_dict = new Dictionary<string, object>()
{ {
{ "CustomerName Ansicht", customer }, { "Klient", customer },
{ "CostBearerName", costbearer }, { "Kostenträger", costbearer },
{ "SupportConceptDuration", supportconcept } { "Hilfeplan", supportconcept }
}; };
var dict = new Dictionary<string, object> var dict = new Dictionary<string, object>
@@ -192,9 +196,29 @@ namespace BeWo.Service.ServiceUtils
return dict; return dict;
} }
#endregion
#region SinglePage
private static Dictionary<string, object> createCustomerContext(Dictionary<TableID, long[]> bewoobjects)
{
var supports = LoadEntity(bewoobjects, TableID.Customer, MapperFactory.CustomerDC_Customer);
var dict = new Dictionary<string, object>
{
{ "Aktuelle Ansicht", "Hilfeplan Navigation" },
{ "Aktueller Ansichtsfilter", "Funktion noch nicht verfügbar" },
{ "Hilfeplanliste", (object)supports ?? "keine Hilfepläne sichtbar" }
};
return dict;
}
#endregion
#region LOAD Methods
private static object LoadProperty<TEntity, TDC> private static object LoadProperty<TEntity, TDC>
(Dictionary<TableID, long[]> bewoobjects, TableID tid, IDCEntityMapper<TEntity, TDC> mapper, Func<TDC, object> getPropertyFunc) (Dictionary<TableID, long[]> bewoobjects, TableID tid, AbstractIDCEntityMapper<TEntity, TDC> mapper, Func<TDC, object> getPropertyFunc)
where TDC : new() where TEntity : BeWoEntityBase, new() where TDC : new() where TEntity : BeWoEntityBase, new()
{ {
if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0)
@@ -208,7 +232,7 @@ namespace BeWo.Service.ServiceUtils
} }
private static Dictionary<string, object> LoadEntity<TEntity, TDC> private static Dictionary<string, object> LoadEntity<TEntity, TDC>
(Dictionary<TableID, long[]> bewoobjects, TableID tid, IDCEntityMapper<TEntity, TDC> mapper) (Dictionary<TableID, long[]> bewoobjects, TableID tid, AbstractIDCEntityMapper<TEntity, TDC> mapper)
where TDC : new() where TEntity : BeWoEntityBase, new() where TDC : new() where TEntity : BeWoEntityBase, new()
{ {
if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0)
@@ -221,7 +245,7 @@ namespace BeWo.Service.ServiceUtils
} }
private static IList<Dictionary<string, object>> LoadEntities<TEntity, TDC> private static IList<Dictionary<string, object>> LoadEntities<TEntity, TDC>
(Dictionary<TableID, long[]> bewoobjects, TableID tid, IDCEntityMapper<TEntity, TDC> mapper) (Dictionary<TableID, long[]> bewoobjects, TableID tid, AbstractIDCEntityMapper<TEntity, TDC> mapper)
where TDC : new() where TEntity : BeWoEntityBase, new() where TDC : new() where TEntity : BeWoEntityBase, new()
{ {
if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0)
@@ -235,7 +259,7 @@ namespace BeWo.Service.ServiceUtils
} }
private static IList<Dictionary<string, object>> LoadEntities<TEntity, TDC> private static IList<Dictionary<string, object>> LoadEntities<TEntity, TDC>
(Dictionary<TableID, long[]> bewoobjects, TableID tid, IDCEntityMapper<TEntity, TDC> mapper, Action<TEntity, TDC> afterDC) (Dictionary<TableID, long[]> bewoobjects, TableID tid, AbstractIDCEntityMapper<TEntity, TDC> mapper, Action<TEntity, TDC> afterDC)
where TDC : new() where TEntity : BeWoEntityBase, new() where TDC : new() where TEntity : BeWoEntityBase, new()
{ {
if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0) if (!bewoobjects.TryGetValue(tid, out long[] oids) || (oids?.Length ?? 0) == 0)
@@ -256,6 +280,8 @@ namespace BeWo.Service.ServiceUtils
return dict; return dict;
} }
#endregion
private static string getSystemPrompt(int i) private static string getSystemPrompt(int i)
{ {