diff --git a/BeWo/AI/AiChatController.cs b/BeWo/AI/AiChatController.cs
index 616133547..437ac29a5 100644
--- a/BeWo/AI/AiChatController.cs
+++ b/BeWo/AI/AiChatController.cs
@@ -1,5 +1,6 @@
using BeWo.AI.View;
using BeWo.View;
+using BeWo.View.Windows;
using BS.Shared;
using BS.Shared.Translation;
using System;
diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj
index b01b12908..07e99f71a 100644
--- a/BeWo/BeWo.csproj
+++ b/BeWo/BeWo.csproj
@@ -103,6 +103,7 @@
AiConversationChatModalPopup.xaml
+
AnimatedBeWoWindow.xaml
@@ -1427,7 +1428,7 @@
HilfeplanImportView.xaml
-
+
DPCtrlEmployeeContractTooltip.xaml
diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs
index 1528be858..d8aebf4f4 100644
--- a/BeWo/BeWoApp.xaml.cs
+++ b/BeWo/BeWoApp.xaml.cs
@@ -544,6 +544,8 @@ namespace BeWo
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, SettingsKeys.DontUpdateApprovalPeriodDates);
AppSettings.DontUpdateApprovalPeriodDates = val != null && val.Equals("1");
+ // REFACTOR: getUserSetting verwenden?
+ AppSettings.ModuleAiEnabled = getUserSetting(SettingsKeys.ModuleAiEnabled);
switch (_Mandator.BeWoClientType)
{
@@ -661,6 +663,13 @@ namespace BeWo
}
}
+ private static bool getUserSetting(string key)
+ {
+ var val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, key);
+ var allowed = val != null && val.Equals("1");
+ return allowed;
+ }
+
internal static Uri SiteOfOrigin
{
get
diff --git a/BeWo/MainControl.xaml.cs b/BeWo/MainControl.xaml.cs
index 27cd6d357..761f15d7a 100644
--- a/BeWo/MainControl.xaml.cs
+++ b/BeWo/MainControl.xaml.cs
@@ -58,7 +58,11 @@ namespace BeWo
Administration = 16,
AiConversation = 17,
AiConversationPopup = 18,
- ServiceRecord = 19
+ // Nur für AI Conversation Zuweisung
+ ServiceRecord = 19,
+ CustomerSingle = 20,
+ PersonSingle = 21,
+ EmployeeSingle = 22,
}
public partial class MainControl
diff --git a/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs b/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs
index dd57c326e..4967b28de 100644
--- a/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs
+++ b/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs
@@ -33,7 +33,7 @@ namespace BeWo.ServiceProxy
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/CreateAiConversation", ReplyAction="http://tempuri.org/IOperationsEnhancedService/CreateAiConversationResponse")]
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/CreateAiConversationBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
- BS.Shared.DataContracts.Feature.AI.AiConversationDC CreateAiConversation(int uicontext, long model, System.Collections.Generic.List> bewoobjects);
+ BS.Shared.DataContracts.Feature.AI.AiConversationDC CreateAiConversation(BS.Shared.DataContracts.Feature.AI.AiConversationDC conversation, long modell_oid);
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/SendNewMessage", ReplyAction="http://tempuri.org/IOperationsEnhancedService/SendNewMessageResponse")]
[System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/SendNewMessageBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")]
@@ -94,9 +94,9 @@ namespace BeWo.ServiceProxy
return base.Channel.GetAiConversations(uicontext);
}
- public BS.Shared.DataContracts.Feature.AI.AiConversationDC CreateAiConversation(int uicontext, long model, System.Collections.Generic.List> bewoobjects)
+ public BS.Shared.DataContracts.Feature.AI.AiConversationDC CreateAiConversation(BS.Shared.DataContracts.Feature.AI.AiConversationDC conversation, long modell_oid)
{
- return base.Channel.CreateAiConversation(uicontext, model, bewoobjects);
+ return base.Channel.CreateAiConversation(conversation, modell_oid);
}
public System.Collections.Generic.List SendNewMessage(long conversation, string message)
diff --git a/BeWo/Styles/ControlStyles/ButtonStyles.xaml b/BeWo/Styles/ControlStyles/ButtonStyles.xaml
index 57075f413..d6641b5b1 100644
--- a/BeWo/Styles/ControlStyles/ButtonStyles.xaml
+++ b/BeWo/Styles/ControlStyles/ButtonStyles.xaml
@@ -231,4 +231,87 @@
+
+
+
+
\ No newline at end of file
diff --git a/BeWo/View/Controls/GkvAbrechnungDetailControl.xaml.cs b/BeWo/View/Controls/GkvAbrechnungDetailControl.xaml.cs
index d32f09161..8ed29012a 100644
--- a/BeWo/View/Controls/GkvAbrechnungDetailControl.xaml.cs
+++ b/BeWo/View/Controls/GkvAbrechnungDetailControl.xaml.cs
@@ -1,5 +1,6 @@
using BeWo.Core;
using BeWo.ServiceProxy;
+using BeWo.View.Windows;
using BeWo.ViewModel;
using BeWo.ViewModel.ListViewModel;
using BS.Shared.DataContracts.GkvAbrechnung;
diff --git a/BeWo/View/Controls/TextViewer.xaml b/BeWo/View/Controls/TextViewer.xaml
index ec0ccf3b5..68f08ec7c 100644
--- a/BeWo/View/Controls/TextViewer.xaml
+++ b/BeWo/View/Controls/TextViewer.xaml
@@ -1,26 +1,39 @@
-
+
-
+
-
-
+
+
-
-
-
-
+
+
-
+
diff --git a/BeWo/View/Detail/Accounting/GkvAbrechnungOverview.xaml.cs b/BeWo/View/Detail/Accounting/GkvAbrechnungOverview.xaml.cs
index 7b4bb6f0b..4bcd7fd61 100644
--- a/BeWo/View/Detail/Accounting/GkvAbrechnungOverview.xaml.cs
+++ b/BeWo/View/Detail/Accounting/GkvAbrechnungOverview.xaml.cs
@@ -13,6 +13,7 @@ using System.Windows.Threading;
using BeWo.Core;
using BeWo.ServiceProxy;
using BeWo.View.Controls;
+using BeWo.View.Windows;
using BeWo.ViewModel;
using BeWo.ViewModel.ListViewModel;
diff --git a/BeWo/View/Detail/CustomerView.xaml b/BeWo/View/Detail/CustomerView.xaml
index b3b93a54e..6c398385c 100644
--- a/BeWo/View/Detail/CustomerView.xaml
+++ b/BeWo/View/Detail/CustomerView.xaml
@@ -783,7 +783,7 @@
FontSize="22"
Foreground="#FFFFFFFF"
Text="{Binding CustomerAlias}"
- TextDecorations="" />
+ TextDecorations="None" />
+ Click="Ai_Button_Click"
+ Visibility="{Binding Converter={StaticResource UserPermission2VisibleConverter}, ConverterParameter={x:Static shared:UserRightType.AiModuleView}}">
AI Chat Window
diff --git a/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml.cs b/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml.cs
index 539a6bbb0..d5e564ee9 100644
--- a/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml.cs
+++ b/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml.cs
@@ -53,6 +53,7 @@ using DependencyObject = System.Windows.DependencyObject;
using BeWo.AI.View;
using BeWo.AI;
using BeWo.View.Detail.AI;
+using BeWo.View.Windows;
namespace BeWo.View.Detail.Zeiterfassung
{
@@ -5077,12 +5078,7 @@ namespace BeWo.View.Detail.Zeiterfassung
var context = ViewModel.GetVisibleInformationReferences(records);
- var control = new AiConversationChatView();
-
- control.ViewModel.UIContext = (int)(UIContext.ServiceRecord);
- control.ViewModel.ContextBeWoObjects = context;
-
- var window = BeWoWindowBuilder.GetAiConversationZeiterfassungWindow(context);
+ var window = BeWoWindowBuilder.AiWindowBuilder.GetAiConversationWindow(UIContext.ServiceRecord, context);
window.Show();
}
@@ -5092,10 +5088,7 @@ namespace BeWo.View.Detail.Zeiterfassung
var context = ViewModel.GetVisibleInformationReferences(records);
- var control = new AiConversationChatModalPopup();
-
- control.ViewModel.UIContext = (int)(UIContext.ServiceRecord);
- control.ViewModel.ContextBeWoObjects = context;
+ var control = BeWoWindowBuilder.AiWindowBuilder.GetAiConversationControl(UIContext.ServiceRecord, context);
MainControl.ShowControlAsModalPopup(control);
}
diff --git a/BeWo/View/Document/DokumentViewHelper.cs b/BeWo/View/Document/DokumentViewHelper.cs
index 0cfe3ab83..2536c8a9a 100644
--- a/BeWo/View/Document/DokumentViewHelper.cs
+++ b/BeWo/View/Document/DokumentViewHelper.cs
@@ -1,4 +1,5 @@
using BeWo.ServiceProxy;
+using BeWo.View.Windows;
using BeWo.ViewModel;
using BS.Shared;
using BS.Shared.DataContracts;
diff --git a/BeWo/View/Navigation/CustomerNavigationView.xaml b/BeWo/View/Navigation/CustomerNavigationView.xaml
index c7bd932f9..c57cf6fc9 100644
--- a/BeWo/View/Navigation/CustomerNavigationView.xaml
+++ b/BeWo/View/Navigation/CustomerNavigationView.xaml
@@ -5,6 +5,7 @@
xmlns:localNavView="clr-namespace:BeWo.View.Navigation"
xmlns:localView="clr-namespace:BeWo.View"
xmlns:markup="clr-namespace:BeWo.MultiLanguage.Markup"
+ x:Name="root_view"
Loaded="OnLoaded">
diff --git a/BeWo/View/Navigation/CustomerNavigationView.xaml.cs b/BeWo/View/Navigation/CustomerNavigationView.xaml.cs
index 41460ddb0..14b452fe7 100644
--- a/BeWo/View/Navigation/CustomerNavigationView.xaml.cs
+++ b/BeWo/View/Navigation/CustomerNavigationView.xaml.cs
@@ -25,6 +25,11 @@ using BS.Shared.Translation;
using Microsoft.Win32;
using BeWo.AI;
using BeWo.View.Document;
+using DevExpress.Mvvm;
+using BeWo.View.Detail.AI;
+using System;
+using BeWo.View.Windows;
+using System.Collections;
namespace BeWo.View.Navigation
{
@@ -44,7 +49,10 @@ namespace BeWo.View.Navigation
{
InitializeComponent();
- mainNavigationView.Sorter = new CustomerSorter();
+ mainNavigationView.OpenAiWindowCommand = new DelegateCommand(OpenAiWindow, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView), false);
+ mainNavigationView.OpenAiPopupCommand = new DelegateCommand(OpenAiPopup, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView2), false);
+
+ mainNavigationView.Sorter = new CustomerSorter();
mainNavigationView.ArchiveButtonVisible = BeWoApp.LoggedOnUser.HasRight(UserRightType.Customer_AllowArchiving);
mainNavigationView.ShowArchivedObjectsVisible = true;
@@ -169,7 +177,48 @@ namespace BeWo.View.Navigation
UpdateCustomFilter();
}
- private void SupportConceptFilterComboBoxOnSelectionChanged(object o, SelectionChangedEventArgs selectionChangedEventArgs)
+ public Dictionary GetVisibleInformationReferences()
+ {
+ var visible = mainNavigationView.objectListBox.ItemsSource;
+
+ return GetVisibleInformationReferences(visible);
+ }
+
+ private Dictionary GetVisibleInformationReferences(IEnumerable selected_records)
+ {
+ foreach (var record in selected_records)
+ {
+ var t = record is CompactCustomerDC;
+
+
+ if (record is CompactCustomerDC)
+ {
+
+ }
+ }
+
+ return null;
+ }
+
+ private void OpenAiWindow()
+ {
+ var context = GetVisibleInformationReferences();
+
+ var window = BeWoWindowBuilder.AiWindowBuilder.GetAiConversationWindow(UIContext.Customer, context);
+
+ window.Show();
+ }
+
+ private void OpenAiPopup()
+ {
+ var context = GetVisibleInformationReferences();
+
+ var control = BeWoWindowBuilder.AiWindowBuilder.GetAiConversationControl(UIContext.Customer, context);
+
+ MainControl.ShowControlAsModalPopup(control);
+ }
+
+ private void SupportConceptFilterComboBoxOnSelectionChanged(object o, SelectionChangedEventArgs selectionChangedEventArgs)
{
BeWoApp.AppSettings.CustomerFilterSupportConcepts = ((CustomerFilterItem) supportConceptFilterComboBox.SelectedItem)?.CustomerFilter ?? CustomerFilterEnum.MyCustomer;
diff --git a/BeWo/View/Navigation/CustomerTeamNavigationView.xaml b/BeWo/View/Navigation/CustomerTeamNavigationView.xaml
index 5eb5d1727..9946b2dd4 100644
--- a/BeWo/View/Navigation/CustomerTeamNavigationView.xaml
+++ b/BeWo/View/Navigation/CustomerTeamNavigationView.xaml
@@ -1,24 +1,25 @@
-
+
-
+
diff --git a/BeWo/View/Navigation/EmployeeNavigationView.xaml b/BeWo/View/Navigation/EmployeeNavigationView.xaml
index ea7a7a6c6..e40c17d54 100644
--- a/BeWo/View/Navigation/EmployeeNavigationView.xaml
+++ b/BeWo/View/Navigation/EmployeeNavigationView.xaml
@@ -1,33 +1,45 @@
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/BeWo/View/Navigation/MainNavigationView.xaml b/BeWo/View/Navigation/MainNavigationView.xaml
index 2838e41ac..d9dfd20d4 100644
--- a/BeWo/View/Navigation/MainNavigationView.xaml
+++ b/BeWo/View/Navigation/MainNavigationView.xaml
@@ -274,6 +274,27 @@
Content="KI"
Style="{StaticResource NavigationToolbarButtonStyle}"
Visibility="Collapsed" />
+
+
+
+
+
+
+
+
+
+
+
UIContext2Header { get; set; } = new Dictionary()
+ {
+ {UIContext.ServiceRecord, "Zeiterfassung KI Chat" },
+ {UIContext.Customer, "Klienten Übersicht KI Chat" },
+ };
+
+ public Window GetAiConversationWindow(UIContext uIContext, Dictionary context, double height = 600, double width = 1200)
+ {
+ string title = null;
+
+ UIContext2Header.TryGetValue(uIContext, out title);
+
+ if (string.IsNullOrEmpty(title))
+ title = "default";
+
+ var control = GetAiConversationControl(uIContext, context, height, width);
+
+ var window = GetAnimatedBeWoWindow(title, control, 400, height, 1000, 500, width, 1600);
+
+ return window;
+ }
+
+ public UserControl GetAiConversationControl(UIContext uIContext, Dictionary context, double height = 600, double width = 1200)
+ {
+ var control = new AiConversationChatView();
+
+ control.ViewModel.UIContext = (int)(UIContext.ServiceRecord);
+ control.ViewModel.ContextBeWoObjects = context;
+
+ return control;
+ }
+ }
+}
diff --git a/BeWo/View/BeWoWindowBuilder.cs b/BeWo/View/Windows/BeWoWindowBuilder.cs
similarity index 86%
rename from BeWo/View/BeWoWindowBuilder.cs
rename to BeWo/View/Windows/BeWoWindowBuilder.cs
index aa9288631..dc32995f9 100644
--- a/BeWo/View/BeWoWindowBuilder.cs
+++ b/BeWo/View/Windows/BeWoWindowBuilder.cs
@@ -1,7 +1,6 @@
using BeWo.View.Controls;
using BeWo.View.Detail;
using BeWo.View.Detail.AI;
-using BeWo.View.Windows;
using BeWo.ViewModel;
using BS.Shared.Extensions;
using System;
@@ -12,22 +11,11 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
-namespace BeWo.View
+namespace BeWo.View.Windows
{
public static class BeWoWindowBuilder
{
- public static Window GetAiConversationZeiterfassungWindow(List> context, double height = 600, double width = 1200)
- {
- var title = "Zeiterfassung KI Chat";
- var control = new AiConversationChatView();
-
- control.ViewModel.UIContext = (int)(UIContext.ServiceRecord);
- control.ViewModel.ContextBeWoObjects = context;
-
- var window = GetAnimatedBeWoWindow(title, control, 400, height, 1000, 500, width, 1600);
-
- return window;
- }
+ public static AiWindowBuilder AiWindowBuilder { get; } = new AiWindowBuilder();
public static BeWoWindow GetTextViewer(string title, string text, bool fixed_size = false, double height = 600, double width = 600)
{
@@ -98,7 +86,7 @@ namespace BeWo.View
return beWoWindow;
}
- private static AnimatedBeWoWindow GetAnimatedBeWoWindow(string title, Control control, double min_height, double height, double max_height, double min_width, double width, double max_width)
+ public static AnimatedBeWoWindow GetAnimatedBeWoWindow(string title, Control control, double min_height, double height, double max_height, double min_width, double width, double max_width)
{
var beWoWindow = new AnimatedBeWoWindow();
diff --git a/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs b/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs
index ceee3ac80..e878fd42e 100644
--- a/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs
+++ b/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs
@@ -1,4 +1,5 @@
using BeWo.ServiceProxy;
+using BS.Shared;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Feature.AI;
using BS.Shared.Extensions;
@@ -107,11 +108,16 @@ namespace BeWo.ViewModel.ListViewModel
}
public int UIContext{ get; set; }
- public List> ContextBeWoObjects { get; set; }
+ public Dictionary ContextBeWoObjects { get; set; }
public void RequestNewConversation()
{
- ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.CreateAiConversation(UIContext, Config.SelectedModel.Oid.Value, ContextBeWoObjects), dc => {
+ var conv = new AiConversationDC();
+
+ conv.UIContext = UIContext;
+ conv.ContextBeWoObjects = ContextBeWoObjects;
+
+ ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.CreateAiConversation(conv, Config.SelectedModel.Oid.Value), dc => {
var vm = new AiConversationVM(dc);
VMList.Insert(0, vm);
SelectedVM = vm;
diff --git a/BeWo/ViewModel/ListViewModel/ServiceRecordListVM.cs b/BeWo/ViewModel/ListViewModel/ServiceRecordListVM.cs
index b76b931a5..26f154b0a 100644
--- a/BeWo/ViewModel/ListViewModel/ServiceRecordListVM.cs
+++ b/BeWo/ViewModel/ListViewModel/ServiceRecordListVM.cs
@@ -1918,7 +1918,7 @@ namespace BeWo.ViewModel.ListViewModel
return json;
}
- public List> GetVisibleInformationReferences(IEnumerable selected_records)
+ public Dictionary GetVisibleInformationReferences(IEnumerable selected_records)
{
var current = SelectedCustomerNode;
var hello = current?.SupportConceptTreeNodeDC;
@@ -1927,17 +1927,20 @@ namespace BeWo.ViewModel.ListViewModel
if (current is null)
return null;
- var rtn = new List>();
-
- rtn.Add(new Tuple(hello.Customer.CustomerOid, (long)TableID.Customer));
- rtn.Add(new Tuple(hello.SupportConcept.SupportConceptOid, (long)TableID.SupportConcept));
- rtn.Add(new Tuple(hello.CostBearer.CostBearerOid ?? -1, (long)TableID.CostBearer));
-
+ var oids = new List();
foreach (var record in selected_records)
{
- rtn.Add(new Tuple(record.DataContract.ServiceRecordOid ?? -1, (long)TableID.ServiceRecord));
+ oids.Add(record.DataContract.ServiceRecordOid ?? -1);
}
+ var rtn = new Dictionary()
+ {
+ {TableID.Customer, new long[]{ hello.Customer.CustomerOid } },
+ {TableID.SupportConcept, new long[]{ hello.SupportConcept.SupportConceptOid } },
+ {TableID.CostBearer, new long[]{ hello.CostBearer.CostBearerOid ?? -1 } },
+ {TableID.ServiceRecord, oids.ToArray() }
+ };
+
return rtn;
}
}
diff --git a/Data/Entities/BeWoEntityReference.cs b/Data/Entities/BeWoEntityReference.cs
index 67de37e16..1eea9c074 100644
--- a/Data/Entities/BeWoEntityReference.cs
+++ b/Data/Entities/BeWoEntityReference.cs
@@ -1,4 +1,5 @@
-using System;
+using BS.Shared;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -9,6 +10,6 @@ namespace BeWo.Data.Entities
public class BeWoEntityReference
{
public virtual long Oid { get; set; }
- public virtual long Tid { get; set; }
+ public virtual TableID Tid { get; set; }
}
}
diff --git a/Data/Mappings/AiConversation.hbm.xml b/Data/Mappings/AiConversation.hbm.xml
index 8cb81d761..e541b4f98 100644
--- a/Data/Mappings/AiConversation.hbm.xml
+++ b/Data/Mappings/AiConversation.hbm.xml
@@ -30,7 +30,7 @@
-
+
diff --git a/Model/Changes_2025_04_01 AI Feature.txt b/Model/Changes_2025_04_01 AI Feature.txt
index c2870311c..ed54ee3be 100644
--- a/Model/Changes_2025_04_01 AI Feature.txt
+++ b/Model/Changes_2025_04_01 AI Feature.txt
@@ -58,9 +58,9 @@ CONSTRAINT `FK_AICONVERSATION_OID` FOREIGN KEY (`AiConversationOid`) REFERENCES
CREATE Table `AiConversation2BeWoObject` (
`AiConversationOid` bigint,
+`BeWoObjectTid` int,
`BeWoObjectOid` bigint,
-`BeWoObjectTid` bigint,
-PRIMARY KEY (`AiConversationOid`, `BeWoObjectOid`, `BeWoObjectTid`),
+PRIMARY KEY (`AiConversationOid`, `BeWoObjectTid`, `BeWoObjectOid`),
CONSTRAINT `FK_AICONVERSATION2_OID` FOREIGN KEY (`AiConversationOid`) REFERENCES `aiconversation` (`Oid`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
diff --git a/Service/DCEntityMapper/AiConversationDC_AiConversation.cs b/Service/DCEntityMapper/AiConversationDC_AiConversation.cs
index 2a8363846..306002822 100644
--- a/Service/DCEntityMapper/AiConversationDC_AiConversation.cs
+++ b/Service/DCEntityMapper/AiConversationDC_AiConversation.cs
@@ -9,6 +9,7 @@ using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Feature.AI;
+using BS.Shared.Extensions;
namespace BeWo.Service.DCEntityMapper
{
@@ -23,7 +24,7 @@ namespace BeWo.Service.DCEntityMapper
pDataContract.Created = pEntity.Created;
pDataContract.Updated = pEntity.Updated;
pDataContract.Context = pEntity.Context;
- pDataContract.ContextBeWoObjects = pEntity.ContextBeWoObjects?.Select(x => new Tuple(x.Oid, x.Tid)).ToList();
+ pDataContract.ContextBeWoObjects = Parse(pEntity.ContextBeWoObjects);
pDataContract.UIContext = pEntity.UIContext;
if (pEntity.Messages is IList list && list.Any())
@@ -37,6 +38,8 @@ namespace BeWo.Service.DCEntityMapper
public override AiConversation MergeWithEntity(AiConversationDC pDataContract, AiConversation pEntity)
{
+ throw new NotImplementedException();
+
ConcurrencyCheck(pDataContract.Version, pEntity);
//pEntity.Oid = pDataContract.Oid;
@@ -46,8 +49,8 @@ namespace BeWo.Service.DCEntityMapper
pEntity.Created = pDataContract.Created;
pEntity.Updated = pDataContract.Updated;
pEntity.Context = pDataContract.Context;
- pEntity.ContextBeWoObjects = pDataContract.ContextBeWoObjects?.Select(x => new BeWoEntityReference() { Oid = x.Item1, Tid = x.Item2}).ToList();
pEntity.UIContext = pDataContract.UIContext;
+ pEntity.ContextBeWoObjects = Parse(pDataContract.ContextBeWoObjects);
MapperFactory.AiConversationMessage.MergeWithEntitys(pDataContract.Messages, pEntity.Messages);
@@ -61,5 +64,43 @@ namespace BeWo.Service.DCEntityMapper
{
throw new System.NotImplementedException();
}
+
+ public Dictionary Parse(IEnumerable beWoEntities)
+ {
+ if (beWoEntities is null)
+ return null;
+
+ var tables = beWoEntities.Select(x => x.Tid).Distinct();
+
+ var rtn = new Dictionary>();
+ foreach (var table in tables)
+ {
+ rtn.Add(table, new List());
+ }
+
+ beWoEntities.DoForEach(x => rtn[x.Tid].Add(x.Oid));
+
+ return rtn.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToArray());
+ }
+
+ public IList Parse(Dictionary input)
+ {
+ if (input is null)
+ return null;
+
+ var rtn = new List();
+
+ foreach (var kvp in input)
+ {
+ var table = kvp.Key;
+ for (var i = 0; i < kvp.Value.Length; i++)
+ {
+ var oid = kvp.Value[i];
+ rtn.Add(new BeWoEntityReference() { Tid = table, Oid = oid });
+ }
+ }
+
+ return rtn;
+ }
}
}
diff --git a/Service/ServiceContracts/IOperationsEnhancedService.cs b/Service/ServiceContracts/IOperationsEnhancedService.cs
index daffb12be..abfb5c438 100644
--- a/Service/ServiceContracts/IOperationsEnhancedService.cs
+++ b/Service/ServiceContracts/IOperationsEnhancedService.cs
@@ -1,4 +1,5 @@
using BeWo.Data.Entities;
+using BS.Shared;
using BS.Shared.Attributes;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Feature.AI;
@@ -37,7 +38,7 @@ namespace BeWo.Service.ServiceContracts
[FaultContract(typeof(BeWoFault))]
[OperationContract]
[RequirePermission(BS.Shared.UserRightType.AiModuleView)]
- AiConversationDC CreateAiConversation(int uicontext, long model, List> bewoobjects);
+ AiConversationDC CreateAiConversation(AiConversationDC conversation, long modell_oid);
[FaultContract(typeof(BeWoFault))]
[OperationContract]
diff --git a/Service/ServiceImplementations/OperationsEnhancedServiceImp.cs b/Service/ServiceImplementations/OperationsEnhancedServiceImp.cs
index c48a6ace6..ddaa46d1b 100644
--- a/Service/ServiceImplementations/OperationsEnhancedServiceImp.cs
+++ b/Service/ServiceImplementations/OperationsEnhancedServiceImp.cs
@@ -6,6 +6,7 @@ using BeWo.Service.DCEntityMapper;
using BeWo.Service.ServiceContracts;
using BeWo.Service.ServiceProxy;
using BeWo.Service.ServiceUtils;
+using BS.Shared;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Feature.AI;
using BS.Shared.DataContracts.MikePHPContracts;
@@ -14,6 +15,7 @@ using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Security.Cryptography;
using System.ServiceModel;
using System.Text;
using System.Threading;
@@ -77,19 +79,19 @@ namespace BeWo.Service.ServiceImplementations
return dcs;
}
- public AiConversationDC CreateAiConversation(int uicontext, long model, List> bewoobjects)
+ public AiConversationDC CreateAiConversation(AiConversationDC conversation, long modell_oid)
{
var current_user = UserRightHelper.GetLoggedInUserWithOid();
- var system = AiSystemBuilder.CreateSystemInstructions(uicontext, bewoobjects);
+ var system = AiSystemBuilder.CreateSystemInstructions(conversation.UIContext, conversation.ContextBeWoObjects);
var conv = new AiConversation();
conv.Created = DateTime.Now;
- conv.ContextBeWoObjects = bewoobjects?.Select(x => new BeWoEntityReference() { Oid = x.Item1, Tid = x.Item2}).ToList();
+ conv.ContextBeWoObjects = MapperFactory.AiConversation.Parse(conversation.ContextBeWoObjects);
conv.Displayname = "Displayname";
conv.Messages = new List();
- conv.Modell = DAOFactory.GenericDAO.LoadByID(model);
- conv.UIContext = uicontext;
+ conv.Modell = DAOFactory.GenericDAO.LoadByID(modell_oid);
+ conv.UIContext = conversation.UIContext;
conv.Updated = DateTime.Now;
conv.ApplicationUserOid = current_user.Oid;
diff --git a/Service/ServiceUtils/AiSystemBuilder.cs b/Service/ServiceUtils/AiSystemBuilder.cs
index 9a3fee120..374e5bf01 100644
--- a/Service/ServiceUtils/AiSystemBuilder.cs
+++ b/Service/ServiceUtils/AiSystemBuilder.cs
@@ -18,7 +18,7 @@ namespace BeWo.Service.ServiceUtils
{
public static class AiSystemBuilder
{
- public static string CreateSystemInstructions(int uicontext, List> bewoobjects)
+ public static string CreateSystemInstructions(int uicontext, Dictionary bewoobjects)
{
var system_prompt = getSystemPrompt(2);
@@ -78,40 +78,38 @@ namespace BeWo.Service.ServiceUtils
return escape;
}
- private static string createServiceRecordContext(List> bewoobjects)
+ private static string createServiceRecordContext(Dictionary bewoobjects)
{
if (bewoobjects is null || !bewoobjects.Any())
return null;
- // Sortiere Liste
- var sorted = getDictionary(bewoobjects);
var selected = new Dictionary();
- if (tryGetSingleValue(sorted, TableID.Customer, out long coid))
+ if (bewoobjects.TryGetValue(TableID.Customer, out long[] cvalues) && (cvalues?.Length ?? 0) > 0)
{
- var customer = DAOFactory.GenericDAO.GetByID(coid);
+ var customer = DAOFactory.GenericDAO.GetByID(cvalues[0]);
var customer_dc = MapperFactory.CompactCustomerDC_Customer.MapToNewDC(customer);
selected.Add("CustomerName", customer_dc.LastNameFirstName);
}
- if (tryGetSingleValue(sorted, TableID.CostBearer, out long cboid))
+ if (bewoobjects.TryGetValue(TableID.CostBearer, out long[] cbvalues) && (cbvalues?.Length ?? 0) > 0)
{
- var costbearer = DAOFactory.GenericDAO.GetByID(cboid);
+ var costbearer = DAOFactory.GenericDAO.GetByID(cbvalues[0]);
var costbearer_dc = MapperFactory.CompactOrganisationDC_Organisation.MapToNewDC(costbearer);
selected.Add("CostBearerName", costbearer_dc.Name);
}
- if (tryGetSingleValue(sorted, TableID.SupportConcept, out long soid))
+ if (bewoobjects.TryGetValue(TableID.SupportConcept, out long[] svalues) && (svalues?.Length ?? 0) > 0)
{
- var supportconcept = DAOFactory.GenericDAO.GetByID(soid);
+ var supportconcept = DAOFactory.GenericDAO.GetByID(svalues[0]);
var supportconcept_dc = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDC(supportconcept);
selected.Add("SupportConceptDuration", $"{supportconcept_dc.StartDate?.Date} - {supportconcept_dc.EndDate?.Date}");
}
var records = new List>();
- if (tryGetMultipleValues(sorted, TableID.ServiceRecord, out List oids))
+ if (bewoobjects.TryGetValue(TableID.ServiceRecord, out long[] values) && (values?.Length ?? 0) > 0)
{
- var service_records = DAOFactory.GenericDAO.GetByIDs(oids);
+ var service_records = DAOFactory.GenericDAO.GetByIDs(values);
var service_records_dc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(service_records);
foreach (var service_record in service_records_dc)
@@ -163,41 +161,41 @@ namespace BeWo.Service.ServiceUtils
}
}
- private static Dictionary> getDictionary(List> tuples)
- {
- var seperate = new Dictionary>();
- foreach (var bewoobject in tuples)
- {
- var oid = bewoobject.Item1;
- var tid = bewoobject.Item2;
+ //private static Dictionary> getDictionary(List> tuples)
+ //{
+ // var seperate = new Dictionary>();
+ // foreach (var bewoobject in tuples)
+ // {
+ // var tid = bewoobject.Item1;
+ // var oid = bewoobject.Item2;
- if (seperate.TryGetValue(tid, out var list))
- {
- list.Add(oid);
- }
- else
- {
- seperate.Add(tid, new List() { oid });
- }
- }
- return seperate;
- }
+ // if (seperate.TryGetValue(tid, out var list))
+ // {
+ // list.Add(oid);
+ // }
+ // else
+ // {
+ // seperate.Add(tid, new List() { oid });
+ // }
+ // }
+ // return seperate;
+ //}
- private static bool tryGetSingleValue(Dictionary> sorted, TableID tid, out long oid)
- {
- oid = 0;
+ //private static bool tryGetSingleValue(Dictionary> sorted, TableID tid, out long oid)
+ //{
+ // oid = 0;
- if (!tryGetMultipleValues(sorted, tid, out List oids) || oids is null || oids.Count == 0)
- return false;
+ // if (!tryGetMultipleValues(sorted, tid, out List oids) || oids is null || oids.Count == 0)
+ // return false;
- oid = oids[0];
+ // oid = oids[0];
- return true;
- }
+ // return true;
+ //}
- private static bool tryGetMultipleValues(Dictionary> sorted, TableID tid, out List oids)
- {
- return sorted.TryGetValue((long)tid, out oids);
- }
+ //private static bool tryGetMultipleValues(Dictionary> sorted, TableID tid, out List oids)
+ //{
+ // return sorted.TryGetValue(tid, out oids);
+ //}
}
}
diff --git a/Shared/Core/SettingsKeys.cs b/Shared/Core/SettingsKeys.cs
index d2004b83d..b4cd4c7bc 100644
--- a/Shared/Core/SettingsKeys.cs
+++ b/Shared/Core/SettingsKeys.cs
@@ -2,7 +2,11 @@
{
public static class SettingsKeys
{
- public static string ShowExpiredSupportConcepts => "ShowExpiredSupportConcepts";
+ // Modules
+ public static string ModuleAiEnabled => "ModuleAiEnabled";
+
+
+ public static string ShowExpiredSupportConcepts => "ShowExpiredSupportConcepts";
public static string ShowOnlyMySupportConcepts => "ShowOnlyMySupportConcepts";
public static string LastSelectedServiceRecordTimeInterval => "LastSelectedServiceRecordTimeInterval";
public static string CustomerFilterInZeiterfassung => "CustomerFilterInZeiterfassung";
diff --git a/Shared/DataContracts/Feature/AI/AiConversationDC.cs b/Shared/DataContracts/Feature/AI/AiConversationDC.cs
index 069d14c7c..b42e518f9 100644
--- a/Shared/DataContracts/Feature/AI/AiConversationDC.cs
+++ b/Shared/DataContracts/Feature/AI/AiConversationDC.cs
@@ -26,7 +26,7 @@ namespace BS.Shared.DataContracts.Feature.AI
[DataMember] public DateTime Updated { get; set; }
[DataMember] public AiModelDC Modell { get; set; }
[DataMember] public string Context { get; set; }
- [DataMember] public List> ContextBeWoObjects { get; set; }
+ [DataMember] public Dictionary ContextBeWoObjects { get; set; }
[DataMember] public int UIContext { get; set; }
[DataMember] public List Messages { get; set; }
}