AiPromptbaustein erster Wurf
This commit is contained in:
@@ -109,6 +109,9 @@
|
||||
<Compile Include="Services\IWindowService.cs" />
|
||||
<Compile Include="ViewModel\AddressVM.cs" />
|
||||
<Compile Include="ViewModel\AiConfigVM.cs" />
|
||||
<Compile Include="ViewModel\ListViewModel\AiPromptbausteinListVM.cs" />
|
||||
<Compile Include="ViewModel\TextModuleListVM.cs" />
|
||||
<Compile Include="ViewModel\AiPromptbausteinVM.cs" />
|
||||
<Compile Include="ViewModel\View\AiConversationChatViewModel.cs" />
|
||||
<Compile Include="ViewModel\View\WindowViewModel.cs" />
|
||||
<Compile Include="View\Core\WaitLayer3.xaml.cs">
|
||||
@@ -117,6 +120,9 @@
|
||||
<Compile Include="View\Detail\AI\AiConfigView.xaml.cs">
|
||||
<DependentUpon>AiConfigView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\Detail\AI\AiPromptbausteinView.xaml.cs">
|
||||
<DependentUpon>AiPromptbausteinView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="View\Document\RtfEditView.xaml.cs">
|
||||
<DependentUpon>RtfEditView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -136,6 +142,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="View\Detail\AI\AiPromptbausteinView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="View\Document\RtfEditView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
151
BeWo/View/Detail/AI/AiPromptbausteinView.xaml
Normal file
151
BeWo/View/Detail/AI/AiPromptbausteinView.xaml
Normal file
@@ -0,0 +1,151 @@
|
||||
<view:BeWoView x:Class="BeWo.View.Detail.AiPromptbausteinView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:view="clr-namespace:BeWo.View"
|
||||
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
|
||||
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
|
||||
xmlns:detail="clr-namespace:BeWo.View.Detail"
|
||||
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
|
||||
Height="Auto" Width="Auto" HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch" Focusable="True">
|
||||
<view:BeWoView.Resources>
|
||||
<detail:IsOnlyForEmployeeRightsConverter x:Key="IsOnlyForEmployeeRightsConverter" />
|
||||
<detail:AiPromptbausteinEditConverter x:Key="AiPromptbausteinEditConverter" />
|
||||
</view:BeWoView.Resources>
|
||||
<GroupBox Name="root" Header="Aktuell definierte KI-Prompts" Style="{StaticResource ObjectEditGroupBox}">
|
||||
<Grid VerticalAlignment="Stretch">
|
||||
<Grid.Resources>
|
||||
<ContextMenu x:Key="ContextMenuAiPromptbausteine" MenuItem.Click="ContextMenuAiPromptbausteine_Click" Opened="ContextMenuAiPromptbausteine_Opened">
|
||||
<MenuItem Header="Neue KI Prompt-Kategorie">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="..\..\Ressources\Icons\Add24.png"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Neuer KI-Prompt">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="..\..\Ressources\Icons\Add24.png"/>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</Grid.Resources>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Column="0" Grid.Row="0" Content="Name" />
|
||||
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Path=NewVM.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="150" />
|
||||
<Label Grid.Column="2" Grid.Row="0" Content="Text" />
|
||||
<TextBox Grid.Column="3" Grid.Row="0" Grid.RowSpan="2" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" Text="{Binding Path=NewVM.Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding Path=NewVM.IsParent, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BoolReverseConverter}}" />
|
||||
<Label Grid.Column="0" Grid.Row="1" Content="KI Prompt-Kategorie" />
|
||||
<dxe:ComboBoxEdit Grid.Column="1" Grid.Row="1" Margin="3" Height="23" Width="150" EditMode="Standalone"
|
||||
ItemsSource="{Binding Path=PossibleAiPromptbausteinParents}"
|
||||
SelectedItem="{Binding Path=NewVM.Parent}">
|
||||
<dxe:ComboBoxEdit.Buttons>
|
||||
<dxe:ButtonInfo GlyphKind="Cancel" Click="RemoveParentAiPromptbausteinFromNewVM_OnClick" />
|
||||
</dxe:ComboBoxEdit.Buttons>
|
||||
</dxe:ComboBoxEdit>
|
||||
<CheckBox Grid.Column="0" Grid.Row="2" Content="Ist AiPromptbausteinkategorie" Margin="3" IsChecked="{Binding Path=NewVM.IsParent, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Checked="IsAiPromptbausteinParent_Checked" />
|
||||
<Button Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="4" HorizontalAlignment="Right" Content="Hinzufügen" Margin="3,3,0,3" Click="AddAiPromptbausteinButton_Click" />
|
||||
<dxg:TreeListControl Name="TreeListControl" Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="4" dx:ThemeManager.ThemeName="Office2010Black" ItemsSource="{Binding Path=VMList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0" ContextMenu="{StaticResource ContextMenuAiPromptbausteine}"
|
||||
ItemsSourceChanged="TreeListControl_ItemsSourceChanged"
|
||||
PreviewMouseDown="TreeListControl_OnPreviewMouseDown">
|
||||
<dxg:TreeListControl.Columns>
|
||||
<dxg:TreeListColumn FieldName="IsDeleteable" FixedWidth="True" Width="24" ReadOnly="True" Header=" ">
|
||||
<dxg:TreeListColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Button Content="r" Click="DeleteButton_Click" FontFamily="Webdings" Width="18" Height="18" VerticalAlignment="Center">
|
||||
<Button.IsEnabled>
|
||||
<MultiBinding Converter="{StaticResource AiPromptbausteinEditConverter}">
|
||||
<Binding />
|
||||
<Binding Path="DataContext.RowData.Row" RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
</MultiBinding>
|
||||
</Button.IsEnabled>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</dxg:TreeListColumn.CellTemplate>
|
||||
</dxg:TreeListColumn>
|
||||
<dxg:TreeListColumn FieldName="Name">
|
||||
<dxg:TreeListColumn.DisplayTemplate>
|
||||
<ControlTemplate>
|
||||
<dxe:TextEdit EditMode="InplaceInactive" FontWeight="{Binding Path=DataContext.RowData.Row.FontWeight, RelativeSource={RelativeSource TemplatedParent}}" Text="{Binding Path=DataContext.RowData.Row.Name, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}">
|
||||
<dxe:TextEdit.IsEnabled>
|
||||
<MultiBinding Converter="{StaticResource AiPromptbausteinEditConverter}">
|
||||
<Binding />
|
||||
<Binding Path="DataContext.RowData.Row" RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
</MultiBinding>
|
||||
</dxe:TextEdit.IsEnabled>
|
||||
</dxe:TextEdit>
|
||||
</ControlTemplate>
|
||||
</dxg:TreeListColumn.DisplayTemplate>
|
||||
<dxg:TreeListColumn.EditTemplate>
|
||||
<ControlTemplate>
|
||||
<dxe:TextEdit x:Name="PART_Editor" EditMode="InplaceActive" FontWeight="{Binding Path=DataContext.RowData.Row.FontWeight, RelativeSource={RelativeSource TemplatedParent}}" Text="{Binding Path=DataContext.RowData.Row.Name, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}">
|
||||
<dxe:TextEdit.IsEnabled>
|
||||
<MultiBinding Converter="{StaticResource AiPromptbausteinEditConverter}">
|
||||
<Binding />
|
||||
<Binding Path="DataContext.RowData.Row" RelativeSource="{RelativeSource TemplatedParent}" />
|
||||
</MultiBinding>
|
||||
</dxe:TextEdit.IsEnabled>
|
||||
</dxe:TextEdit>
|
||||
</ControlTemplate>
|
||||
</dxg:TreeListColumn.EditTemplate>
|
||||
</dxg:TreeListColumn>
|
||||
<dxg:TreeListColumn FieldName="Text">
|
||||
<dxg:TreeListColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<dxe:TextEdit x:Name="PART_Editor" EditMode="InplaceActive" Text="{Binding Path=DataContext.RowData.Row.Text, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
|
||||
IsEnabled="{Binding Path=DataContext.RowData.Row, Converter={StaticResource IsOnlyForEmployeeRightsConverter}, RelativeSource={RelativeSource TemplatedParent}}" AcceptsReturn="True" AcceptsTab="True" TextTrimming="WordEllipsis" TextWrapping="Wrap" SelectAllOnGotFocus="False" SelectAllOnMouseUp="False" />
|
||||
</DataTemplate>
|
||||
</dxg:TreeListColumn.CellTemplate>
|
||||
</dxg:TreeListColumn>
|
||||
<dxg:TreeListColumn FieldName="Parent" Header="KI Prompt-Kategorie">
|
||||
<dxg:TreeListColumn.DisplayTemplate>
|
||||
<ControlTemplate>
|
||||
<dxe:ComboBoxEdit EditMode="InplaceActive" IsTextEditable="False"
|
||||
ItemsSource="{Binding Path=DataContext.PossibleAiPromptbausteinParents, RelativeSource={RelativeSource FindAncestor, AncestorType=dxg:TreeListControl}}"
|
||||
SelectedItem="{Binding Path=DataContext.RowData.Row.Parent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||
Tag="{Binding Path=DataContext.RowData.Row, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Loaded="FrameworkElement_OnLoaded">
|
||||
<dxe:ComboBoxEdit.Buttons>
|
||||
<dxe:ButtonInfo GlyphKind="Cancel" Click="ButtonInfo_OnClick" Tag="{Binding}" />
|
||||
</dxe:ComboBoxEdit.Buttons>
|
||||
</dxe:ComboBoxEdit>
|
||||
</ControlTemplate>
|
||||
</dxg:TreeListColumn.DisplayTemplate>
|
||||
<dxg:TreeListColumn.EditTemplate>
|
||||
<ControlTemplate>
|
||||
<!-- KI Prompt-Kategorie -->
|
||||
<dxe:ComboBoxEdit x:Name="PART_Editor" EditMode="InplaceActive" IsTextEditable="False"
|
||||
ItemsSource="{Binding Path=DataContext.PossibleAiPromptbausteinParents, RelativeSource={RelativeSource FindAncestor, AncestorType=dxg:TreeListControl}}"
|
||||
SelectedItem="{Binding Path=DataContext.RowData.Row.Parent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||
EditValueChanged="PART_Editor_OnEditValueChanged"
|
||||
Tag="{Binding Path=DataContext.RowData.Row, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||
Loaded="FrameworkElement_OnLoaded">
|
||||
<dxe:ComboBoxEdit.Buttons>
|
||||
<dxe:ButtonInfo GlyphKind="Cancel" Click="ButtonInfo_OnClick" Tag="{Binding}" />
|
||||
</dxe:ComboBoxEdit.Buttons>
|
||||
</dxe:ComboBoxEdit>
|
||||
</ControlTemplate>
|
||||
</dxg:TreeListColumn.EditTemplate>
|
||||
</dxg:TreeListColumn>
|
||||
</dxg:TreeListControl.Columns>
|
||||
<dxg:TreeListControl.View>
|
||||
<dxg:TreeListView Name="TreeListView" AutoWidth="True" KeyFieldName="KeyField" ParentFieldName="ParentField"
|
||||
ExpandStateBinding="{Binding Path=IsExpanded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
/>
|
||||
</dxg:TreeListControl.View>
|
||||
</dxg:TreeListControl>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</view:BeWoView>
|
||||
304
BeWo/View/Detail/AI/AiPromptbausteinView.xaml.cs
Normal file
304
BeWo/View/Detail/AI/AiPromptbausteinView.xaml.cs
Normal file
@@ -0,0 +1,304 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
|
||||
using BeWo.ServiceProxy;
|
||||
using BeWo.ViewModel;
|
||||
using BeWo.ViewModel.ListViewModel;
|
||||
|
||||
using BS.Shared;
|
||||
using BS.Shared.Extensions;
|
||||
using BS.Shared.Translation;
|
||||
using DevExpress.Xpf.Editors;
|
||||
using DevExpress.Xpf.Grid;
|
||||
|
||||
namespace BeWo.View.Detail
|
||||
{
|
||||
public partial class AiPromptbausteinView
|
||||
{
|
||||
private AiPromptbausteinListVM _ViewModel;
|
||||
|
||||
public AiPromptbausteinListVM ViewModel
|
||||
{
|
||||
get => _ViewModel;
|
||||
|
||||
set
|
||||
{
|
||||
_ViewModel = value;
|
||||
root.DataContext = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsDirty => ViewModel != null && ViewModel.IsDirty;
|
||||
|
||||
private readonly bool _IsInAdministrationView;
|
||||
|
||||
public AiPromptbausteinView(AiPromptbausteinListVM pViewModel, bool pIsInAdministrationView = false)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_IsInAdministrationView = pIsInAdministrationView;
|
||||
|
||||
ViewModel = pViewModel;
|
||||
}
|
||||
|
||||
protected override void Save()
|
||||
{
|
||||
Save(null);
|
||||
}
|
||||
|
||||
public void Save(Action pCallBack)
|
||||
{
|
||||
var lToDos = new List<Action<IOperationsService>>();
|
||||
|
||||
if(ViewModel.ChangedCount == 0 && ViewModel.RemovedCount == 0 && ViewModel.AddedCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ViewModel.AddedCount > 0)
|
||||
{
|
||||
lToDos.Add(s => s.InsertNewAiPromptbausteine(ViewModel.CommitAdded()));
|
||||
}
|
||||
|
||||
if (ViewModel.RemovedCount > 0)
|
||||
{
|
||||
lToDos.Add(s => s.DeleteAiPromptbausteine(ViewModel.GetRemoved().ToDictionary(dc => dc.Oid.Value, dc => dc.Version.Value)));
|
||||
}
|
||||
|
||||
if (ViewModel.ChangedCount > 0)
|
||||
{
|
||||
lToDos.Add(s => s.UpdateAiPromptbausteine(ViewModel.CommitChanged()));
|
||||
}
|
||||
|
||||
ServiceFacade.DoMultipleOperationsServicesAsync(lToDos, () =>
|
||||
{
|
||||
pCallBack?.Invoke();
|
||||
ReloadViewModel();
|
||||
});
|
||||
}
|
||||
|
||||
private void ReloadViewModel()
|
||||
{
|
||||
VMFactory.CreateAiPromptbausteinListVMAsync(r => this.Dispatch(delegate
|
||||
{
|
||||
TreeListControl.BeginDataUpdate();
|
||||
|
||||
ViewModel = r;
|
||||
|
||||
TreeListControl.EndDataUpdate();
|
||||
|
||||
TreeListControl.SelectedItems.Clear();
|
||||
|
||||
}), _IsInAdministrationView);
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var focusedNode = TreeListView.FocusedNode;
|
||||
var selectedAiPromptbaustein = (AiPromptbausteinVM) focusedNode.Content;
|
||||
|
||||
String msg = "der ausgewähte KI-Prompt";
|
||||
if (selectedAiPromptbaustein.IsParent)
|
||||
{
|
||||
msg = "die ausgewähte Kategorie";
|
||||
}
|
||||
|
||||
if (MessageBox.Show(Translator.Translate("Sie Sie sicher, dass {0} \"{1}\" gelöscht werden soll?", msg, selectedAiPromptbaustein.Name), "Löschen", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes)
|
||||
{
|
||||
_ChildrenToDelete.Add(selectedAiPromptbaustein);
|
||||
|
||||
if (selectedAiPromptbaustein.IsParent)
|
||||
{
|
||||
RetrieveChildAiPromptbausteinsFromParent(selectedAiPromptbaustein);
|
||||
}
|
||||
|
||||
ViewModel.VMList.RemoveRange(_ChildrenToDelete);
|
||||
_ChildrenToDelete.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<AiPromptbausteinVM> _ChildrenToDelete = new List<AiPromptbausteinVM>();
|
||||
|
||||
private void RetrieveChildAiPromptbausteinsFromParent(AiPromptbausteinVM parent)
|
||||
{
|
||||
var children = ViewModel.VMList.Where(w => w.Parent != null && w.Parent.Equals(parent));
|
||||
|
||||
foreach(var child in children)
|
||||
{
|
||||
_ChildrenToDelete.Add(child);
|
||||
RetrieveChildAiPromptbausteinsFromParent(child);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckEditorRights(AiPromptbausteinVM textbausteinVM, object parameter)
|
||||
{
|
||||
if (textbausteinVM != null)
|
||||
{
|
||||
var isOwn = textbausteinVM.Employee != null && textbausteinVM.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid);
|
||||
|
||||
var hasRight2EditAll = BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineAlleBearbeiten);
|
||||
var hasRight2EditOwn = BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineNurEigeneBearbeiten);
|
||||
var hasRight2Create4All = BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineAlleBearbeiten);
|
||||
|
||||
if (parameter != null && parameter.ToString().Equals("IsOnlyForEmployeeCheckBox"))
|
||||
{
|
||||
return isOwn && hasRight2EditOwn && hasRight2Create4All || hasRight2EditAll;
|
||||
}
|
||||
|
||||
return isOwn && hasRight2EditOwn || hasRight2EditAll;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ContextMenuAiPromptbausteins_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(e.OriginalSource is MenuItem twi)
|
||||
{
|
||||
var selectedItem = TreeListControl.SelectedItem as AiPromptbausteinVM;
|
||||
|
||||
ViewModel.NewVM.IsParent = twi.Header.Equals("Neue Textbausteinkategorie");
|
||||
ViewModel.NewVM.IsExpanded = twi.Header.Equals("Neue Textbausteinkategorie");
|
||||
ViewModel.NewVM.IsOnlyForEmployee = !_IsInAdministrationView;
|
||||
ViewModel.NewVM.Name = GenerateNewAiPromptbausteinName(twi.Header.ToString());
|
||||
|
||||
if(selectedItem != null)
|
||||
{
|
||||
ViewModel.NewVM.Parent = selectedItem;
|
||||
}
|
||||
|
||||
ViewModel.AddNewVMToList(false);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
private string GenerateNewAiPromptbausteinName(string pName)
|
||||
{
|
||||
var newName = pName;
|
||||
var counter = 1;
|
||||
|
||||
while(ViewModel.VMList.Any(a => a.Name != null && a.Name.Equals(newName)))
|
||||
{
|
||||
newName = pName + " " + counter;
|
||||
counter++;
|
||||
}
|
||||
|
||||
return newName;
|
||||
}
|
||||
|
||||
private void ContextMenuAiPromptbausteins_Opened(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (e.OriginalSource is ContextMenu menu)
|
||||
{
|
||||
var aiPromptbaustein = TreeListControl.SelectedItem as AiPromptbausteinVM;
|
||||
|
||||
foreach (var menuitem in menu.Items.OfType<MenuItem>().Select(item => item))
|
||||
{
|
||||
if(aiPromptbaustein != null && !aiPromptbaustein.IsParent)
|
||||
{
|
||||
menuitem.IsEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
menuitem.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TreeListControl_ItemsSourceChanged(object sender, DevExpress.Xpf.Grid.ItemsSourceChangedEventArgs e)
|
||||
{
|
||||
TreeListControl.SelectedItem = null;
|
||||
}
|
||||
|
||||
private void TreeListControl_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var hitInfo = TreeListView.CalcHitInfo(e.OriginalSource as DependencyObject);
|
||||
if(!hitInfo.InRowCell)
|
||||
{
|
||||
TreeListControl.SelectedItem = null;
|
||||
}
|
||||
|
||||
e.Handled = false;
|
||||
}
|
||||
|
||||
private void ButtonInfo_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(sender is Button btn && btn.TemplatedParent is ButtonContainer bc)
|
||||
{
|
||||
if(bc.Content is ButtonInfo bi)
|
||||
{
|
||||
if(bi.Tag is EditGridCellData cellData)
|
||||
{
|
||||
var vm = (AiPromptbausteinVM) cellData.RowData.Row;
|
||||
|
||||
vm.Parent = null;
|
||||
vm.IsParent = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: wird das gebraucht? Was tut es?
|
||||
private void PART_Editor_OnEditValueChanged(object sender, EditValueChangedEventArgs e)
|
||||
{
|
||||
var comboBoxEdit = (ComboBoxEdit) sender;
|
||||
var selectedAiPromptbaustein = (AiPromptbausteinVM) comboBoxEdit.Tag;
|
||||
|
||||
var oldValue = e.OldValue;
|
||||
var newValue = e.NewValue;
|
||||
|
||||
if(e.NewValue != null)
|
||||
{
|
||||
selectedAiPromptbaustein.Parent = (AiPromptbausteinVM) e.NewValue;
|
||||
}
|
||||
}
|
||||
|
||||
private void FrameworkElement_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var comboBoxEdit = (ComboBoxEdit) sender;
|
||||
|
||||
var aiPromptbaustein = (AiPromptbausteinVM) comboBoxEdit.Tag;
|
||||
|
||||
comboBoxEdit.ItemsSource = ViewModel.GetAiPromptbausteinParents(aiPromptbaustein);
|
||||
}
|
||||
|
||||
private void RemoveParentAiPromptbausteinFromNewVM_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.NewVM.Parent = null;
|
||||
}
|
||||
|
||||
private void IsAiPromptbausteinParent_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.NewVM.Text = null;
|
||||
}
|
||||
|
||||
private void AddAiPromptbausteinButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.NewVM.IsOnlyForEmployee = !_IsInAdministrationView;
|
||||
ViewModel.AddNewVMToList(false);
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public class IsOnlyForEmployeeRightsConverter2 : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var aiPromptbausteinVM = (AiPromptbausteinVM)value;
|
||||
|
||||
return AiPromptbausteinView.CheckEditorRights(aiPromptbausteinVM, parameter) && aiPromptbausteinVM != null && !aiPromptbausteinVM.IsParent;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
250
BeWo/ViewModel/AiPromptbausteinVM.cs
Normal file
250
BeWo/ViewModel/AiPromptbausteinVM.cs
Normal file
@@ -0,0 +1,250 @@
|
||||
using System.Windows;
|
||||
|
||||
using BeWo.ServiceProxy;
|
||||
using BeWo.Validation;
|
||||
|
||||
using BS.Shared;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
|
||||
namespace BeWo.ViewModel
|
||||
{
|
||||
public class AiPromptbausteinVM : AbstractDCMapperVM<AiPromptbausteinDC>
|
||||
{
|
||||
private int _Position;
|
||||
|
||||
private string _Text;
|
||||
|
||||
private string _Name;
|
||||
|
||||
private CompactEmployeeDC _Employee;
|
||||
|
||||
private ServiceCategoryDC _ServiceCategory;
|
||||
|
||||
private bool _IsOnlyForEmployee;
|
||||
|
||||
private bool _IsParent;
|
||||
|
||||
private bool _IsExpanded;
|
||||
|
||||
private AiPromptbausteinVM _Parent;
|
||||
|
||||
private ActivationTypeId _ActivationType;
|
||||
|
||||
public AiPromptbausteinVM(AiPromptbausteinDC pDataContract) : base(pDataContract, pDataContract.Oid == null) {}
|
||||
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get => _IsExpanded;
|
||||
|
||||
set
|
||||
{
|
||||
if(AreDifferent(_IsExpanded, value))
|
||||
{
|
||||
_IsExpanded = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.IsExpanded, value), nameof(IsExpanded));
|
||||
FirePropertyChanged(nameof(IsExpanded));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CompactEmployeeDC Employee
|
||||
{
|
||||
get => _Employee;
|
||||
|
||||
set
|
||||
{
|
||||
if (AreDifferent(_Employee, value))
|
||||
{
|
||||
_Employee = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.Employee, value), nameof(Employee));
|
||||
FirePropertyChanged(nameof(Employee));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ActivationTypeId ActivationType
|
||||
{
|
||||
get => _ActivationType;
|
||||
|
||||
set
|
||||
{
|
||||
if(AreDifferent(_ActivationType, value))
|
||||
{
|
||||
_ActivationType = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.ActivationType, value), nameof(ActivationType));
|
||||
|
||||
FirePropertyChanged(nameof(ActivationType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Position
|
||||
{
|
||||
get => _Position;
|
||||
|
||||
set
|
||||
{
|
||||
if (AreDifferent(_Position, value))
|
||||
{
|
||||
_Position = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.Position, value), nameof(Position));
|
||||
FirePropertyChanged(nameof(Position));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => _Text;
|
||||
|
||||
set
|
||||
{
|
||||
if (AreDifferent(_Text, value))
|
||||
{
|
||||
_Text = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.Text, value), nameof(Text));
|
||||
FirePropertyChanged(nameof(Text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsOnlyForEmployee
|
||||
{
|
||||
get => _IsOnlyForEmployee;
|
||||
|
||||
set
|
||||
{
|
||||
if (AreDifferent(_IsOnlyForEmployee, value))
|
||||
{
|
||||
_IsOnlyForEmployee = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.IsOnlyForEmployee, value), nameof(IsOnlyForEmployee));
|
||||
FirePropertyChanged(nameof(IsOnlyForEmployee));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsParent
|
||||
{
|
||||
get => _IsParent;
|
||||
|
||||
set
|
||||
{
|
||||
if(AreDifferent(_IsParent, value))
|
||||
{
|
||||
_IsParent = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.IsParent, value), nameof(IsParent));
|
||||
FirePropertyChanged(nameof(IsParent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AiPromptbausteinVM Parent
|
||||
{
|
||||
get => _Parent;
|
||||
|
||||
set
|
||||
{
|
||||
if(AreDifferent(_Parent, value) && AreDifferent(value, this))
|
||||
{
|
||||
_Parent = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.Parent, value), nameof(Parent));
|
||||
FirePropertyChanged(nameof(Parent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FontWeight FontWeight => _IsParent ? FontWeights.Bold : FontWeights.Normal;
|
||||
|
||||
public long? KeyField => DataContract?.Oid;
|
||||
|
||||
public long? ParentField => Parent?.DataContract?.Oid;
|
||||
|
||||
[Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
|
||||
public string Name
|
||||
{
|
||||
get => _Name;
|
||||
|
||||
set
|
||||
{
|
||||
if (AreDifferent(_Name, value))
|
||||
{
|
||||
_Name = value;
|
||||
StoreDirtyInformation(AreDifferent(DataContract.Name, value), nameof(Name));
|
||||
FirePropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void InitByDataContract(AiPromptbausteinDC pDataContract)
|
||||
{
|
||||
if (!IsNew)
|
||||
{
|
||||
_Text = pDataContract.Text;
|
||||
_Position = pDataContract.Position;
|
||||
_Name = pDataContract.Name;
|
||||
_Employee = pDataContract.Employee;
|
||||
_IsOnlyForEmployee = pDataContract.IsOnlyForEmployee;
|
||||
_IsParent = pDataContract.IsParent;
|
||||
_Parent = pDataContract.Parent != null ? new AiPromptbausteinVM(pDataContract.Parent) : null;
|
||||
_IsExpanded = pDataContract.IsExpanded;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ServiceFacade.DoEmployeeServiceSync(s => _Employee = s.LoadCompactEmployee(BeWoApp.LoggedOnEmployee.EmployeeOid.Value));
|
||||
|
||||
if (BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineNurEigeneBearbeiten) && !BeWoApp.LoggedOnUser.HasRight(UserRightType.TextbausteineAlleBearbeiten))
|
||||
{
|
||||
_IsOnlyForEmployee = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override AiPromptbausteinDC MapToDataContract(AiPromptbausteinDC pDataContract, bool doCommit)
|
||||
{
|
||||
pDataContract.Text = _Text;
|
||||
pDataContract.Position = _Position;
|
||||
pDataContract.Name = _Name;
|
||||
pDataContract.IsParent = _IsParent;
|
||||
pDataContract.IsExpanded = _IsExpanded;
|
||||
pDataContract.ActivationType = _ActivationType;
|
||||
|
||||
pDataContract.IsOnlyForEmployee = _IsOnlyForEmployee;
|
||||
|
||||
pDataContract.Parent = _Parent?.CommitToDataContract();
|
||||
|
||||
pDataContract.Employee = _Employee;
|
||||
|
||||
return pDataContract;
|
||||
}
|
||||
|
||||
public override bool Equals(object pObj)
|
||||
{
|
||||
if (!(pObj is AiPromptbausteinVM))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var obj = (AiPromptbausteinVM) pObj;
|
||||
|
||||
return
|
||||
Equals(IsNew, obj.IsNew) &&
|
||||
Equals(ServiceCategory, obj.ServiceCategory) &&
|
||||
Equals(Text, obj.Text) &&
|
||||
Equals(Position, obj.Position) &&
|
||||
Equals(Parent, obj.Parent) &&
|
||||
Equals(Name, obj.Name) &&
|
||||
Equals(Employee, obj.Employee) &&
|
||||
Equals(IsOnlyForEmployee, obj.IsOnlyForEmployee) &&
|
||||
Equals(IsParent, obj.IsParent) &&
|
||||
Equals(IsDirty, obj.IsDirty);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return _Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
BeWo/ViewModel/ListViewModel/AiPromptbausteinListVM.cs
Normal file
28
BeWo/ViewModel/ListViewModel/AiPromptbausteinListVM.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BS.Shared.DataContracts;
|
||||
|
||||
namespace BeWo.ViewModel.ListViewModel
|
||||
{
|
||||
public class AiPromptbausteinListVM : AbstractDCListMapperVM<AiPromptbausteinDC, AiPromptbausteinVM>
|
||||
{
|
||||
public static string PropertyName_PossibleAiPromptbausteinParents = "PossibleAiPromptbausteinParents";
|
||||
|
||||
private readonly List<AiPromptbausteinVM> _PossibleAiPromptbausteinParents;
|
||||
|
||||
|
||||
public AiPromptbausteinListVM(IEnumerable<AiPromptbausteinDC> pDataContracts) : base(pDataContracts)
|
||||
{
|
||||
_PossibleAiPromptbausteinParents = VMList.Where(w => w.IsParent).ToList();
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<AiPromptbausteinVM> PossibleAiPromptbausteinParents => _PossibleAiPromptbausteinParents;
|
||||
|
||||
public IEnumerable<AiPromptbausteinVM> GetAiPromptbausteinParents(AiPromptbausteinVM aiPromptbaustein)
|
||||
{
|
||||
return _PossibleAiPromptbausteinParents.Except(new List<AiPromptbausteinVM> {aiPromptbaustein});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,19 +13,19 @@
|
||||
<basicHttpBinding>
|
||||
<binding name="BeWoBasicEndpoint" closeTimeout="00:05:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text">
|
||||
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
|
||||
<!--<security mode="None" />-->
|
||||
<security mode="Transport"/>
|
||||
<security mode="None" />
|
||||
<!--security mode="Transport"/-->
|
||||
<!-- mode="Transport" für https und "None" sonst-->
|
||||
</binding>
|
||||
<binding name="BeWoStreamingEndpoint" receiveTimeout="10:10:00" sendTimeout="10:01:00" maxBufferSize="65536" maxReceivedMessageSize="67108864" transferMode="StreamedRequest" useDefaultWebProxy="true" messageEncoding="Text">
|
||||
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
|
||||
<!--<security mode="None" />-->
|
||||
<security mode="Transport"/>
|
||||
<security mode="None" />
|
||||
<!--security mode="Transport"/-->
|
||||
<!-- mode="Transport" für https und "None" sonst-->
|
||||
</binding>
|
||||
<binding name="QueryServiceEndpoint" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text">
|
||||
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
|
||||
<security mode="Transport">
|
||||
<security mode="None">
|
||||
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
|
||||
<message clientCredentialType="UserName" algorithmSuite="Default"/>
|
||||
</security>
|
||||
|
||||
@@ -2778,6 +2778,41 @@ WHERE sc.Billable = 1 and sr.StartDate >= '{0:yyyy-MM-dd}' and sr.StartDate < '{
|
||||
return criteria.List<TextModule>();
|
||||
}
|
||||
|
||||
public IEnumerable<AiPromptbaustein> GetActiveAiPromptbausteine(bool shouldOnlyLoadOwnAiPromptbausteine, bool hasRightToSeeAll, bool isInAdministrationView, long employeeOid)
|
||||
{
|
||||
var criteria = CreateCriteriaIsActive<AiPromptbaustein>();
|
||||
|
||||
if (isInAdministrationView)
|
||||
{
|
||||
criteria.Add(Restrictions.Eq(nameof(AiPromptbaustein.IsOnlyForEmployee), false));
|
||||
}
|
||||
else if (!hasRightToSeeAll)
|
||||
{
|
||||
criteria.Add(Restrictions.Eq(nameof(AiPromptbaustein.IsOnlyForEmployee), true))
|
||||
.Add(Restrictions.Eq(nameof(AiPromptbaustein.Employee) + "." + nameof(BeWoEntityBase.Oid), employeeOid));
|
||||
}
|
||||
else
|
||||
{
|
||||
criteria.Add(
|
||||
Restrictions.Or(
|
||||
Restrictions.And(
|
||||
Restrictions.Eq(nameof(AiPromptbaustein.IsOnlyForEmployee), true),
|
||||
Restrictions.Eq(nameof(AiPromptbaustein.Employee) + "." + nameof(BeWoEntityBase.Oid), employeeOid)),
|
||||
Restrictions.Eq(nameof(AiPromptbaustein.IsOnlyForEmployee), false)));
|
||||
}
|
||||
|
||||
return criteria.List<AiPromptbaustein>();
|
||||
}
|
||||
|
||||
public IEnumerable<AiPromptbaustein> GetChildAiPromptbausteine(AiPromptbaustein aiPromptbaustein)
|
||||
{
|
||||
var criteria = CreateCriteria<AiPromptbaustein>();
|
||||
|
||||
criteria.Add(Restrictions.Eq(nameof(AiPromptbaustein.Parent), aiPromptbaustein));
|
||||
|
||||
return criteria.List<AiPromptbaustein>();
|
||||
}
|
||||
|
||||
public IEnumerable<ChatBewoMessageSync> FindEmployeeChatBewoMessageSync(long oid)
|
||||
{
|
||||
var c = CreateCriteriaIsActive<ChatBewoMessageSync>()
|
||||
|
||||
@@ -235,6 +235,7 @@
|
||||
<Compile Include="Entities\AiConversation.cs" />
|
||||
<Compile Include="Entities\AiConversationMessage.cs" />
|
||||
<Compile Include="Entities\AiConfig.cs" />
|
||||
<Compile Include="Entities\AiPromptbaustein.cs" />
|
||||
<Compile Include="Entities\AiModel.cs" />
|
||||
<Compile Include="Entities\AiSetting.cs" />
|
||||
<Compile Include="Entities\AbsenceTimeHistory.cs" />
|
||||
@@ -842,6 +843,9 @@
|
||||
<EmbeddedResource Include="Mappings\OrganisationLight.hbm.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Mappings\AiPromptbaustein.hbm.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Content Include="Mappings\Timesheet2Mail.hbm.xml" />
|
||||
<EmbeddedResource Include="Mappings\ContactHistory.hbm.xml">
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
21
Data/Entities/AiPromptbaustein.cs
Normal file
21
Data/Entities/AiPromptbaustein.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using BS.Shared;
|
||||
|
||||
namespace BeWo.Data.Entities
|
||||
{
|
||||
public class AiPromptbaustein : BeWoEntityBase
|
||||
{
|
||||
public AiPromptbaustein()
|
||||
{
|
||||
_Tid = TableID.AiPromptbaustein;
|
||||
}
|
||||
|
||||
public virtual string Text { get; set; }
|
||||
public virtual int Position { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual Employee Employee { get; set; }
|
||||
public virtual bool IsOnlyForEmployee { get; set; }
|
||||
public virtual AiPromptbaustein Parent { get; set; }
|
||||
public virtual bool IsParent { get; set; }
|
||||
public virtual bool IsExpanded { get; set; }
|
||||
}
|
||||
}
|
||||
26
Data/Mappings/AiPromptbaustein.hbm.xml
Normal file
26
Data/Mappings/AiPromptbaustein.hbm.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
|
||||
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
|
||||
<class name="BeWo.Data.Entities.AiPromptbaustein,BeWo.Data" table="AiPromptbaustein">
|
||||
<id name="Oid" column="Oid" type="Int64" unsaved-value="null">
|
||||
<generator class="identity" />
|
||||
</id>
|
||||
<version type="Int64" column="Version" name="Version" />
|
||||
<property column="Tid" type="BS.Shared.TableID, BS.Shared" name="_Tid" access="field" />
|
||||
<property column="InsTs" type="DateTime" name="InsTs" />
|
||||
<property column="InsUser" type="String" name="InsUser" length="256" />
|
||||
<property column="IsActive" type="BS.Shared.ActivationTypeId, BS.Shared" name="IsActive" />
|
||||
<property column="SystemEntryID" type="BS.Shared.SystemEntryID, BS.Shared" name="SystemEntryID" />
|
||||
<property column="UdpUser" type="String" name="UdpUser" length="256" />
|
||||
<property column="Notice" type="String" name="Notice" length="1024" />
|
||||
<property column="Text" type="String" name="Text" length="1024" />
|
||||
<property column="Position" name="Position" type="Int32" />
|
||||
<property column="Name" type="String" name="Name" length="1024" />
|
||||
<property column="IsOnlyForEmployee" type="Boolean" name="IsOnlyForEmployee" />
|
||||
<property column="IsParent" type="Boolean" name="IsParent" />
|
||||
<property column="IsExpanded" type="Boolean" name="IsExpanded" />
|
||||
|
||||
<many-to-one name="Employee" column="EmployeeOid" class="BeWo.Data.Entities.Employee, BeWo.Data" cascade="none" fetch="join" />
|
||||
<many-to-one name="Parent" column="ParentOid" class="BeWo.Data.Entities.AiPromptbaustein, BeWo.Data" cascade="none" fetch="join" />
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
24
Model/Changes_2025-09-29 AI Promptbaustein.txt
Normal file
24
Model/Changes_2025-09-29 AI Promptbaustein.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
CREATE TABLE `AiPromptbaustein` (
|
||||
`Oid` bigint NOT NULL AUTO_INCREMENT,
|
||||
`Tid` int DEFAULT NULL,
|
||||
`IsActive` tinyint(1) DEFAULT NULL,
|
||||
`Notice` varchar(1024) DEFAULT NULL,
|
||||
`InsTs` datetime DEFAULT NULL,
|
||||
`InsUser` varchar(256) DEFAULT NULL,
|
||||
`Version` bigint DEFAULT NULL,
|
||||
`UdpUser` varchar(256) DEFAULT NULL,
|
||||
`SystemEntryID` int DEFAULT NULL,
|
||||
`Text` mediumtext,
|
||||
`Position` int DEFAULT NULL,
|
||||
`Name` varchar(256) DEFAULT NULL,
|
||||
`EmployeeOid` bigint DEFAULT NULL,
|
||||
`IsOnlyForEmployee` tinyint(1) DEFAULT NULL,
|
||||
`ParentOid` bigint DEFAULT NULL,
|
||||
`IsParent` tinyint(1) DEFAULT NULL,
|
||||
`IsExpanded` tinyint DEFAULT NULL,
|
||||
PRIMARY KEY (`Oid`),
|
||||
KEY `EMPLOYEE_AIPROMPTBAUSTEIN_FK` (`EmployeeOid`),
|
||||
KEY `FK_AIPROMPTBAUSTEIN2PARENT` (`ParentOid`),
|
||||
CONSTRAINT `FK_EMPLOYEE_AIPROMPT` FOREIGN KEY (`EmployeeOid`) REFERENCES `employee` (`Oid`),
|
||||
CONSTRAINT `FK_AIPROMPTBAUSTEIN2PARENT` FOREIGN KEY (`ParentOid`) REFERENCES `AiPromptbaustein` (`Oid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
108
Service/DCEntityMapper/AiPromptbausteinDC_AiPromptbaustein.cs
Normal file
108
Service/DCEntityMapper/AiPromptbausteinDC_AiPromptbaustein.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
|
||||
using BS.Shared.DataContracts;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BeWo.Service.DCEntityMapper
|
||||
{
|
||||
public class AiPromptbausteinDC_AiPromptbaustein : AbstractIDCEntityMapper<AiPromptbaustein, AiPromptbausteinDC>
|
||||
{
|
||||
public IList<AiPromptbausteinDC> CreateDcList(IEnumerable<AiPromptbaustein> aiPromptbausteine)
|
||||
{
|
||||
var list = new List<AiPromptbausteinDC>();
|
||||
Dictionary<long, IList<long>> parentChildDict = new Dictionary<long, IList<long>>();
|
||||
foreach (var aiPromptbaustein in aiPromptbausteine)
|
||||
{
|
||||
var dc = CreateAiPromptbausteinDC(aiPromptbaustein, parentChildDict);
|
||||
list.Add(dc);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private AiPromptbausteinDC CreateAiPromptbausteinDC(AiPromptbaustein tm, Dictionary<long, IList<long>> parentChildDict)
|
||||
{
|
||||
var dc = new AiPromptbausteinDC();
|
||||
dc.Position = tm.Position;
|
||||
dc.Version = tm.Version.Value;
|
||||
dc.Oid = tm.Oid.Value;
|
||||
dc.Text = tm.Text;
|
||||
dc.Name = tm.Name;
|
||||
dc.IsOnlyForEmployee = tm.IsOnlyForEmployee;
|
||||
dc.IsParent = tm.IsParent;
|
||||
dc.IsExpanded = tm.IsExpanded;
|
||||
dc.ActivationType = tm.IsActive;
|
||||
|
||||
dc.Employee = tm.Employee != null ? MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(tm.Employee) : null;
|
||||
|
||||
if (tm.Parent != null)
|
||||
{
|
||||
// Endlosschleifen vermeiden: Parent eines Bausteins darf nicht gleichzeitig Kind des gleichen Bausteins sein
|
||||
if (!parentChildDict.ContainsKey(tm.Parent.Oid.Value))
|
||||
{
|
||||
parentChildDict.Add(tm.Parent.Oid.Value, new List<long>());
|
||||
}
|
||||
parentChildDict[tm.Parent.Oid.Value].Add(tm.Oid.Value);
|
||||
|
||||
bool addParent = true;
|
||||
if (parentChildDict.ContainsKey(tm.Oid.Value))
|
||||
{
|
||||
var childOids = parentChildDict[tm.Oid.Value];
|
||||
|
||||
if (childOids.Contains(tm.Parent.Oid.Value))
|
||||
{
|
||||
addParent = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (addParent && tm.Parent.IsActive != BS.Shared.ActivationTypeId.Deleted)
|
||||
{
|
||||
dc.Parent = CreateAiPromptbausteinDC(tm.Parent, parentChildDict);
|
||||
}
|
||||
}
|
||||
|
||||
return dc;
|
||||
}
|
||||
|
||||
public override AiPromptbausteinDC MergeWithDC(AiPromptbaustein entity, AiPromptbausteinDC dataContract)
|
||||
{
|
||||
dataContract.Position = entity.Position;
|
||||
dataContract.Version = entity.Version.Value;
|
||||
dataContract.Oid = entity.Oid.Value;
|
||||
dataContract.Text = entity.Text;
|
||||
dataContract.Name = entity.Name;
|
||||
dataContract.IsOnlyForEmployee = entity.IsOnlyForEmployee;
|
||||
dataContract.ActivationType = entity.IsActive;
|
||||
|
||||
if (entity.Employee != null)
|
||||
dataContract.Employee = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(entity.Employee);
|
||||
|
||||
return dataContract;
|
||||
}
|
||||
|
||||
public override AiPromptbaustein MergeWithEntity(AiPromptbausteinDC dataContract, AiPromptbaustein entity)
|
||||
{
|
||||
ConcurrencyCheck(dataContract.Version, entity);
|
||||
|
||||
entity.Position = dataContract.Position;
|
||||
entity.Oid = dataContract.Oid;
|
||||
entity.Text = dataContract.Text;
|
||||
entity.Name = dataContract.Name;
|
||||
entity.IsOnlyForEmployee = dataContract.IsOnlyForEmployee;
|
||||
entity.IsActive = dataContract.ActivationType;
|
||||
|
||||
if (dataContract.Employee != null)
|
||||
{
|
||||
entity.Employee = DAOFactory.GenericDAO.LoadByID<Employee>(dataContract.Employee.EmployeeOid);
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
protected override bool AreDCAndEntityEqual(AiPromptbausteinDC dc, AiPromptbaustein entity)
|
||||
{
|
||||
return dc.Oid == entity.Oid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,6 +263,8 @@ namespace BeWo.Service.DCEntityMapper
|
||||
|
||||
private static TextbausteinDC_Textbaustein _TextbausteinDC_Textbaustein;
|
||||
|
||||
private static AiPromptbausteinDC_AiPromptbaustein _AiPromptbausteinDC_AiPromptbaustein;
|
||||
|
||||
private static BargeldtransaktionDC_Bargeldtransaktion _BargeldtransaktionDC_Bargeldtransaktion;
|
||||
|
||||
private static BargeldkassenDC_Bargeldkasse _bargeldkassenDCBargeldkasseDCBargeldkassenDCBargeldkasse;
|
||||
@@ -357,6 +359,9 @@ namespace BeWo.Service.DCEntityMapper
|
||||
public static TextbausteinDC_Textbaustein TextbausteinDC_Textbaustein =>
|
||||
_TextbausteinDC_Textbaustein ?? (_TextbausteinDC_Textbaustein = new TextbausteinDC_Textbaustein());
|
||||
|
||||
public static AiPromptbausteinDC_AiPromptbaustein AiPromptbausteinDC_AiPromptbaustein =>
|
||||
_AiPromptbausteinDC_AiPromptbaustein ?? (_AiPromptbausteinDC_AiPromptbaustein = new AiPromptbausteinDC_AiPromptbaustein());
|
||||
|
||||
public static DepotRhythmusDC_DepotRhythmus DepotRhythmusDC_DepotRhythmus =>
|
||||
_DepotRhythmusDC_DepotRhythmus ?? (_DepotRhythmusDC_DepotRhythmus = new DepotRhythmusDC_DepotRhythmus());
|
||||
|
||||
|
||||
@@ -340,6 +340,7 @@
|
||||
<Compile Include="DCEntityMapper\BudgetDC_Budget.cs" />
|
||||
<Compile Include="DCEntityMapper\QuittierungsCheckDC_QuittierungsCheck.cs" />
|
||||
<Compile Include="DCEntityMapper\RatingDC_Rating.cs" />
|
||||
<Compile Include="DCEntityMapper\AiPromptbausteinDC_AiPromptbaustein.cs" />
|
||||
<Compile Include="DCEntityMapper\TextbausteinDC_Textbaustein.cs" />
|
||||
<Compile Include="DCEntityMapper\TokenDC_Token.cs" />
|
||||
<Compile Include="DCEntityMapper\VertretungsListeDC_VertretungsListe.cs" />
|
||||
|
||||
@@ -555,7 +555,31 @@ namespace BeWo.Service.ServiceContracts
|
||||
[OperationContract]
|
||||
IList<TextModuleDC> GetTextModulesByServiceCategory(long pServiceCategoryOid);
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
IList<TextModuleDC> GetAllAiPromptbausteine();
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
IList<TextModuleDC> GetAiPromptbausteine(bool shouldShowAllAiPromptbausteine, long employeeOid, bool hasRightToSeeAllAiPromptbausteine, bool isInAdministrationView);
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
IList<TextModuleDC> GetAiPromptbausteineForSelectedSupportConcept(bool shouldShowAllAiPromptbausteine, long employeeOid, bool hasRightToSeeAllAiPromptbausteine, bool isInAdministrationView, long? cb2scOid);
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
IList<long> InsertNewAiPromptbausteine(IEnumerable<TextModuleDC> aiPromptbausteine);
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
void UpdateAiPromptbausteine(List<TextModuleDC> aiPrompotBausteine);
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
void DeleteAiPromptbausteine(Dictionary<long, long> oid2Version);
|
||||
|
||||
[FaultContract(typeof(BeWoFault))]
|
||||
[OperationContract]
|
||||
IList<ServiceRecordDC> FindServiceRecordsInSpan(long pCostBearer2SupportConceptOid, DateTimeSpan period);
|
||||
|
||||
|
||||
@@ -418,7 +418,7 @@ namespace BeWo.Service.ServiceImplementations
|
||||
.Select(i => GenerateInitialSettlementDCForPeriod(i.CostBearerOids2CostBearerRelOids[pCostBearer], periodStart, periodEnd))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
public Settlement2DC GenerateDifferenzSettlementDC(long pCostBearer2SupportConceptOid)
|
||||
{
|
||||
try
|
||||
@@ -3524,6 +3524,122 @@ namespace BeWo.Service.ServiceImplementations
|
||||
modulesToDelete.Add(textModule);
|
||||
}
|
||||
|
||||
public IList<TextModuleDC> GetAllAiPromptbausteine()
|
||||
{
|
||||
try
|
||||
{
|
||||
var allAiPromptbausteine = DAOFactory.GenericDAO.GetAll<AiPromptbaustein>();
|
||||
|
||||
return null; // MapperFactory.AiPromptbausteinDC_AiPromptbaustein.CreateDcList(allAiPromptbausteine);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Utils.CreateBeWoFaultException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public IList<AiPromptbausteinDC> GetAiPromptbausteineForSelectedSupportConcept(bool shouldShowAllAiPromptbausteine, long employeeOid, bool hasRightToSeeAllAiPromptbausteine, bool isInAdministrationView, long? cb2scOid)
|
||||
{
|
||||
try
|
||||
{
|
||||
var s = PluginLoader.FindClass<OperationService>();
|
||||
|
||||
return null; // s.GetAiPromptbausteineForSelectedSupportConcept(shouldShowAllAiPromptbausteine, employeeOid, hasRightToSeeAllAiPromptbausteine, isInAdministrationView, cb2scOid);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Utils.CreateBeWoFaultException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IList<AiPromptbausteinDC> GetAiPromptbausteine(bool shouldShowAllAiPromptbausteine, long employeeOid, bool hasRightToSeeAllAiPromptbausteine, bool isInAdministrationView)
|
||||
{
|
||||
try
|
||||
{
|
||||
var s = PluginLoader.FindClass<OperationService>();
|
||||
|
||||
return null; // s.GetAiPromptbausteine(shouldShowAllAiPromptbausteine, employeeOid, hasRightToSeeAllAiPromptbausteine, isInAdministrationView);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Utils.CreateBeWoFaultException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public IList<long> InsertNewAiPromptbausteine(IEnumerable<AiPromptbausteinDC> aiPromptbausteinDCs)
|
||||
{
|
||||
try
|
||||
{
|
||||
var aiPromptbausteine = MapperFactory.AiPromptbausteinDC_AiPromptbaustein.MapToNewEntities(aiPromptbausteinDCs);
|
||||
|
||||
foreach (var tm in aiPromptbausteine)
|
||||
{
|
||||
tm.IsActive = ActivationTypeId.Active;
|
||||
}
|
||||
DAOFactory.GenericDAO.Insert(aiPromptbausteine);
|
||||
|
||||
return aiPromptbausteine.Select(asb => asb.Oid.Value).ToList();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Utils.CreateBeWoFaultException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAiPromptbausteine(List<AiPromptbausteinDC> pTextbausteine)
|
||||
{
|
||||
try
|
||||
{
|
||||
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<AiPromptbaustein>(pTextbausteine.Select(sc => sc.Oid.Value));
|
||||
foreach (var item in pTextbausteine)
|
||||
{
|
||||
item.ActivationType = ActivationTypeId.Active;
|
||||
}
|
||||
MapperFactory.AiPromptbausteinDC_AiPromptbaustein.MergeWithEntitys(pTextbausteine, lOriginals);
|
||||
|
||||
DAOFactory.GenericDAO.Update(lOriginals);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Utils.CreateBeWoFaultException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteAiPromptbausteine(Dictionary<long, long> pOid2Version)
|
||||
{
|
||||
try
|
||||
{
|
||||
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<AiPromptbaustein>(pOid2Version.Select(e => e.Key));
|
||||
lOriginals.DoForEach(or => MapperFactory.AiPromptbausteinDC_AiPromptbaustein.ConcurrencyCheck(pOid2Version[or.Oid.Value], or));
|
||||
|
||||
IList<AiPromptbaustein> modulesToDelete = new List<AiPromptbaustein>();
|
||||
|
||||
foreach (var aiPromptbaustein in lOriginals)
|
||||
{
|
||||
AddAiPromptbausteinAndChildsToList(aiPromptbaustein, modulesToDelete);
|
||||
}
|
||||
|
||||
DAOFactory.GenericDAO.Delete(modulesToDelete);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Utils.CreateBeWoFaultException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddAiPromptbausteinAndChildsToList(AiPromptbaustein aiPromptbaustein, IList<AiPromptbaustein> aiPromptbausteineToDelete)
|
||||
{
|
||||
var children = DAOFactory.SearchDAO.GetChildAiPromptbausteine(aiPromptbaustein);
|
||||
|
||||
foreach (var child in children)
|
||||
{
|
||||
AddAiPromptbausteinAndChildsToList(child, aiPromptbausteineToDelete);
|
||||
}
|
||||
|
||||
aiPromptbausteineToDelete.Add(aiPromptbaustein);
|
||||
}
|
||||
|
||||
public IList<ServiceRecordDC> FindServiceRecordsInSpan(long pCostBearer2SupportConceptOid, DateTimeSpan period)
|
||||
{
|
||||
try
|
||||
@@ -9030,5 +9146,25 @@ namespace BeWo.Service.ServiceImplementations
|
||||
throw Utils.CreateBeWoFaultException(e);
|
||||
}
|
||||
}
|
||||
|
||||
IList<TextModuleDC> IOperationsService.GetAiPromptbausteine(bool shouldShowAllAiPromptbausteine, long employeeOid, bool hasRightToSeeAllAiPromptbausteine, bool isInAdministrationView)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
IList<TextModuleDC> IOperationsService.GetAiPromptbausteineForSelectedSupportConcept(bool shouldShowAllAiPromptbausteine, long employeeOid, bool hasRightToSeeAllAiPromptbausteine, bool isInAdministrationView, long? cb2scOid)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
IList<long> IOperationsService.InsertNewAiPromptbausteine(IEnumerable<TextModuleDC> aiPromptbausteine)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void IOperationsService.UpdateAiPromptbausteine(List<TextModuleDC> aiPrompotBausteine)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +189,8 @@ namespace BS.Shared
|
||||
AiModel = 179,
|
||||
AiConversationMessage = 180,
|
||||
AiContext2BeWoObject = 181,
|
||||
AiConfig = 182
|
||||
AiConfig = 182,
|
||||
AiPromptbaustein = 183
|
||||
}
|
||||
|
||||
public enum SystemEntryID
|
||||
|
||||
43
Shared/DataContracts/AiPromptbausteinDC.cs
Normal file
43
Shared/DataContracts/AiPromptbausteinDC.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
|
||||
namespace BS.Shared.DataContracts
|
||||
{
|
||||
[DataContract]
|
||||
public partial class AiPromptbausteinDC : IDataContract
|
||||
{
|
||||
[DataMember]
|
||||
public ActivationTypeId ActivationType { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public long? Oid { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public long? Version { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string Text { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public int Position { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public CompactEmployeeDC Employee { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public bool IsOnlyForEmployee { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public bool IsParent { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public AiPromptbausteinDC Parent { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public bool IsExpanded { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -321,6 +321,7 @@
|
||||
<Compile Include="DataContracts\CustomerTokenRelationDC.cs" />
|
||||
<Compile Include="DataContracts\EmployeeTokenRelationDC.cs" />
|
||||
<Compile Include="DataContracts\ChatBewoMessageSyncDC.cs" />
|
||||
<Compile Include="DataContracts\AiPromptbausteinDC.cs" />
|
||||
<Compile Include="DataContracts\VertreterSucheFilterDC.cs" />
|
||||
<Compile Include="DataContracts\SbdConfigDC.cs" />
|
||||
<Compile Include="DataContracts\QuittierungsCheckDC.cs" />
|
||||
|
||||
Reference in New Issue
Block a user