diff --git a/.gitignore b/.gitignore index 7181900fb..58942535c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ .editorconfig DebugConfig.txt Host/Multitenancy/demo.config +*.log.txt +*temp.txt # Folder bin[Rr]elease/ 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/AI/View/AiChatView.xaml b/BeWo/AI/View/AiChatView.xaml index be279766b..f58bfce2b 100644 --- a/BeWo/AI/View/AiChatView.xaml +++ b/BeWo/AI/View/AiChatView.xaml @@ -1,18 +1,23 @@ - + - + - - + + - - - + + + - + + WICHTIG! Bitte tragen Sie keine echten Daten bei Ihren Tests ein, da es sich um einen öffentlichen Testzugang handelt, auf den jeder Zugriff hat! + + - - + + - - - + + + diff --git a/BeWo/Converter/NewlineConverter.cs b/BeWo/Converter/NewlineConverter.cs new file mode 100644 index 000000000..03f0e7b65 --- /dev/null +++ b/BeWo/Converter/NewlineConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace BeWo.Converter +{ + public class NewlineConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value?.ToString()? + .Replace("\\r\\n", "\r\n") + .Replace("\\n", "\r\n") + .Replace("\\r", "\r\n"); + } + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BeWo/Core/Config/AppSettings.cs b/BeWo/Core/Config/AppSettings.cs index cbe897495..a76a67672 100644 --- a/BeWo/Core/Config/AppSettings.cs +++ b/BeWo/Core/Config/AppSettings.cs @@ -485,6 +485,9 @@ namespace BeWo.Core.Config public bool ShowAIInternal { get; set; } public bool AllowGkvAbrechnung { get; set; } + + public bool ModuleAiEnabled { get; set; } + public bool ShowWohnhilfe { get; set; } public bool ShowImportAbschlagszahlungen { get; set; } diff --git a/BeWo/DebugConfig.cs b/BeWo/DebugConfig.cs index e64ec478c..ad6d26b7f 100644 --- a/BeWo/DebugConfig.cs +++ b/BeWo/DebugConfig.cs @@ -10,7 +10,8 @@ namespace BeWo FeatureCustomerWohnhilfe, FeatureWohnheimWohneinheit, FeatureAuswertungenQuittierungsbelege, - FeatureDakota + FeatureDakota, + FeatureAiModule } public class DebugConfig @@ -47,8 +48,8 @@ namespace BeWo /// - Wohnhilfe: 5 /// public int? SelectIndex { get; set; } - public bool EnableAutoRemoteDebugging { get; set; } + public bool EnableAllUserRightsInDebug { get; set; } = false; public static DebugConfig SimpleAutoLogin => new DebugConfig() { @@ -139,6 +140,19 @@ namespace BeWo EnableAutoRemoteDebugging = true }); + name2config.Add("FeatureAiModule", + new DebugConfig() + { + DebugConfigMode = DebugConfigMode.FeatureAiModule, + AutoLogin = true, + //SelectView = UIContext.AiConversation, + //SelectIndex = 8, + //DefaultLoginUsername = "m1", + //DefaultLoginPassword = "bewobewo", + //DefaultProfilename = "5000000000", + EnableAutoRemoteDebugging = true + }); + return name2config; } #endif diff --git a/BeWo/EnterTenantDialog.xaml b/BeWo/EnterTenantDialog.xaml index acc081ec9..5d01dc0cf 100644 --- a/BeWo/EnterTenantDialog.xaml +++ b/BeWo/EnterTenantDialog.xaml @@ -1,10 +1,18 @@ - - - - + + + + @@ -17,7 +25,13 @@ - + @@ -25,24 +39,70 @@ - - - - + + + + - Bitte geben Sie Ihre 10-stellige Kundennummer ein: - - - - Demo Zugang nutzen + + Bitte geben Sie Ihre 10-stellige Kundennummer ein: + + + + + + Demo Zugang nutzen + - - + + - - - + + + diff --git a/BeWo/LockedPage.xaml b/BeWo/LockedPage.xaml index 5927ff440..ad233da53 100644 --- a/BeWo/LockedPage.xaml +++ b/BeWo/LockedPage.xaml @@ -1,14 +1,22 @@ - + - + @@ -21,7 +29,14 @@ - + @@ -30,7 +45,12 @@ - + @@ -44,31 +64,142 @@ - - - + - - - - + + + + + + - - - - + + + - + - + @@ -430,37 +669,75 @@ - - - - - - - + + + + + + + - + - + - + @@ -476,49 +753,132 @@ - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + @@ -530,115 +890,243 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - + + + - + @@ -647,8 +1135,12 @@ - + @@ -673,10 +1165,10 @@ - - + + - + @@ -694,101 +1186,241 @@ - - + - - + + @@ -1476,27 +2866,59 @@ - - - - + + + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + diff --git a/BeWo/View/MiniChatView.xaml b/BeWo/View/MiniChatView.xaml index f15b2e9e0..92fa883df 100644 --- a/BeWo/View/MiniChatView.xaml +++ b/BeWo/View/MiniChatView.xaml @@ -1,14 +1,31 @@ - + - + - + diff --git a/BeWo/View/Navigation/CustomerNavigationView.xaml b/BeWo/View/Navigation/CustomerNavigationView.xaml index 3b10699fa..c57cf6fc9 100644 --- a/BeWo/View/Navigation/CustomerNavigationView.xaml +++ b/BeWo/View/Navigation/CustomerNavigationView.xaml @@ -1,12 +1,14 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/BeWo/View/Navigation/CustomerNavigationView.xaml.cs b/BeWo/View/Navigation/CustomerNavigationView.xaml.cs index 41460ddb0..75558e8df 100644 --- a/BeWo/View/Navigation/CustomerNavigationView.xaml.cs +++ b/BeWo/View/Navigation/CustomerNavigationView.xaml.cs @@ -25,482 +25,535 @@ 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; +using System.Windows.Input; namespace BeWo.View.Navigation { - /// - /// Interaktionslogik für CustomerNavigationView.xaml - /// - public partial class CustomerNavigationView - { - //private readonly CheckBox chkShowOnlyMyCustomers; - //private readonly CheckBox chkShowOnlyTeamCustomers; - private readonly ComboBox supportConceptFilterComboBox; + /// + /// Interaktionslogik für CustomerNavigationView.xaml + /// + public partial class CustomerNavigationView + { + //private readonly CheckBox chkShowOnlyMyCustomers; + //private readonly CheckBox chkShowOnlyTeamCustomers; + private readonly ComboBox supportConceptFilterComboBox; - private IEnumerable objectList; - private IEnumerable recentList; + private IEnumerable objectList; + private IEnumerable recentList; - public CustomerNavigationView() - { - InitializeComponent(); + public CustomerNavigationView() + { + InitializeComponent(); - mainNavigationView.Sorter = new CustomerSorter(); - mainNavigationView.ArchiveButtonVisible = BeWoApp.LoggedOnUser.HasRight(UserRightType.Customer_AllowArchiving); - mainNavigationView.ShowArchivedObjectsVisible = true; + mainNavigationView.OpenAiWindowCommand = new DelegateCommand(OpenAiWindow, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView)); + mainNavigationView.OpenAiPopupCommand = new DelegateCommand(OpenAiPopup, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView2)); + + mainNavigationView.Sorter = new CustomerSorter(); + mainNavigationView.ArchiveButtonVisible = BeWoApp.LoggedOnUser.HasRight(UserRightType.Customer_AllowArchiving); + mainNavigationView.ShowArchivedObjectsVisible = true; - supportConceptFilterComboBox = new ComboBox(); - //supportConceptFilterComboBox.HorizontalAlignment = "Left"; - //supportConceptFilterComboBox.FontFamily = "Microsoft Sans Serif"; + supportConceptFilterComboBox = new ComboBox(); + //supportConceptFilterComboBox.HorizontalAlignment = "Left"; + //supportConceptFilterComboBox.FontFamily = "Microsoft Sans Serif"; - //supportConceptFilterComboBox.Foreground = new SolidColorBrush(Color.FromRgb(210, 210, 210)); - supportConceptFilterComboBox.FontSize = 12; - supportConceptFilterComboBox.Margin = new Thickness(10, 0, 0, 0); - supportConceptFilterComboBox.MinWidth = 100; - //supportConceptFilterComboBox.DisplayMemberPath = "DisplayName"; - //supportConceptFilterComboBox.SelectionChanged = "sortCombo_SelectionChanged"; - supportConceptFilterComboBox.Style = FindResource("SortComboBox") as Style; + //supportConceptFilterComboBox.Foreground = new SolidColorBrush(Color.FromRgb(210, 210, 210)); + supportConceptFilterComboBox.FontSize = 12; + supportConceptFilterComboBox.Margin = new Thickness(10, 0, 0, 0); + supportConceptFilterComboBox.MinWidth = 100; + //supportConceptFilterComboBox.DisplayMemberPath = "DisplayName"; + //supportConceptFilterComboBox.SelectionChanged = "sortCombo_SelectionChanged"; + supportConceptFilterComboBox.Style = FindResource("SortComboBox") as Style; - if (BeWoApp.AppSettings.ShowAIInternal) - { - mainNavigationView.btnOpenAi.Visibility = Visibility.Visible; - } + if (BeWoApp.AppSettings.ShowAIInternal) + { + mainNavigationView.btnOpenAi.Visibility = Visibility.Visible; + } - if (BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) || BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll)) - { - supportConceptFilterComboBox.Items.Add(new CustomerFilterItem(CustomerFilterEnum.All)); - } - - if(BeWoApp.LoggedOnUser.HasRight(UserRightType.Customer_ViewMyTeams)) - { - supportConceptFilterComboBox.Items.Add(new CustomerFilterItem(CustomerFilterEnum.TeamCustomer)); - } - supportConceptFilterComboBox.Items.Add(new CustomerFilterItem(CustomerFilterEnum.MyCustomer)); + if (BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) || BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll)) + { + supportConceptFilterComboBox.Items.Add(new CustomerFilterItem(CustomerFilterEnum.All)); + } - CustomerFilterItem selectedItem = null; + if (BeWoApp.LoggedOnUser.HasRight(UserRightType.Customer_ViewMyTeams)) + { + supportConceptFilterComboBox.Items.Add(new CustomerFilterItem(CustomerFilterEnum.TeamCustomer)); + } + supportConceptFilterComboBox.Items.Add(new CustomerFilterItem(CustomerFilterEnum.MyCustomer)); - switch(BeWoApp.AppSettings.CustomerFilterSupportConcepts) - { - case CustomerFilterEnum.All: - if(BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) || BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll)) - { - selectedItem = new CustomerFilterItem(CustomerFilterEnum.All); - } - - break; - case CustomerFilterEnum.TeamCustomer: - if(BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) || - BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll) || - BeWoApp.LoggedOnUser.HasRight(UserRightType.Customer_ViewMyTeams)) - { - selectedItem = new CustomerFilterItem(CustomerFilterEnum.TeamCustomer); - } - - break; - } - - if(selectedItem == null) - { - selectedItem = new CustomerFilterItem(CustomerFilterEnum.MyCustomer); - } - - supportConceptFilterComboBox.SelectedItem = selectedItem; - supportConceptFilterComboBox.SelectionChanged += SupportConceptFilterComboBoxOnSelectionChanged; + CustomerFilterItem selectedItem = null; - //chkShowOnlyMyCustomers = new CheckBox - // { - // FontSize = 12, - // Margin = new Thickness(10, 0, 0, 0), - // Content = Translator.Translate("Meine Klienten"), - // VerticalAlignment = VerticalAlignment.Center - // }; - //chkShowOnlyTeamCustomers = new CheckBox - //{ - // FontSize = 12, - // Margin = new Thickness(10, 0, 0, 0), - // Content = Translator.Translate("Klienten meines Teams"), - // VerticalAlignment = VerticalAlignment.Center - //}; + switch (BeWoApp.AppSettings.CustomerFilterSupportConcepts) + { + case CustomerFilterEnum.All: + if (BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) || BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll)) + { + selectedItem = new CustomerFilterItem(CustomerFilterEnum.All); + } - //var b = FindResource("MainGroupBoxForegroundBrush") as Brush; - //if (b != null) - //{ - // chkShowOnlyMyCustomers.Foreground = b; - // chkShowOnlyTeamCustomers.Foreground = b; - //} + break; + case CustomerFilterEnum.TeamCustomer: + if (BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) || + BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll) || + BeWoApp.LoggedOnUser.HasRight(UserRightType.Customer_ViewMyTeams)) + { + selectedItem = new CustomerFilterItem(CustomerFilterEnum.TeamCustomer); + } - //if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) && - // !BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll)) - //{ - // chkShowOnlyMyCustomers.IsChecked = true; - // chkShowOnlyMyCustomers.IsEnabled = false; - //} - //else - //{ - // chkShowOnlyMyCustomers.IsChecked = BeWoApp.AppSettings.ShowOnlyMyClients; - //} + break; + } - //if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) && - // !BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll)) - //{ - // chkShowOnlyTeamCustomers.IsChecked = true; - // chkShowOnlyTeamCustomers.IsEnabled = false; - //} - //else - //{ - // chkShowOnlyTeamCustomers.IsChecked = BeWoApp.AppSettings.ShowOnlyTeamClients; - //} + if (selectedItem == null) + { + selectedItem = new CustomerFilterItem(CustomerFilterEnum.MyCustomer); + } - //chkShowOnlyMyCustomers.Click += chkShowOnlyMyCustomers_Click; - //chkShowOnlyTeamCustomers.Click += chkShowOnlyMyCustomers_Click; + supportConceptFilterComboBox.SelectedItem = selectedItem; + supportConceptFilterComboBox.SelectionChanged += SupportConceptFilterComboBoxOnSelectionChanged; - //mainNavigationView.AddControlToSortPanel(chkShowOnlyMyCustomers); - //mainNavigationView.AddControlToSortPanel(chkShowOnlyTeamCustomers); - var lbl = new TextBlock - { - Text = "Filter:", - FontSize = 12, - Margin = new Thickness(8, 2, -3, 0) - }; + //chkShowOnlyMyCustomers = new CheckBox + // { + // FontSize = 12, + // Margin = new Thickness(10, 0, 0, 0), + // Content = Translator.Translate("Meine Klienten"), + // VerticalAlignment = VerticalAlignment.Center + // }; + //chkShowOnlyTeamCustomers = new CheckBox + //{ + // FontSize = 12, + // Margin = new Thickness(10, 0, 0, 0), + // Content = Translator.Translate("Klienten meines Teams"), + // VerticalAlignment = VerticalAlignment.Center + //}; - mainNavigationView.sortPanel.Children.Insert(3, lbl); - mainNavigationView.sortPanel.Children.Insert(4, supportConceptFilterComboBox); - - UpdateCustomFilter(); - } + //var b = FindResource("MainGroupBoxForegroundBrush") as Brush; + //if (b != null) + //{ + // chkShowOnlyMyCustomers.Foreground = b; + // chkShowOnlyTeamCustomers.Foreground = b; + //} - private void SupportConceptFilterComboBoxOnSelectionChanged(object o, SelectionChangedEventArgs selectionChangedEventArgs) - { - BeWoApp.AppSettings.CustomerFilterSupportConcepts = ((CustomerFilterItem) supportConceptFilterComboBox.SelectedItem)?.CustomerFilter ?? CustomerFilterEnum.MyCustomer; + //if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) && + // !BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll)) + //{ + // chkShowOnlyMyCustomers.IsChecked = true; + // chkShowOnlyMyCustomers.IsEnabled = false; + //} + //else + //{ + // chkShowOnlyMyCustomers.IsChecked = BeWoApp.AppSettings.ShowOnlyMyClients; + //} - BeWoApp.SaveAppSettings(); + //if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) && + // !BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll)) + //{ + // chkShowOnlyTeamCustomers.IsChecked = true; + // chkShowOnlyTeamCustomers.IsEnabled = false; + //} + //else + //{ + // chkShowOnlyTeamCustomers.IsChecked = BeWoApp.AppSettings.ShowOnlyTeamClients; + //} - UpdateCustomFilter(); - } + //chkShowOnlyMyCustomers.Click += chkShowOnlyMyCustomers_Click; + //chkShowOnlyTeamCustomers.Click += chkShowOnlyMyCustomers_Click; - private CustomFilter CreateNewCustomFilter() - { - var filter = new CustomerNavigationFilter {CustomerFilter = ((CustomerFilterItem) supportConceptFilterComboBox.SelectedItem)?.CustomerFilter ?? CustomerFilterEnum.MyCustomer}; + //mainNavigationView.AddControlToSortPanel(chkShowOnlyMyCustomers); + //mainNavigationView.AddControlToSortPanel(chkShowOnlyTeamCustomers); + var lbl = new TextBlock + { + Text = "Filter:", + FontSize = 12, + Margin = new Thickness(8, 2, -3, 0) + }; - return filter; - } + mainNavigationView.sortPanel.Children.Insert(3, lbl); + mainNavigationView.sortPanel.Children.Insert(4, supportConceptFilterComboBox); - private void OnLoaded(object sender, RoutedEventArgs e) - { - ServiceFacade.DoCustomerServiceAsync(s => s.ConvertToNewSubstitutionType(), n => this.Dispatch(delegate - { - ReloadData(false); - })); - } + UpdateCustomFilter(); + } - private void UpdateCustomFilter() - { - mainNavigationView.CustomFilter = CreateNewCustomFilter(); - } + public Dictionary GetVisibleInformationReferences() + { + var visible = mainNavigationView.objectListBox.ItemsSource; - private void ChkShowOnlyMyCustomers_Click(object sender, RoutedEventArgs e) - { - //if (chkShowOnlyMyCustomers.IsChecked != null) - // BeWoApp.AppSettings.ShowOnlyMyClients = chkShowOnlyMyCustomers.IsChecked.Value; - //if (chkShowOnlyTeamCustomers.IsChecked != null) - // BeWoApp.AppSettings.ShowOnlyTeamClients = chkShowOnlyTeamCustomers.IsChecked.Value; - BeWoApp.SaveAppSettings(); + return GetVisibleInformationReferences(visible); + } - UpdateCustomFilter(); - } + private Dictionary GetVisibleInformationReferences(IEnumerable visible_customers) + { + var oids = new List(); + foreach (var c in visible_customers) + { + var customer = c as CompactCustomerDC; + oids.Add(customer.CustomerOid); + } - private bool mainNavigationView_ArchiveObject(IFilterableDC obj) - { - var cdc = obj as CompactCustomerDC; - if (cdc != null) - { - if (MessageBox.Show(Translator.Translate("Wollen Sie den Klient '{0}' wirklich archivieren?", cdc.FirstName + " " + cdc.LastName), "Archivieren", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) - { - ServiceFacade.DoCustomerServiceAsync( - s => - { - s.ArchiveCustomer(cdc.CustomerOid, cdc.CustomerVersion); - return cdc; - }, - cb => cb.CustomerVersion++); + var dict = new Dictionary() { + { TableID.Customer, oids.ToArray()} + }; - Cache.GetInstance().ClearSupportConceptTree(); - return true; - } - } + return dict; + } - return false; - } + private void OpenAiWindow() + { + var context = GetVisibleInformationReferences(); - private void mainNavigationView_CreateNewObject() - { - VMFactory.CreateCustomerVMAsync(cb => this.Dispatch(() => MainControl.NavigateTo(new CustomerView(cb) {ParentView = this}))); - } + var window = BeWoWindowBuilder.AiWindowBuilder.GetAiConversationWindow(UIContext.Customer, context); - private bool mainNavigationView_DeleteObject(IFilterableDC obj) - { - var cdc = obj as CompactCustomerDC; - if (cdc != null) - { - if (MessageBox.Show(Translator.Translate("Wollen Sie den Klient '{0}' wirklich löschen?", cdc.FirstName + " " + cdc.LastName), "Löschen", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) - { + window?.ShowDialog(); + } - CustomerInfoDC details = ServiceFacade.DoOperationsServiceSync(s => s.GetCustomerInfosForCustomerOid(cdc.CustomerOid)); - bool delete = true; - if (details != null) - { - if (!string.IsNullOrEmpty(details.CurrentSupportConcept) && details.CurrentSupportConcept.ToLower() != Translator.Translate("Kein aktueller Hilfeplan").ToLower()) - { - if (MessageBox.Show(Translator.Translate("Für Klient '{0}' wurde bereits ein Hilfeplan angelegt. Der Hilfeplan wird dadurch auch gelöscht!\n Möchten Sie wirklich fortfahren und den Klient löschen?", cdc.FirstName + " " + cdc.LastName), "Löschen", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.No) - { - delete = false; - } - } - - } - if (delete) - { - - ServiceFacade.DoCustomerServiceAsync( - s => - { - s.DeactivateCustomer(cdc.CustomerOid, cdc.CustomerVersion); - return cdc; - }, cb => cb.CustomerVersion++); + private void OpenAiPopup() + { + var context = GetVisibleInformationReferences(); - Cache.GetInstance().ClearSupportConceptTree(); - return true; - - } - } - } + var control = BeWoWindowBuilder.AiWindowBuilder.GetAiConversationControl(UIContext.Customer, context); - return false; - } + if (control is object) + MainControl.ShowControlAsModalPopup(control); + } - private void mainNavigationView_ExcelExport(object sender, EventArgs> e) - { + private void SupportConceptFilterComboBoxOnSelectionChanged(object o, SelectionChangedEventArgs selectionChangedEventArgs) + { + BeWoApp.AppSettings.CustomerFilterSupportConcepts = ((CustomerFilterItem)supportConceptFilterComboBox.SelectedItem)?.CustomerFilter ?? CustomerFilterEnum.MyCustomer; + + BeWoApp.SaveAppSettings(); + + UpdateCustomFilter(); + } + + private CustomFilter CreateNewCustomFilter() + { + var filter = new CustomerNavigationFilter { CustomerFilter = ((CustomerFilterItem)supportConceptFilterComboBox.SelectedItem)?.CustomerFilter ?? CustomerFilterEnum.MyCustomer }; + + return filter; + } + + private void OnLoaded(object sender, RoutedEventArgs e) + { + ServiceFacade.DoCustomerServiceAsync(s => s.ConvertToNewSubstitutionType(), n => this.Dispatch(delegate + { + ReloadData(false); + })); + + CommandManager.InvalidateRequerySuggested(); + } + + private void UpdateCustomFilter() + { + mainNavigationView.CustomFilter = CreateNewCustomFilter(); + } + + private void ChkShowOnlyMyCustomers_Click(object sender, RoutedEventArgs e) + { + //if (chkShowOnlyMyCustomers.IsChecked != null) + // BeWoApp.AppSettings.ShowOnlyMyClients = chkShowOnlyMyCustomers.IsChecked.Value; + //if (chkShowOnlyTeamCustomers.IsChecked != null) + // BeWoApp.AppSettings.ShowOnlyTeamClients = chkShowOnlyTeamCustomers.IsChecked.Value; + BeWoApp.SaveAppSettings(); + + UpdateCustomFilter(); + } + + private bool mainNavigationView_ArchiveObject(IFilterableDC obj) + { + var cdc = obj as CompactCustomerDC; + if (cdc != null) + { + if (MessageBox.Show(Translator.Translate("Wollen Sie den Klient '{0}' wirklich archivieren?", cdc.FirstName + " " + cdc.LastName), "Archivieren", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) + { + ServiceFacade.DoCustomerServiceAsync( + s => + { + s.ArchiveCustomer(cdc.CustomerOid, cdc.CustomerVersion); + return cdc; + }, + cb => cb.CustomerVersion++); + + Cache.GetInstance().ClearSupportConceptTree(); + return true; + } + } + + return false; + } + + private void mainNavigationView_CreateNewObject() + { + VMFactory.CreateCustomerVMAsync(cb => this.Dispatch(() => MainControl.NavigateTo(new CustomerView(cb) { ParentView = this }))); + } + + private bool mainNavigationView_DeleteObject(IFilterableDC obj) + { + var cdc = obj as CompactCustomerDC; + if (cdc != null) + { + if (MessageBox.Show(Translator.Translate("Wollen Sie den Klient '{0}' wirklich löschen?", cdc.FirstName + " " + cdc.LastName), "Löschen", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) + { + + CustomerInfoDC details = ServiceFacade.DoOperationsServiceSync(s => s.GetCustomerInfosForCustomerOid(cdc.CustomerOid)); + bool delete = true; + if (details != null) + { + if (!string.IsNullOrEmpty(details.CurrentSupportConcept) && details.CurrentSupportConcept.ToLower() != Translator.Translate("Kein aktueller Hilfeplan").ToLower()) + { + if (MessageBox.Show(Translator.Translate("Für Klient '{0}' wurde bereits ein Hilfeplan angelegt. Der Hilfeplan wird dadurch auch gelöscht!\n Möchten Sie wirklich fortfahren und den Klient löschen?", cdc.FirstName + " " + cdc.LastName), "Löschen", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.No) + { + delete = false; + } + } + + } + if (delete) + { + + ServiceFacade.DoCustomerServiceAsync( + s => + { + s.DeactivateCustomer(cdc.CustomerOid, cdc.CustomerVersion); + return cdc; + }, cb => cb.CustomerVersion++); + + Cache.GetInstance().ClearSupportConceptTree(); + return true; + + } + } + } + + return false; + } + + private void mainNavigationView_ExcelExport(object sender, EventArgs> e) + { var path = BeWoApp.GetAndCreateUserAppDataPath() + Translator.Translate("\\Klienten.xls"); - var sf = new SaveFileDialog { FileName = Path.GetFileName(path), Filter = "Microsoft Excel 97-2003-Arbeitsblatt|*.xls|Alle Dateien|*.*" }; - if (sf.ShowDialog() != true) - return; + var sf = new SaveFileDialog { FileName = Path.GetFileName(path), Filter = "Microsoft Excel 97-2003-Arbeitsblatt|*.xls|Alle Dateien|*.*" }; + if (sf.ShowDialog() != true) + return; - ServiceFacade.DoDownloadServiceSync(s => BeWoUtils.WriteExcelFile(s.PrepareExcelFileCustomerExport(mainNavigationView.DownloadLinkEngine.ExcelFileId, e.Data.Cast().Select(c => c.CustomerOid).ToList()), sf.FileName)); - } + ServiceFacade.DoDownloadServiceSync(s => BeWoUtils.WriteExcelFile(s.PrepareExcelFileCustomerExport(mainNavigationView.DownloadLinkEngine.ExcelFileId, e.Data.Cast().Select(c => c.CustomerOid).ToList()), sf.FileName)); + } - private void mainNavigationView_OpenObject(IFilterableDC obj) - { - var cdc = obj as CompactCustomerDC; - if (cdc != null) - { - VMFactory.CreateCustomerVMAsync(cdc.CustomerOid, cb => this.Dispatch(() => MainControl.NavigateTo(new CustomerView(cb) {ParentView = this}))); - } - } - - public override void ChildViewClosed() - { - recentList = null; - objectList = null; - } - private void MainNavigationView_OnReloadData() - { - ReloadData(true); - } - - private void ReloadData(bool refresh) + private void mainNavigationView_OpenObject(IFilterableDC obj) { - if (refresh || recentList == null) - { - ServiceFacade.DoCustomerServiceAsync( + var cdc = obj as CompactCustomerDC; + if (cdc != null) + { + VMFactory.CreateCustomerVMAsync(cdc.CustomerOid, cb => this.Dispatch(() => MainControl.NavigateTo(new CustomerView(cb) { ParentView = this }))); + } + } + + public override void ChildViewClosed() + { + recentList = null; + objectList = null; + } + private void MainNavigationView_OnReloadData() + { + ReloadData(true); + } + + private void ReloadData(bool refresh) + { + if (refresh || recentList == null) + { + ServiceFacade.DoCustomerServiceAsync( s => s.GetAllCustomersCompact(BeWoApp.LoggedOnUser.Employee.EmployeeOid), - r => this.Dispatch(delegate - { - objectList = r; - - mainNavigationView.ShowSearchResult(objectList); - })); + r => this.Dispatch(delegate + { + objectList = r; - ServiceFacade.DoCustomerServiceAsync(s => s.GetLastOpenedCustomers(), - r => - this.Dispatch(delegate - { - if(BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) || BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll)) - { - recentList = r; - } - else if(BeWoApp.LoggedOnUser.HasRight(UserRightType.Customer_ViewMyCustomers)) - { - recentList = r.Where(w => BeWoApp.LoggedOnEmployee.RelatedCustomers.Select(s3 => s3.Customer.CustomerOid).Contains(w.CustomerOid)); - } - else - { - recentList = new List(); - } + mainNavigationView.ShowSearchResult(objectList); + })); - mainNavigationView.ShowHistory(recentList); + ServiceFacade.DoCustomerServiceAsync(s => s.GetLastOpenedCustomers(), + r => + this.Dispatch(delegate + { + if (BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) || BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll)) + { + recentList = r; + } + else if (BeWoApp.LoggedOnUser.HasRight(UserRightType.Customer_ViewMyCustomers)) + { + recentList = r.Where(w => BeWoApp.LoggedOnEmployee.RelatedCustomers.Select(s3 => s3.Customer.CustomerOid).Contains(w.CustomerOid)); + } + else + { + recentList = new List(); + } + + mainNavigationView.ShowHistory(recentList); #if DEBUG - if(DebugConfig.CurrentConfig is object && DebugConfig.CurrentConfig.DebugConfigMode == DebugConfigMode.FeatureCustomerWohnhilfe) - { - mainNavigationView_OpenObject(recentList.FirstOrDefault() ?? objectList.FirstOrDefault()); - } + if (DebugConfig.CurrentConfig is object && DebugConfig.CurrentConfig.DebugConfigMode == DebugConfigMode.FeatureCustomerWohnhilfe) + { + mainNavigationView_OpenObject(recentList.FirstOrDefault() ?? objectList.FirstOrDefault()); + } #endif - }) - ); - } - else - { - mainNavigationView.ShowSearchResult(objectList); - mainNavigationView.ShowHistory(recentList); - } - } + }) + ); + } + else + { + mainNavigationView.ShowSearchResult(objectList); + mainNavigationView.ShowHistory(recentList); + } + } - private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e) - { - //var alleVorlagen = ServiceFacade.DoOperationsServiceSync(s => s.Getvor()); + private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e) + { + //var alleVorlagen = ServiceFacade.DoOperationsServiceSync(s => s.Getvor()); - var alleVorlagen = ServiceFacade.DoOperationsServiceSync(s => s.GetDokumentvorlagenForType(TableID.Customer)); - if (alleVorlagen.Count > 0) - { - var c = (CompactCustomerDC)((Hyperlink)sender).Tag; + var alleVorlagen = ServiceFacade.DoOperationsServiceSync(s => s.GetDokumentvorlagenForType(TableID.Customer)); + if (alleVorlagen.Count > 0) + { + var c = (CompactCustomerDC)((Hyperlink)sender).Tag; - DokumentViewHelper.OpenTemplateSelectionDialog(alleVorlagen, TableID.Customer, c.CustomerOid); - } - else - { - BeWoUtils.NavigateToReportUri(((Hyperlink)sender).NavigateUri.ToString(), "Druckvorschau"); - } - //var folderDCs = VMFactory.CreateFolderList(TableID.Vorlagentabelle, (long)vm.DocTreeItemOid); + DokumentViewHelper.OpenTemplateSelectionDialog(alleVorlagen, TableID.Customer, c.CustomerOid); + } + else + { + BeWoUtils.NavigateToReportUri(((Hyperlink)sender).NavigateUri.ToString(), "Druckvorschau"); + } + //var folderDCs = VMFactory.CreateFolderList(TableID.Vorlagentabelle, (long)vm.DocTreeItemOid); - - } - + } - private void MainNavigationView_OnOpenMailMergeWindow(List allCustomers, IFilterableDC selectedCustomer) - { - var mmw = new MailMergeWindow(this, typeof(CustomerDC), objectList.ToList(), selectedCustomer) { Sorter = new CustomerSorter() }; - - mmw.Show(); - } - private void Hyperlink_Reaktivieren_Click(object sender, RoutedEventArgs e) - { - var customer = (CompactCustomerDC) ((Hyperlink)sender).Tag; - if (MessageBox.Show(Translator.Translate("Wollen Sie den Klient '{0}' wirklich reaktivieren?", customer.FirstName + " " + customer.LastName), "Reaktivieren", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.No) - { - return; - } + private void MainNavigationView_OnOpenMailMergeWindow(List allCustomers, IFilterableDC selectedCustomer) + { + var mmw = new MailMergeWindow(this, typeof(CustomerDC), objectList.ToList(), selectedCustomer) { Sorter = new CustomerSorter() }; - ServiceFacade.DoCustomerServiceAsync(s => - { + mmw.Show(); + } + + private void Hyperlink_Reaktivieren_Click(object sender, RoutedEventArgs e) + { + var customer = (CompactCustomerDC)((Hyperlink)sender).Tag; + + if (MessageBox.Show(Translator.Translate("Wollen Sie den Klient '{0}' wirklich reaktivieren?", customer.FirstName + " " + customer.LastName), "Reaktivieren", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.No) + { + return; + } + + ServiceFacade.DoCustomerServiceAsync(s => + { s.ReactivateCustomer(customer.CustomerOid, customer.CustomerVersion); - return customer; - }, cb => cb.CustomerVersion++); + return customer; + }, cb => cb.CustomerVersion++); Cache.GetInstance().ClearSupportConceptTree(); - customer.ActivationType = ActivationTypeId.Active; + customer.ActivationType = ActivationTypeId.Active; var context = mainNavigationView.objectListBox.DataContext; mainNavigationView.objectListBox.DataContext = null; mainNavigationView.objectListBox.DataContext = context; - } - - private void Hyperlink_AusArchivHolen_Click(object sender, RoutedEventArgs e) - { - var customer = (CompactCustomerDC) ((Hyperlink)sender).Tag; + } - if (MessageBox.Show(Translator.Translate("Wollen Sie den Klient '{0}' wirklich aus dem Archiv holen?", customer.FirstName + " " + customer.LastName), "Reaktivieren", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.No) - { - return; - } + private void Hyperlink_AusArchivHolen_Click(object sender, RoutedEventArgs e) + { + var customer = (CompactCustomerDC)((Hyperlink)sender).Tag; - ServiceFacade.DoCustomerServiceAsync(s => - { + if (MessageBox.Show(Translator.Translate("Wollen Sie den Klient '{0}' wirklich aus dem Archiv holen?", customer.FirstName + " " + customer.LastName), "Reaktivieren", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.No) + { + return; + } + + ServiceFacade.DoCustomerServiceAsync(s => + { s.ReactivateCustomer(customer.CustomerOid, customer.CustomerVersion); - return customer; - }, cb => cb.CustomerVersion++); + return customer; + }, cb => cb.CustomerVersion++); Cache.GetInstance().ClearSupportConceptTree(); - customer.ActivationType = ActivationTypeId.Active; + customer.ActivationType = ActivationTypeId.Active; var context = mainNavigationView.objectListBox.DataContext; mainNavigationView.objectListBox.DataContext = null; mainNavigationView.objectListBox.DataContext = context; - } + } - private void Hyperlink_Anonymize_Click(object sender, RoutedEventArgs e) - { - var customer = (CompactCustomerDC) ((Hyperlink) sender).Tag; + private void Hyperlink_Anonymize_Click(object sender, RoutedEventArgs e) + { + var customer = (CompactCustomerDC)((Hyperlink)sender).Tag; - var dialog = new MessageDialog(() => - { - this.Dispatch(() => - { - ServiceFacade.DoOperationsServiceAsync(s => - { - s.AnonymizeCustomer(customer.CustomerOid); - }, () => - { - ReloadData(true); - }); - }); - }); + var dialog = new MessageDialog(() => + { + this.Dispatch(() => + { + ServiceFacade.DoOperationsServiceAsync(s => + { + s.AnonymizeCustomer(customer.CustomerOid); + }, () => + { + ReloadData(true); + }); + }); + }); - ServiceFacade.DoOperationsServiceAsync(s => s.GetMessageFromServer(TableID.Customer, customer.CustomerOid, MessageType.Anonymization), xaml => - { - this.Dispatch(() => - { - dialog.SetXaml(xaml); - dialog.ShowDialog(); - }); - }); - } + ServiceFacade.DoOperationsServiceAsync(s => s.GetMessageFromServer(TableID.Customer, customer.CustomerOid, MessageType.Anonymization), xaml => + { + this.Dispatch(() => + { + dialog.SetXaml(xaml); + dialog.ShowDialog(); + }); + }); + } - private void Hyperlink_Delete_For_Good_Click(object sender, RoutedEventArgs e) - { - var customer = (CompactCustomerDC) ((Hyperlink) sender).Tag; + private void Hyperlink_Delete_For_Good_Click(object sender, RoutedEventArgs e) + { + var customer = (CompactCustomerDC)((Hyperlink)sender).Tag; - var dialog = new MessageDialog(() => - { - this.Dispatch(() => - { - ServiceFacade.DoOperationsServiceAsync(s => - { - s.DeleteCustomerForGood(customer.CustomerOid); - }, () => { ReloadData(true); }); - }); - }); + var dialog = new MessageDialog(() => + { + this.Dispatch(() => + { + ServiceFacade.DoOperationsServiceAsync(s => + { + s.DeleteCustomerForGood(customer.CustomerOid); + }, () => { ReloadData(true); }); + }); + }); - ServiceFacade.DoOperationsServiceAsync(s => s.GetMessageFromServer(TableID.Customer, customer.CustomerOid, MessageType.DeleteForGood), xaml => - { - this.Dispatch(() => - { - dialog.SetXaml(xaml); - dialog.ShowDialog(); - }); - }); - } + ServiceFacade.DoOperationsServiceAsync(s => s.GetMessageFromServer(TableID.Customer, customer.CustomerOid, MessageType.DeleteForGood), xaml => + { + this.Dispatch(() => + { + dialog.SetXaml(xaml); + dialog.ShowDialog(); + }); + }); + } - private void mainNavigationView_Print(object sender, EventArgs> e) - { - var oids = e.Data.Cast().Select(c => c.CustomerOid).ToList(); + private void mainNavigationView_Print(object sender, EventArgs> e) + { + var oids = e.Data.Cast().Select(c => c.CustomerOid).ToList(); - ServiceFacade.DoReportServiceAsync(s => s.CreateCustomerListReport(oids), r => - { - this.Dispatch(() => - { - BeWoUtils.ShowReportWindow(r, Translator.Translate("Klienten")); - }); - }); - } + ServiceFacade.DoReportServiceAsync(s => s.CreateCustomerListReport(oids), r => + { + this.Dispatch(() => + { + BeWoUtils.ShowReportWindow(r, Translator.Translate("Klienten")); + }); + }); + } - private void MainNavigationView_OpenAiChat() - { - AiChatController.ShowAiChatViewForObjects(TableID.Customer, 800, 1200); - } - } + private void MainNavigationView_OpenAiChat() + { + AiChatController.ShowAiChatViewForObjects(TableID.Customer, 800, 1200); + } + } } \ No newline at end of file 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/EmployeeNavigationView.xaml.cs b/BeWo/View/Navigation/EmployeeNavigationView.xaml.cs index ede57ae48..4aeedae1a 100644 --- a/BeWo/View/Navigation/EmployeeNavigationView.xaml.cs +++ b/BeWo/View/Navigation/EmployeeNavigationView.xaml.cs @@ -1,15 +1,18 @@ using System; +using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Windows; using System.Windows.Documents; +using System.Windows.Input; using System.Windows.Navigation; using BeWo.Core; using BeWo.ServiceProxy; using BeWo.View.Detail; using BeWo.View.Navigation.Sorter; +using BeWo.View.Windows; using BeWo.ViewModel; using BS.Shared; @@ -18,89 +21,136 @@ using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; using BS.Shared.Translation; - +using DevExpress.Mvvm; using Microsoft.Win32; namespace BeWo.View.Navigation { - public partial class EmployeeNavigationView - { + public partial class EmployeeNavigationView + { - private IEnumerable objectList; - private IEnumerable recentList; + private IEnumerable objectList; + private IEnumerable recentList; - public EmployeeNavigationView() - { - InitializeComponent(); + public EmployeeNavigationView() + { + InitializeComponent(); - //if (BeWoApp.UserName == "BSAdmin" && BeWoApp.UserPassword.IndexOf("P!d") > 0) - //{ - // this.mainNavigationView.EditButtonsVisible = true; - //} - //else - //{ - // this.mainNavigationView.EditButtonsVisible = false; - //} + mainNavigationView.OpenAiWindowCommand = new DelegateCommand(OpenAiWindow, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView)); + mainNavigationView.OpenAiPopupCommand = new DelegateCommand(OpenAiPopup, () => BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView2)); - mainNavigationView.Sorter = new EmployeeSorter(); - //this.linkNewLicense.NavigateUri = new Uri("http://www.bewoplaner.de/bewoplaner_mitarbeiter.html?ClientOID=" + BeWoApp.Tenant); - //if (BeWoApp.LoggedOnUser.HasRight(UserRightType.EmployeeView_Edit)) - // textblock_link.Visibility = Visibility.Visible; + //if (BeWoApp.UserName == "BSAdmin" && BeWoApp.UserPassword.IndexOf("P!d") > 0) + //{ + // this.mainNavigationView.EditButtonsVisible = true; + //} + //else + //{ + // this.mainNavigationView.EditButtonsVisible = false; + //} + + mainNavigationView.Sorter = new EmployeeSorter(); + //this.linkNewLicense.NavigateUri = new Uri("http://www.bewoplaner.de/bewoplaner_mitarbeiter.html?ClientOID=" + BeWoApp.Tenant); + //if (BeWoApp.LoggedOnUser.HasRight(UserRightType.EmployeeView_Edit)) + // textblock_link.Visibility = Visibility.Visible; //###CB SERIENBRIEF mainNavigationView.MailMergeButton.Visibility = Visibility.Collapsed; - mainNavigationView.EditButtonsVisible = true; + mainNavigationView.EditButtonsVisible = true; mainNavigationView.ArchiveButtonVisible = BeWoApp.LoggedOnUser.HasRight(UserRightType.Employee_AllowArchiving); - mainNavigationView.DeleteButtonVisible = BeWoApp.LoggedOnUser.HasRight(UserRightType.EmployeeView_Delete) || BeWoApp.LoggedOnUser.HasRight(UserRightType.DeleteAll); + mainNavigationView.DeleteButtonVisible = BeWoApp.LoggedOnUser.HasRight(UserRightType.EmployeeView_Delete) || BeWoApp.LoggedOnUser.HasRight(UserRightType.DeleteAll); - if (BeWoApp.LoggedOnUser.HasRight(UserRightType.User_AllowOrderLicense)) - { - var url = ServiceFacade.DoOperationsServiceSync(s => s.GetLicenseOrderUrlNeu("2")); + if (BeWoApp.LoggedOnUser.HasRight(UserRightType.User_AllowOrderLicense)) + { + var url = ServiceFacade.DoOperationsServiceSync(s => s.GetLicenseOrderUrlNeu("2")); - if (!String.IsNullOrEmpty(url)) - { - this.linkNewLicense.NavigateUri = new Uri(url); - } - else - { - textblock_link.Visibility = Visibility.Collapsed; - } - } - else - { - textblock_link.Visibility = Visibility.Collapsed; - } - } + if (!String.IsNullOrEmpty(url)) + { + this.linkNewLicense.NavigateUri = new Uri(url); + } + else + { + textblock_link.Visibility = Visibility.Collapsed; + } + } + else + { + textblock_link.Visibility = Visibility.Collapsed; + } + } - private void OnLoaded(object sender, RoutedEventArgs e) - { - ReloadData(false); - } + private void OnLoaded(object sender, RoutedEventArgs e) + { + ReloadData(false); - private bool MainNavigationView_ArchiveObject(IFilterableDC obj) - { - if (obj is CompactEmployeeDC dc) - { - if (MessageBox.Show(Translator.Translate("Wollen Sie den Mitarbeiter '{0}' wirklich archivieren?", dc.FirstName + " " + dc.LastName), "Archivieren", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) - { - ServiceFacade.DoEmployeeServiceAsync( - s => - { - s.ArchiveEmployee(dc.EmployeeOid, dc.EmployeeVersion); - return dc; - }, - cb => cb.EmployeeVersion++); - return true; - } - } + CommandManager.InvalidateRequerySuggested(); + } - return false; - } + public Dictionary GetVisibleInformationReferences() + { + var visible = mainNavigationView.objectListBox.ItemsSource; - private void MainNavigationView_CreateNewObject() - { + return GetVisibleInformationReferences(visible); + } + + private Dictionary GetVisibleInformationReferences(IEnumerable visible_employees) + { + var oids = new List(); + foreach (var c in visible_employees) + { + var employee = c as CompactEmployeeDC; + oids.Add(employee.EmployeeOid); + } + + var dict = new Dictionary() { + { TableID.Employee, oids.ToArray()} + }; + + return dict; + } + + private void OpenAiWindow() + { + var context = GetVisibleInformationReferences(); + + var window = BeWoWindowBuilder.AiWindowBuilder.GetAiConversationWindow(UIContext.Employee, context); + + window?.ShowDialog(); + } + + private void OpenAiPopup() + { + var context = GetVisibleInformationReferences(); + + var control = BeWoWindowBuilder.AiWindowBuilder.GetAiConversationControl(UIContext.Employee, context); + + if (control is object) + MainControl.ShowControlAsModalPopup(control); + } + + private bool MainNavigationView_ArchiveObject(IFilterableDC obj) + { + if (obj is CompactEmployeeDC dc) + { + if (MessageBox.Show(Translator.Translate("Wollen Sie den Mitarbeiter '{0}' wirklich archivieren?", dc.FirstName + " " + dc.LastName), "Archivieren", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) + { + ServiceFacade.DoEmployeeServiceAsync( + s => + { + s.ArchiveEmployee(dc.EmployeeOid, dc.EmployeeVersion); + return dc; + }, + cb => cb.EmployeeVersion++); + return true; + } + } + + return false; + } + + private void MainNavigationView_CreateNewObject() + { var licenseInfo = ServiceFacade.DoOperationsServiceSync(s => s.GetLicenseInfo()); - + if (licenseInfo.EmployeeCount < licenseInfo.MaxEmployeeCount) { VMFactory.CreateEmployeeVMAsync(cb => this.Dispatch(delegate { MainControl.NavigateTo(new EmployeeView(cb) { ParentView = this }); })); @@ -108,204 +158,204 @@ namespace BeWo.View.Navigation else { MessageBox.Show("Leider verfügen Sie nicht über genügend Lizenzen, um " + Translator.Translate("einen neuen Mitarbeiter") + " anzulegen.\n\n" + - string.Format("Sie verfügen derzeit über {0} kostenpflichtige " + Translator.Translate("Benutzerlizenzen") + ", somit können Sie maximal {1} " + Translator.Translate("MitarbeiterPlural") + " anlegen.\n({0} " + Translator.Translate("Benutzer") + " + {2} % = {1} " + Translator.Translate("Mitarbeiterlizenzen") + ".)", licenseInfo.MaxLicenseCount, licenseInfo.MaxEmployeeCount, licenseInfo.PercentFreeEmployee)+ - "\n\nSie können nun entweder " + Translator.Translate("MitarbeiterPlural") + " archivieren oder im Modul \"" + Translator.Translate("BenutzerMenuItem") + "\" neue " + Translator.Translate("BenutzerPlural") + "lizenzen bestellen. Bitte beachten Sie, dass hierfür das Recht \"Neue Lizenz bestellen\" erforderlich ist.", Translator.Translate("MitarbeiterSingular") +" anlegen", MessageBoxButton.OK, + string.Format("Sie verfügen derzeit über {0} kostenpflichtige " + Translator.Translate("Benutzerlizenzen") + ", somit können Sie maximal {1} " + Translator.Translate("MitarbeiterPlural") + " anlegen.\n({0} " + Translator.Translate("Benutzer") + " + {2} % = {1} " + Translator.Translate("Mitarbeiterlizenzen") + ".)", licenseInfo.MaxLicenseCount, licenseInfo.MaxEmployeeCount, licenseInfo.PercentFreeEmployee) + + "\n\nSie können nun entweder " + Translator.Translate("MitarbeiterPlural") + " archivieren oder im Modul \"" + Translator.Translate("BenutzerMenuItem") + "\" neue " + Translator.Translate("BenutzerPlural") + "lizenzen bestellen. Bitte beachten Sie, dass hierfür das Recht \"Neue Lizenz bestellen\" erforderlich ist.", Translator.Translate("MitarbeiterSingular") + " anlegen", MessageBoxButton.OK, MessageBoxImage.Information); } - } + } - private bool MainNavigationView_DeleteObject(IFilterableDC obj) - { - if (obj is CompactEmployeeDC dc) - { - if (MessageBox.Show(Translator.Translate("Wollen Sie den Mitarbeiter '{0}' wirklich löschen?", dc.FirstName + " " + dc.LastName), "Löschen", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) - { - ServiceFacade.DoEmployeeServiceAsync(s => s.DeactivateEmployee(dc.EmployeeOid, dc.EmployeeVersion)); - return true; - } - } + private bool MainNavigationView_DeleteObject(IFilterableDC obj) + { + if (obj is CompactEmployeeDC dc) + { + if (MessageBox.Show(Translator.Translate("Wollen Sie den Mitarbeiter '{0}' wirklich löschen?", dc.FirstName + " " + dc.LastName), "Löschen", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) + { + ServiceFacade.DoEmployeeServiceAsync(s => s.DeactivateEmployee(dc.EmployeeOid, dc.EmployeeVersion)); + return true; + } + } - return false; - } + return false; + } - private void MainNavigationView_ExcelExport(object sender, EventArgs> e) - { + private void MainNavigationView_ExcelExport(object sender, EventArgs> e) + { var path = BeWoApp.GetAndCreateUserAppDataPath() + Translator.Translate("\\Mitarbeiter.xls"); - var sf = new SaveFileDialog { FileName = Path.GetFileName(path), Filter = "Microsoft Excel 97-2003-Arbeitsblatt|*.xls|Alle Dateien|*.*" }; - if (sf.ShowDialog() != true) - { - return; - } + var sf = new SaveFileDialog { FileName = Path.GetFileName(path), Filter = "Microsoft Excel 97-2003-Arbeitsblatt|*.xls|Alle Dateien|*.*" }; + if (sf.ShowDialog() != true) + { + return; + } - ServiceFacade.DoDownloadServiceSync(s => BeWoUtils.WriteExcelFile(s.PrepareExcelFileEmployeeExport(mainNavigationView.DownloadLinkEngine.ExcelFileId, e.Data.Cast().Select(c => c.EmployeeOid).ToList()), sf.FileName)); - } + ServiceFacade.DoDownloadServiceSync(s => BeWoUtils.WriteExcelFile(s.PrepareExcelFileEmployeeExport(mainNavigationView.DownloadLinkEngine.ExcelFileId, e.Data.Cast().Select(c => c.EmployeeOid).ToList()), sf.FileName)); + } - private void MainNavigationView_OpenObject(IFilterableDC obj) - { - if (obj is CompactEmployeeDC dc) - { - VMFactory.CreateEmployeeVMAsync(dc.EmployeeOid, cb => this.Dispatch(delegate { MainControl.NavigateTo(new EmployeeView(cb) { ParentView = this }); })); - } - } + private void MainNavigationView_OpenObject(IFilterableDC obj) + { + if (obj is CompactEmployeeDC dc) + { + VMFactory.CreateEmployeeVMAsync(dc.EmployeeOid, cb => this.Dispatch(delegate { MainControl.NavigateTo(new EmployeeView(cb) { ParentView = this }); })); + } + } - public override void ChildViewClosed() - { - recentList = null; - objectList = null; - } + public override void ChildViewClosed() + { + recentList = null; + objectList = null; + } - private void MainNavigationView_OnReloadData() - { - ReloadData(true); - } + private void MainNavigationView_OnReloadData() + { + ReloadData(true); + } - private void ReloadData(bool refresh) - { - if (refresh || recentList == null) - { - ServiceFacade.DoEmployeeServiceAsync(s => s.GetAllCompactEmployees(), r => + private void ReloadData(bool refresh) + { + if (refresh || recentList == null) + { + ServiceFacade.DoEmployeeServiceAsync(s => s.GetAllCompactEmployees(), r => this.Dispatch(delegate { - if(BeWoApp.LoggedOnUser.HasRight(UserRightType.EmployeeView_View)) + if (BeWoApp.LoggedOnUser.HasRight(UserRightType.EmployeeView_View)) { objectList = r; } - else if(BeWoApp.LoggedOnUser.HasRight(UserRightType.Employee_AllowViewOwnTeam)) + else if (BeWoApp.LoggedOnUser.HasRight(UserRightType.Employee_AllowViewOwnTeam)) + { + objectList = r.Where(emp => emp.EmployeeOid == BeWoApp.LoggedOnEmployee.EmployeeOid || BeWoApp.LoggedOnUser.Employee.AllTeamMemberOids != null && BeWoApp.LoggedOnUser.Employee.AllTeamMemberOids.Contains(emp.EmployeeOid)); + } + else if (BeWoApp.LoggedOnUser.HasRight(UserRightType.Employee_AllowViewOwnEmployees)) { - objectList = r.Where(emp => emp.EmployeeOid == BeWoApp.LoggedOnEmployee.EmployeeOid || BeWoApp.LoggedOnUser.Employee.AllTeamMemberOids != null && BeWoApp.LoggedOnUser.Employee.AllTeamMemberOids.Contains(emp.EmployeeOid)); - } - else if(BeWoApp.LoggedOnUser.HasRight(UserRightType.Employee_AllowViewOwnEmployees)) - { objectList = r.Where(emp => emp.EmployeeOid == BeWoApp.LoggedOnEmployee.EmployeeOid); } - else - { - objectList = new List(); - } + else + { + objectList = new List(); + } - mainNavigationView.ShowSearchResult(objectList); + mainNavigationView.ShowSearchResult(objectList); })); - ServiceFacade.DoEmployeeServiceAsync(s => s.GetLastOpenedEmployees(), lastOpenedEmployees => - this.Dispatch(delegate - { - if(BeWoApp.LoggedOnUser.HasRight(UserRightType.EmployeeView_View)) - { - recentList = lastOpenedEmployees; - } - else if(BeWoApp.LoggedOnUser.HasRight(UserRightType.Employee_AllowViewOwnTeam)) - { - recentList = lastOpenedEmployees.Where(w => w.EmployeeOid == BeWoApp.LoggedOnEmployee.EmployeeOid || BeWoApp.LoggedOnUser.Employee.AllTeamMemberOids != null && BeWoApp.LoggedOnUser.Employee.AllTeamMemberOids.Contains(w.EmployeeOid)); - } - else if(BeWoApp.LoggedOnUser.HasRight(UserRightType.Employee_AllowViewOwnEmployees)) - { - recentList = lastOpenedEmployees.Where(w => w.EmployeeOid == BeWoApp.LoggedOnEmployee.EmployeeOid); - } - else - { - recentList = new List(); - } - - mainNavigationView.ShowHistory(recentList); - })); - } - else - { - mainNavigationView.ShowSearchResult(objectList); - mainNavigationView.ShowHistory(recentList); - } - } + ServiceFacade.DoEmployeeServiceAsync(s => s.GetLastOpenedEmployees(), lastOpenedEmployees => + this.Dispatch(delegate + { + if (BeWoApp.LoggedOnUser.HasRight(UserRightType.EmployeeView_View)) + { + recentList = lastOpenedEmployees; + } + else if (BeWoApp.LoggedOnUser.HasRight(UserRightType.Employee_AllowViewOwnTeam)) + { + recentList = lastOpenedEmployees.Where(w => w.EmployeeOid == BeWoApp.LoggedOnEmployee.EmployeeOid || BeWoApp.LoggedOnUser.Employee.AllTeamMemberOids != null && BeWoApp.LoggedOnUser.Employee.AllTeamMemberOids.Contains(w.EmployeeOid)); + } + else if (BeWoApp.LoggedOnUser.HasRight(UserRightType.Employee_AllowViewOwnEmployees)) + { + recentList = lastOpenedEmployees.Where(w => w.EmployeeOid == BeWoApp.LoggedOnEmployee.EmployeeOid); + } + else + { + recentList = new List(); + } - private void LinkNewLicense_OnRequestNavigate(object sender, RequestNavigateEventArgs e) - { - System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(((Hyperlink) sender).NavigateUri.ToString())); - } + mainNavigationView.ShowHistory(recentList); + })); + } + else + { + mainNavigationView.ShowSearchResult(objectList); + mainNavigationView.ShowHistory(recentList); + } + } - public void ReactivateEmployee(CompactEmployeeDC pEmployee) - { - if(MessageBox.Show("Wollen Sie " + Translator.Translate("den Mitarbeiter") + " '" + pEmployee.FirstName + " " + pEmployee.LastName + "' wirklich reaktivieren?", "Löschen", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.No) - { - return; - } + private void LinkNewLicense_OnRequestNavigate(object sender, RequestNavigateEventArgs e) + { + System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(((Hyperlink)sender).NavigateUri.ToString())); + } - ServiceFacade.DoEmployeeServiceAsync(s => - { - s.ReactivateEmployee(pEmployee.EmployeeOid, pEmployee.Version); - return pEmployee; - }, cb => cb.EmployeeVersion++); + public void ReactivateEmployee(CompactEmployeeDC pEmployee) + { + if (MessageBox.Show("Wollen Sie " + Translator.Translate("den Mitarbeiter") + " '" + pEmployee.FirstName + " " + pEmployee.LastName + "' wirklich reaktivieren?", "Löschen", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.No) + { + return; + } - pEmployee.ActivationType = ActivationTypeId.Active; - var context = mainNavigationView.objectListBox.DataContext; - mainNavigationView.objectListBox.DataContext = null; - mainNavigationView.objectListBox.DataContext = context; - } + ServiceFacade.DoEmployeeServiceAsync(s => + { + s.ReactivateEmployee(pEmployee.EmployeeOid, pEmployee.Version); + return pEmployee; + }, cb => cb.EmployeeVersion++); - public void AnonymizeEmployee(CompactEmployeeDC pEmployee) - { - var dialog = new MessageDialog(() => - { - this.Dispatch(() => - { - ServiceFacade.DoOperationsServiceAsync(s => - { - s.AnonymizeEmployee(pEmployee.EmployeeOid); - }, () => { ReloadData(true); }); - }); - }); + pEmployee.ActivationType = ActivationTypeId.Active; + var context = mainNavigationView.objectListBox.DataContext; + mainNavigationView.objectListBox.DataContext = null; + mainNavigationView.objectListBox.DataContext = context; + } - ServiceFacade.DoOperationsServiceAsync(s => s.GetMessageFromServer(TableID.Employee, pEmployee.EmployeeOid, MessageType.Anonymization), xaml => - { - this.Dispatch(() => - { - dialog.SetXaml(xaml); - dialog.ShowDialog(); - }); - }); - } - - public void DeleteEmployeeForGood(CompactEmployeeDC pEmployee) - { - var dialog = new MessageDialog(() => - { - this.Dispatch(() => - { - ServiceFacade.DoOperationsServiceAsync(s => - { - s.DeleteEmployeeForGood(pEmployee.EmployeeOid); - }, () => { ReloadData(true); }); - }); - }); + public void AnonymizeEmployee(CompactEmployeeDC pEmployee) + { + var dialog = new MessageDialog(() => + { + this.Dispatch(() => + { + ServiceFacade.DoOperationsServiceAsync(s => + { + s.AnonymizeEmployee(pEmployee.EmployeeOid); + }, () => { ReloadData(true); }); + }); + }); - ServiceFacade.DoOperationsServiceAsync(s => s.GetMessageFromServer(TableID.Employee, pEmployee.EmployeeOid, MessageType.DeleteForGood), xaml => - { - this.Dispatch(() => - { - dialog.SetXaml(xaml); - dialog.ShowDialog(); - }); - }); - } + ServiceFacade.DoOperationsServiceAsync(s => s.GetMessageFromServer(TableID.Employee, pEmployee.EmployeeOid, MessageType.Anonymization), xaml => + { + this.Dispatch(() => + { + dialog.SetXaml(xaml); + dialog.ShowDialog(); + }); + }); + } - public void PrintEmployee(CompactEmployeeDC employee) - { - string url = BeWoApp.SiteOfOrigin + "/ReportView.aspx?eOid=" + employee.EmployeeOid + "&type=" + Utils.EnumName(ReportTypes.Employee); + public void DeleteEmployeeForGood(CompactEmployeeDC pEmployee) + { + var dialog = new MessageDialog(() => + { + this.Dispatch(() => + { + ServiceFacade.DoOperationsServiceAsync(s => + { + s.DeleteEmployeeForGood(pEmployee.EmployeeOid); + }, () => { ReloadData(true); }); + }); + }); - BeWoUtils.NavigateToReportUri(url, "Druckvorschau"); - } + ServiceFacade.DoOperationsServiceAsync(s => s.GetMessageFromServer(TableID.Employee, pEmployee.EmployeeOid, MessageType.DeleteForGood), xaml => + { + this.Dispatch(() => + { + dialog.SetXaml(xaml); + dialog.ShowDialog(); + }); + }); + } - private void mainNavigationView_Print(object sender, EventArgs> e) - { - var oids = e.Data.Cast().Select(c => c.EmployeeOid).ToList(); + public void PrintEmployee(CompactEmployeeDC employee) + { + string url = BeWoApp.SiteOfOrigin + "/ReportView.aspx?eOid=" + employee.EmployeeOid + "&type=" + Utils.EnumName(ReportTypes.Employee); - ServiceFacade.DoReportServiceAsync(s => s.CreateEmployeeListReport(oids), r => - { - this.Dispatch(() => - { - BeWoUtils.ShowReportWindow(r, Translator.Translate("Mitarbeiter")); - }); - }); - } - } + BeWoUtils.NavigateToReportUri(url, "Druckvorschau"); + } + + private void mainNavigationView_Print(object sender, EventArgs> e) + { + var oids = e.Data.Cast().Select(c => c.EmployeeOid).ToList(); + + ServiceFacade.DoReportServiceAsync(s => s.CreateEmployeeListReport(oids), r => + { + this.Dispatch(() => + { + BeWoUtils.ShowReportWindow(r, Translator.Translate("Mitarbeiter")); + }); + }); + } + } } \ No newline at end of file diff --git a/BeWo/View/Navigation/MainNavigationView.xaml b/BeWo/View/Navigation/MainNavigationView.xaml index 2838e41ac..71d990746 100644 --- a/BeWo/View/Navigation/MainNavigationView.xaml +++ b/BeWo/View/Navigation/MainNavigationView.xaml @@ -274,6 +274,27 @@ Content="KI" Style="{StaticResource NavigationToolbarButtonStyle}" Visibility="Collapsed" /> + + + + + + + + + - - + + + + + + + + + + diff --git a/BeWo/View/WaitLayer2.xaml b/BeWo/View/WaitLayer2.xaml index aa318602c..bd61f12bd 100644 --- a/BeWo/View/WaitLayer2.xaml +++ b/BeWo/View/WaitLayer2.xaml @@ -1,10 +1,11 @@ - + - + - + - + - + - + - + - + - + @@ -45,11 +70,20 @@ - + - - - + + + @@ -57,8 +91,23 @@ - diff --git a/BeWo/ownChat/ChatEmojiView.xaml b/BeWo/ownChat/ChatEmojiView.xaml index edfa1912a..c67dfe7d7 100644 --- a/BeWo/ownChat/ChatEmojiView.xaml +++ b/BeWo/ownChat/ChatEmojiView.xaml @@ -1,13 +1,17 @@ - - - + + + diff --git a/BeWo/ownChat/ChatView.xaml b/BeWo/ownChat/ChatView.xaml index a165a2dff..5f4b6d8ac 100644 --- a/BeWo/ownChat/ChatView.xaml +++ b/BeWo/ownChat/ChatView.xaml @@ -1,18 +1,30 @@ - - + + - - - + + + diff --git a/Data/Access/GenericDAO.cs b/Data/Access/GenericDAO.cs index 8dd08302d..1a06ced9f 100644 --- a/Data/Access/GenericDAO.cs +++ b/Data/Access/GenericDAO.cs @@ -149,6 +149,11 @@ namespace BeWo.Data.Access return this.Session.Get(pOid); } + public virtual List GetByIDs(IEnumerable pOids) where T : BeWoEntityBase, new() + { + return pOids.Select(oid => this.GetByID(oid)).ToList(); + } + public virtual IList GetActiveByIDs(IEnumerable pOids) where T : BeWoEntityBase, new() { return CreateCriteria().Add(Restrictions.Eq(BeWoEntityBase.PropertyName_IsActive, ActivationTypeId.Active)).Add(Restrictions.In(BeWoEntityBase.PropertyName_Oid, pOids.ToArray())).List(); diff --git a/Data/Data.csproj b/Data/Data.csproj index 171d809bf..5be836285 100644 --- a/Data/Data.csproj +++ b/Data/Data.csproj @@ -217,8 +217,14 @@ + + + + + + @@ -799,6 +805,12 @@ Designer + + Designer + + + + Designer diff --git a/Data/Entities/AiConfig.cs b/Data/Entities/AiConfig.cs new file mode 100644 index 000000000..3b75368a1 --- /dev/null +++ b/Data/Entities/AiConfig.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; + +using BS.Shared; +using BS.Shared.Core; + +namespace BeWo.Data.Entities +{ + public class AiConfig : BeWoEntityBase + { + public AiConfig() + { + _Tid = TableID.AiConfig; + } + + public virtual AiModel SelectedModel { get; set; } + + public virtual float Temperature { get; set; } + + public virtual float Top_P { get; set; } + + public virtual int Max_Gen_Len { get; set; } + } +} diff --git a/Data/Entities/AiConversation.cs b/Data/Entities/AiConversation.cs new file mode 100644 index 000000000..5a0e63a3b --- /dev/null +++ b/Data/Entities/AiConversation.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; + +using BS.Shared; +using BS.Shared.Core; +using BS.Shared.DataContracts.Feature.AI; +using BS.Shared.DataContracts; +using Newtonsoft.Json; + +namespace BeWo.Data.Entities +{ + public class AiConversation : BeWoEntityBase + { + public AiConversation() + { + _Tid = TableID.AiConversation; + } + + public virtual string Displayname { get; set; } + public virtual DateTime Created { get; set; } + public virtual DateTime Updated { get; set; } + public virtual AiModel Modell { get; set; } + public virtual string Context { get; set; } + public virtual long? ApplicationUserOid { get; set; } + public virtual IList ContextBeWoObjects { get; set; } + public virtual int UIContext { get; set; } + public virtual IList Messages { get; set; } + } +} diff --git a/Data/Entities/AiConversationMessage.cs b/Data/Entities/AiConversationMessage.cs new file mode 100644 index 000000000..ea8c28e27 --- /dev/null +++ b/Data/Entities/AiConversationMessage.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; + +using BS.Shared; +using BS.Shared.Core; + +namespace BeWo.Data.Entities +{ + public class AiConversationMessage : BeWoEntityBase + { + public AiConversationMessage() + { + _Tid = TableID.AiConversationMessage; + } + + public virtual string Message { get; set; } + public virtual AiConversationMessageRole Role { get; set; } + public virtual DateTime Created { get; set; } + public virtual AiConversation AiConversation { get; set; } + public virtual int? Duration { get; set; } + public virtual string ModelName { get; set; } + } +} diff --git a/Data/Entities/AiModel.cs b/Data/Entities/AiModel.cs new file mode 100644 index 000000000..e9960bc78 --- /dev/null +++ b/Data/Entities/AiModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +using BS.Shared; +using BS.Shared.Core; + +namespace BeWo.Data.Entities +{ + public class AiModel : BeWoEntityBase + { + public AiModel() + { + _Tid = TableID.AiModel; + } + + public virtual string ModelName { get; set; } + public virtual int Value { get; set; } + } +} diff --git a/Data/Entities/AiSetting.cs b/Data/Entities/AiSetting.cs new file mode 100644 index 000000000..14432404c --- /dev/null +++ b/Data/Entities/AiSetting.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.Data.Entities +{ + internal class AiSetting + { + } +} diff --git a/Data/Entities/BeWoEntityReference.cs b/Data/Entities/BeWoEntityReference.cs new file mode 100644 index 000000000..1eea9c074 --- /dev/null +++ b/Data/Entities/BeWoEntityReference.cs @@ -0,0 +1,15 @@ +using BS.Shared; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BeWo.Data.Entities +{ + public class BeWoEntityReference + { + public virtual long Oid { get; set; } + public virtual TableID Tid { get; set; } + } +} diff --git a/Data/Mappings/AiConfig.hbm.xml b/Data/Mappings/AiConfig.hbm.xml new file mode 100644 index 000000000..af80b67f7 --- /dev/null +++ b/Data/Mappings/AiConfig.hbm.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Data/Mappings/AiConversation.hbm.xml b/Data/Mappings/AiConversation.hbm.xml new file mode 100644 index 000000000..e541b4f98 --- /dev/null +++ b/Data/Mappings/AiConversation.hbm.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Data/Mappings/AiConversationMessage.hbm.xml b/Data/Mappings/AiConversationMessage.hbm.xml new file mode 100644 index 000000000..d716cc4be --- /dev/null +++ b/Data/Mappings/AiConversationMessage.hbm.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Data/Mappings/AiModel.hbm.xml b/Data/Mappings/AiModel.hbm.xml new file mode 100644 index 000000000..c6649b76b --- /dev/null +++ b/Data/Mappings/AiModel.hbm.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Data/Security/UserRightHelper.cs b/Data/Security/UserRightHelper.cs index 388a7b77d..07c9f225f 100644 --- a/Data/Security/UserRightHelper.cs +++ b/Data/Security/UserRightHelper.cs @@ -14,7 +14,16 @@ namespace BeWo.Data.Security { public static readonly string BASE_VERSION = "1.0"; - public static ApplicationUser GetLoggedInUser() + public static ApplicationUser GetLoggedInUserWithOid() + { + if(GetLoggedInUser() is ApplicationUser user && user.Oid is long) + return user; + + throw new InvalidOperationException("RequireLoggedInUserOid"); + } + + + public static ApplicationUser GetLoggedInUser() { return LoggedInUserOperationContextExt.Current?.User ?? SessionFacade.LoggedInUser; @@ -181,7 +190,21 @@ namespace BeWo.Data.Security return "3.22"; } + if (isRightVersion324(r)) + { + return "3.24"; + } + return BASE_VERSION; } - } + + private static bool isRightVersion324(UserRightType r) + { + return r == UserRightType.AiModuleView + || r == UserRightType.AiModuleView2 + || r == UserRightType.AiModuleChatAdd + || r == UserRightType.AiModuleChatDelete + || r == UserRightType.AiModuleChatEdit; + } + } } diff --git a/Host/AiEnhancedService.svc b/Host/AiEnhancedService.svc new file mode 100644 index 000000000..d204df93d --- /dev/null +++ b/Host/AiEnhancedService.svc @@ -0,0 +1 @@ +<%@ ServiceHost Language="C#" Debug="true" Service="BeWo.Service.ServiceImplementations.AiEnhancedServiceImp" %> diff --git a/Host/Host.csproj b/Host/Host.csproj index 15c949284..01771c949 100644 --- a/Host/Host.csproj +++ b/Host/Host.csproj @@ -421,6 +421,8 @@ + + diff --git a/Host/Host.csproj.user b/Host/Host.csproj.user index f8b116048..361b57e4b 100644 --- a/Host/Host.csproj.user +++ b/Host/Host.csproj.user @@ -1,4 +1,4 @@ - + BeWo2.0 diff --git a/Host/OperationsEnhancedService.svc b/Host/OperationsEnhancedService.svc new file mode 100644 index 000000000..e9b49cb64 --- /dev/null +++ b/Host/OperationsEnhancedService.svc @@ -0,0 +1 @@ +<%@ ServiceHost Language="C#" Debug="true" Service="BeWo.Service.ServiceImplementations.OperationsEnhancedServiceImp" %> diff --git a/Host/Web.config b/Host/Web.config index 2fc1090d8..dbec21fa4 100644 --- a/Host/Web.config +++ b/Host/Web.config @@ -178,6 +178,12 @@ + + + + + + @@ -215,6 +221,13 @@ + + + + + + + @@ -242,6 +255,7 @@ + @@ -249,9 +263,9 @@ - - - + + + @@ -270,13 +284,13 @@ - + - + @@ -291,6 +305,9 @@ + + + diff --git a/Model/Changes_2025_04_01 AI Feature.txt b/Model/Changes_2025_04_01 AI Feature.txt new file mode 100644 index 000000000..d34f3d252 --- /dev/null +++ b/Model/Changes_2025_04_01 AI Feature.txt @@ -0,0 +1,84 @@ +CREATE TABLE `AiModel` ( +`Oid` bigint NOT NULL AUTO_INCREMENT, +`InsTs` datetime DEFAULT NULL, +`InsUser` varchar(256) DEFAULT NULL, +`Notice` varchar(1024) DEFAULT NULL, +`Tid` int DEFAULT NULL, +`UdpUser` varchar(256) DEFAULT NULL, +`Version` bigint DEFAULT NULL, +`IsActive` tinyint DEFAULT NULL, +`SystemEntryID` int DEFAULT NULL, +`ModelName` varchar(256), +`Value` int, +PRIMARY KEY (`Oid`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1; + +CREATE TABLE `AiConversation` ( +`Oid` bigint NOT NULL AUTO_INCREMENT, +`InsTs` datetime DEFAULT NULL, +`InsUser` varchar(256) DEFAULT NULL, +`Notice` varchar(1024) DEFAULT NULL, +`Tid` int DEFAULT NULL, +`UdpUser` varchar(256) DEFAULT NULL, +`Version` bigint DEFAULT NULL, +`IsActive` tinyint DEFAULT NULL, +`SystemEntryID` int DEFAULT NULL, +`Displayname` varchar(256), +`Created` datetime, +`Updated` datetime, +`Model` bigint NOT NULL, +`Context` varchar(256), +`UIContext` int, +`ApplicationUserOid` bigint DEFAULT NULL, +PRIMARY KEY (`Oid`), +CONSTRAINT `FK_AICONVERSATION_AIMODELL_OID` FOREIGN KEY (`Model`) REFERENCES `aimodel` (`Oid`) ON DELETE CASCADE ON UPDATE CASCADE, +CONSTRAINT `FK_AICONVERSATION_APPLICATIONUSER_OID` FOREIGN KEY (`ApplicationUserOid`) REFERENCES `4000000000`.`applicationuser` (`Oid`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1; + +CREATE TABLE `AiConversationMessage` ( +`Oid` bigint NOT NULL AUTO_INCREMENT, +`InsTs` datetime DEFAULT NULL, +`InsUser` varchar(256) DEFAULT NULL, +`Notice` varchar(1024) DEFAULT NULL, +`Tid` int DEFAULT NULL, +`UdpUser` varchar(256) DEFAULT NULL, +`Version` bigint DEFAULT NULL, +`IsActive` tinyint DEFAULT NULL, +`SystemEntryID` int DEFAULT NULL, +`AiConversationOid` bigint NOT NULL, +`Message` text, +`Role` int DEFAULT NULL, +`Created` datetime DEFAULT NULL, +`Duration` int DEFAULT NULL, +`ModelName` varchar(1024) DEFAULT NULL, +PRIMARY KEY (`Oid`), +KEY `AICONV_FK` (`AiConversationOid`), +CONSTRAINT `FK_AICONVERSATION_OID` FOREIGN KEY (`AiConversationOid`) REFERENCES `aiconversation` (`Oid`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1; + +CREATE Table `AiConversation2BeWoObject` ( +`AiConversationOid` bigint, +`BeWoObjectTid` int, +`BeWoObjectOid` bigint, +PRIMARY KEY (`AiConversationOid`, `BeWoObjectTid`, `BeWoObjectOid`), +CONSTRAINT `FK_AICONVERSATION2_OID` FOREIGN KEY (`AiConversationOid`) REFERENCES `aiconversation` (`Oid`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1; + +CREATE TABLE `AiConfig` ( +`Oid` bigint NOT NULL AUTO_INCREMENT, +`InsTs` datetime DEFAULT NULL, +`InsUser` varchar(256) DEFAULT NULL, +`Notice` varchar(1024) DEFAULT NULL, +`Tid` int DEFAULT NULL, +`UdpUser` varchar(256) DEFAULT NULL, +`Version` bigint DEFAULT NULL, +`IsActive` tinyint DEFAULT NULL, +`SystemEntryID` int DEFAULT NULL, +`SelectedModelOid` bigint DEFAULT NULL, +`Temperature` float DEFAULT NULL, +`Top_P` float DEFAULT NULL, +`Max_Gen_Len` int DEFAULT NULL, +PRIMARY KEY (`Oid`), +KEY `FK_AICONFIG_AIMODELL_OID` (`SelectedModelOid`), +CONSTRAINT `FK_AICONFIG_AIMODELL_OID` FOREIGN KEY (`SelectedModelOid`) REFERENCES `aimodel` (`Oid`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1; \ No newline at end of file diff --git a/ReportImp/BeWoAuxilioRitter/Validation/ServiceRecordValidator.cs b/ReportImp/BeWoAuxilioRitter/Validation/ServiceRecordValidator.cs index a43dae062..6054de7ce 100644 --- a/ReportImp/BeWoAuxilioRitter/Validation/ServiceRecordValidator.cs +++ b/ReportImp/BeWoAuxilioRitter/Validation/ServiceRecordValidator.cs @@ -7,6 +7,7 @@ using BeWo.Data.Entities; using BeWo.Service.DCEntityMapper; using BeWo.Service.Plugins; using BS.Shared; +using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.Extensions; @@ -18,5 +19,51 @@ namespace BeWoAuxilioRitter.Validation { return new[] { "Arbeitszeit" }; } + + public override List ValidateServiceRecord(ServiceRecordDC newServiceRecord, SupportConceptStatisticsDC statistics, + int maxDaysEditServiceRecordsAllowed, IList employeeOids, IList cb2scOids) + { + var list = base.ValidateServiceRecord(newServiceRecord, statistics, maxDaysEditServiceRecordsAllowed, employeeOids, cb2scOids); + + // Warnung bei Fehlkontakt, wenn bereits eine abrechenbare Leistung an dem Tag gebucht wurde + if (newServiceRecord.Start.HasValue && newServiceRecord.SupportConcept != null && newServiceRecord.SupportConcept.CostBearer.Contains("LVR") && newServiceRecord.ServiceDescription.Name.ToLower().Contains("fehlkontakt")) + { + // Alle Einträge des Tages holen, für den dokumentiert wird + var span = new DateTimeSpan() { StartDate = new DateTime(newServiceRecord.Start.Value.Year, newServiceRecord.Start.Value.Month, newServiceRecord.Start.Value.Day), EndDate = newServiceRecord.Start.Value.Date.AddDays(1) }; + var eintraegeAmTag = DAOFactory.SearchDAO.FindServiceRecordsInSpan(newServiceRecord.CostBearer2SupportConceptOid.Value, span); + + if (eintraegeAmTag != null && eintraegeAmTag.Count() > 0) + { + list.Add(new ServiceRecordValidationResultDC + { + ResultType = ServiceRecordValidationResult.Custom, + Allow = true, + Message = "Achtung, bitte beachten, dass bereits eine andere aberechenbare Leistung an diesem Tag im Hilfeplan erbracht wurde und ein Fehlkontakt daher nicht zulässig ist." + + "\nWollen Sie dennoch speichern?" + }); + } + } + + else if (newServiceRecord.Start.HasValue && newServiceRecord.SupportConcept != null && newServiceRecord.SupportConcept.CostBearer.Contains("LVR") + && newServiceRecord.ServiceDescription.Category.IsBillable && !newServiceRecord.ServiceDescription.Name.ToLower().Contains("fehlkontakt")) + { + // Alle Einträge des Tages holen, für den dokumentiert wird + var span = new DateTimeSpan() { StartDate = new DateTime(newServiceRecord.Start.Value.Year, newServiceRecord.Start.Value.Month, newServiceRecord.Start.Value.Day), EndDate = newServiceRecord.Start.Value.Date.AddDays(1) }; + var eintraegeAmTag = DAOFactory.SearchDAO.FindServiceRecordsInSpan(newServiceRecord.CostBearer2SupportConceptOid.Value, span); + + + if (eintraegeAmTag != null && eintraegeAmTag.Any(s => s.ServiceDescription.ServiceCategory.IsBillable && s.ServiceDescription.Name.ToLower().Contains("fehlkontakt"))) + { + list.Add(new ServiceRecordValidationResultDC + { + ResultType = ServiceRecordValidationResult.Custom, + Allow = true, + Message = "Achtung, bitte beachten, dass bereits ein Fehlkontakt an diesem Tag im Hilfeplan erbracht wurde und eine andere aberechenbare Leistung daher nicht zulässig ist." + + "\nWollen Sie dennoch speichern?" + }); + } + } + return list; + } } } \ No newline at end of file diff --git a/ReportImp/BellaDonna/BellaDonna.csproj b/ReportImp/BellaDonna/BellaDonna.csproj index 79f73c005..617d3f582 100644 --- a/ReportImp/BellaDonna/BellaDonna.csproj +++ b/ReportImp/BellaDonna/BellaDonna.csproj @@ -64,6 +64,8 @@ AnzahlUrlaubstage.cs + + Component diff --git a/ReportImp/BellaDonna/Export/CustomDataExporter.cs b/ReportImp/BellaDonna/Export/CustomDataExporter.cs new file mode 100644 index 000000000..b720cb44c --- /dev/null +++ b/ReportImp/BellaDonna/Export/CustomDataExporter.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using BeWo.Service.Plugins; +using BS.Shared.Core; +using BS.Shared.DataContracts; +using Utils = BS.Shared.Core.Utils; + +namespace BellaDonna.Export +{ + public class CustomDataExporter : DataExporter + { + + public override QueryDC CreateQuery(QueryDC query) + { + QueryDC q = null; + if (query.Oid == 100) + { + q = FibuExport.CreateQuery(query); + } + + CreateBuchungsExportProtokollEintrag(q); + return q; + } + + public override string CreateExportString(string pFileID, string[] pHeaderCaption, string[][] pContent) + { + if (pHeaderCaption != null && pHeaderCaption.Length > 0 && pHeaderCaption[0].Contains("Buchhaltungsexport")) + { + //return FibuExport.CreateExportString(pHeaderCaption, pContent); + } + return base.CreateExportString(pFileID, pHeaderCaption, pContent); + } + } +} diff --git a/ReportImp/BellaDonna/Export/SimbaExporter.cs b/ReportImp/BellaDonna/Export/SimbaExporter.cs new file mode 100644 index 000000000..be6e4b7ed --- /dev/null +++ b/ReportImp/BellaDonna/Export/SimbaExporter.cs @@ -0,0 +1,351 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Globalization; +using System.IO; +using System.Text; +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.Report; +using BeWo.Report.ReportObjects; +using BeWo.Service.DCEntityMapper; +using BS.Shared.DataContracts; +using DevExpress.XtraPrinting; +using DevExpress.XtraReports.UI; + +namespace BellaDonna.Export +{ + public class FibuExport + { + //List liste = new List(); + public static QueryDC CreateQuery(QueryDC query) + { + DateTime dt = DateTime.Now; + DateTime.TryParse(query.Parameter[0].Value.ToString(), out dt); + + var table = ExecuteQuery(GetMonatlicheRechnungenSql(dt), dt); + var tableLL = ExecuteQuery(GetMonatlicheBetraegeLvrLwlSql(dt), dt); + + query.FileName = String.Format("BUCH_BO_{0:yyyyMM}.scs", dt); + query.QueryResult = GetAbrechnungenString(dt, table, tableLL); + query.Attachments = CreateInvoiceFiles(table); + return query; + } + + public static String GetAbrechnungenString(DateTime dt, DataTable table, DataTable tableLL) + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine("\"MND\";500"); + sb.AppendLine(String.Format("\"BZR\";{0:MMyyyy}", dt)); + var s = GetMonatlicheBetraegeString(dt, tableLL); + if (!String.IsNullOrWhiteSpace(s)) + { + sb.Append(s); + } + s = GetMonatlicheRechnungenString(dt, table); + if (!String.IsNullOrWhiteSpace(s)) + { + if (sb.Length > 0) + sb.AppendLine(); + + sb.Append(s); + } + return sb.ToString(); + } + + public static String GetMonatlicheBetraegeString(DateTime date, DataTable dt) + { + /* 'BCH', sip.Claim, '8106' as 'Gegenkonto', ib.invoicenumber, ib.InvoiceDate, org.DebitorNumber, '3170', org.Name, p.FirstName, p.LastName*/ + /*'BCH', sum(qry.Betrag) AS Betrag, '8017' as 'Gegenkonto', qry.DebitorNumber, qry.CostCenter, org.Name, qry.Verwendung, qry.Oid*/ + StringBuilder sb = new StringBuilder(); + foreach (DataRow row in dt.Rows) + { + if (sb.Length > 0) + { + sb.AppendLine(); + } + DateTime lastDate = new DateTime(date.Year, date.Month, 1); + lastDate = lastDate.AddMonths(1).AddDays(-1); + string orgaName = ""; + if (row[5] != null) + { + orgaName = row[5].ToString(); + } + sb.Append(String.Format("\"{0}\"", row[0])); + sb.Append(";"); + sb.Append(String.Format("{0:0.00}", row[1])); + sb.Append(";;;"); + string gKonto = GetErlöskonto(orgaName); + sb.Append(String.Format("{0}", gKonto)); //Gegenkonto + sb.Append(";"); + sb.Append(String.Format("{0:yyyyMM}", lastDate)); // Belegnummer JJJJMM + sb.Append(";;"); + sb.Append(String.Format("{0:ddMMyyyy}", lastDate)); //Simba nimmt nur Buchungen an, ReDatum = Abrechnungszeitraum + sb.Append(";;"); + sb.Append(String.Format("{0}", row[3])); // Debitornummer Orga + sb.Append(";"); + string costcenter = GetKostenstelle(orgaName); + sb.Append(String.Format("{0}", costcenter)); // Kostenstelle Organisation + sb.Append(";;;"); + sb.Append(String.Format("\"{0}\"", row[6])); + sb.Append(";\"EUR\";;;;;;;;;;"); + //sb.Append(String.Format("{0}", row[3])); + sb.Append(";;;;;"); // bei Rechnungen kommt hier noch der Beleg als PDF + } + return sb.ToString(); + } + + private static string GetErlöskonto(string orgaName) + { + if (orgaName.Contains("LWL") || orgaName.Contains("Landschaftsverband Rheinland") || orgaName.Contains("LVR")) + { + return "8030"; + } + else if (orgaName.Contains("Stadt Essen")) + { + return "8020"; + } + else if (orgaName == "CSE") + { + return "8090"; + } + else + { + return "8030"; + } + } + + private static string GetKostenstelle(string orgaName) + { + if (orgaName.Contains("Jugendamt Stadt Essen")) + { + return "34"; + } + else if (orgaName == "CSE") + { + return "33"; + } + else + { + return "32"; + } + } + + private static String GetMonatlicheBetraegeLvrLwlSql(DateTime date) + { + String sql = @" + SELECT + 'BCH', + sum(qry.Betrag) AS Betrag, + '8020' as 'Gegenkonto', + qry.DebitorNumber, + qry.CostCenter, + qry.Name, + qry.Verwendung, + qry.Oid, + sum(qry.FLS) AS FLS, + qry.Preis + FROM + ( + (SELECT + IF(crpRateFactor.`CostRateValue` is null, ROUND((sr.`GeleisteteFLM` / 60) * (SELECT crp.`CostRateValue` FROM `costrateperiod` crp WHERE crp.`ObjectTid` = 22 AND crp.`CostRateType` = 0 AND crp.`ObjectOid` = cb2sc.`CostBearerOid` AND (crp.`EndDate` is null or crp.`EndDate` > ':Monat_Start') order by IF(crp.`EndDate` is null, MAKEDATE(9999,365),crp.`EndDate`) LIMIT 1 )), + ROUND(ROUND((sr.`GeleisteteFLM` / 60), 2) * (SELECT crp.`CostRateValue` FROM `costrateperiod` crp WHERE crp.`ObjectTid` = 22 AND crp.`CostRateType` = 0 AND crp.`ObjectOid` = cb2sc.`CostBearerOid` AND (crp.`EndDate` is null or crp.`EndDate` > ':Monat_Start') order by IF(crp.`EndDate` is null, MAKEDATE(9999,365),crp.`EndDate`) LIMIT 1 ) * ((100 + crpRateFactor.`CostRateValue`)/100), 2)) AS 'Betrag', + org.DebitorNumber, + c.CostCenter, + org.Name, + CONCAT(org.Name,', ', p.`LastName`, ', ', p.`FirstName`) as 'Verwendung', + cb2sc.Oid, + ROUND(sr.`GeleisteteFLM` / 60, 2) as 'FLS', + ROUND((SELECT crp.`CostRateValue` FROM `costrateperiod` crp WHERE crp.`ObjectTid` = 22 AND crp.`CostRateType` = 0 AND crp.`ObjectOid` = cb2sc.`CostBearerOid` AND (crp.`EndDate` is null or crp.`EndDate` > ':Monat_Start') order by IF(crp.`EndDate` is null, MAKEDATE(9999,365),crp.`EndDate`) LIMIT 1 ), 2) as 'Preis' + FROM `supportconcept` sc + INNER JOIN `costbearer2supportconcept` cb2sc ON sc.`Oid` = cb2sc.`SupportConceptOid` + INNER JOIN `costbearer` cb ON cb2sc.`CostBearerOid` = cb.`Oid` + LEFT JOIN + (SELECT crp.`ObjectOid`, crp.`CostRateValue` FROM `costrateperiod` crp + WHERE crp.`ObjectTid` = 22 AND crp.`CostRateType` = 2 AND (crp.`EndDate` is null or crp.`EndDate` > NOW())) + AS crpRateFactor ON crpRateFactor.`ObjectOid` = cb.`Oid` + INNER JOIN `organisation` org ON org.`CostBearerOid` = cb.`Oid` + INNER JOIN `customer` c ON sc.`CustomerOid` = c.`Oid` + INNER JOIN `person` p on c.`PersonOid` = p.`Oid` + LEFT JOIN + (SELECT sr2.`CostBearer2SupportConceptOid`, SUM(sr2.`roundedduration` / IF(sr2.`GroupEmployeeCount` is null, 1, sr2.`GroupEmployeeCount`)) AS GeleisteteFLM FROM `servicerecord` sr2 + INNER JOIN `servicedescription` sd ON sr2.`ServiceDescriptionOid` = sd.`Oid` + INNER JOIN `servicecategory` sc ON sd.`ServiceCategoryOid` = sc.`Oid` + WHERE sr2.`StartDate` >= ':Monat_Start' AND sr2.`StartDate` < ':Monat_End' AND sc.`Billable` = 1 and sd.Name <> 'Fehlkontakt' GROUP BY sr2.`CostBearer2SupportConceptOid`) + AS sr ON sr.`CostBearer2SupportConceptOid` = cb2sc.`Oid` + WHERE c.`IsActive` = 1 AND sc.`IsActive` = 1 and (sr.`GeleisteteFLM` is not null) and (org.Name = 'Landschaftsverband Rheinland Dez 7' OR org.Name = 'LWL')) + UNION + (SELECT + ROUND(0.8 * (sr.`GeleisteteFLM` / 60) * (SELECT crp.`CostRateValue` FROM `costrateperiod` crp WHERE crp.`ObjectTid` = 22 AND crp.`CostRateType` = 0 AND crp.`ObjectOid` = cb2sc.`CostBearerOid` AND (crp.`EndDate` is null or crp.`EndDate` > ':Monat_Start') order by IF(crp.`EndDate` is null, MAKEDATE(9999,365),crp.`EndDate`) LIMIT 1 )) AS 'Betrag', + org.DebitorNumber, + c.CostCenter, + org.Name, + CONCAT(org.Name,', ', p.`LastName`, ', ', p.`FirstName`) as 'Verwendung', + cb2sc.Oid, + ROUND(0.8 * sr.`GeleisteteFLM` / 60, 2) as 'FLS', + ROUND((SELECT crp.`CostRateValue` FROM `costrateperiod` crp WHERE crp.`ObjectTid` = 22 AND crp.`CostRateType` = 0 AND crp.`ObjectOid` = cb2sc.`CostBearerOid` AND (crp.`EndDate` is null or crp.`EndDate` > ':Monat_Start') order by IF(crp.`EndDate` is null, MAKEDATE(9999,365),crp.`EndDate`) LIMIT 1 ), 2) as 'Preis' + FROM `supportconcept` sc + INNER JOIN `costbearer2supportconcept` cb2sc ON sc.`Oid` = cb2sc.`SupportConceptOid` + INNER JOIN `costbearer` cb ON cb2sc.`CostBearerOid` = cb.`Oid` + INNER JOIN `organisation` org ON org.`CostBearerOid` = cb.`Oid` + INNER JOIN `customer` c ON sc.`CustomerOid` = c.`Oid` + INNER JOIN `person` p on c.`PersonOid` = p.`Oid` + LEFT JOIN + (SELECT sr2.`CostBearer2SupportConceptOid`, SUM(sr2.`roundedduration` / IF(sr2.`GroupEmployeeCount` is null, 1, sr2.`GroupEmployeeCount`)) AS GeleisteteFLM FROM `servicerecord` sr2 + INNER JOIN `servicedescription` sd ON sr2.`ServiceDescriptionOid` = sd.`Oid` + INNER JOIN `servicecategory` sc ON sd.`ServiceCategoryOid` = sc.`Oid` + WHERE sr2.`StartDate` >= ':Monat_Start' AND sr2.`StartDate` < ':Monat_End' AND sc.`Billable` = 1 and sd.Name = 'Fehlkontakt' GROUP BY sr2.`CostBearer2SupportConceptOid`) + AS sr ON sr.`CostBearer2SupportConceptOid` = cb2sc.`Oid` + WHERE c.`IsActive` = 1 AND sc.`IsActive` = 1 and (sr.`GeleisteteFLM` is not null) and (org.Name = 'Landschaftsverband Rheinland Dez 7' OR org.Name = 'LWL')) + )qry + GROUP BY qry.OID + ORDER BY qry.Verwendung + "; + + return sql; + } + + public static String GetMonatlicheRechnungenString(DateTime date, DataTable dt) + { + /* 'BCH', sip.Claim, '8106' as 'Gegenkonto', ib.invoicenumber, ib.InvoiceDate, org.DebitorNumber, '3170', org.Name, p.FirstName, p.LastName*/ + StringBuilder sb = new StringBuilder(); + foreach (DataRow row in dt.Rows) + { + if (sb.Length > 0) + { + sb.AppendLine(); + } + DateTime lastDate = new DateTime(date.Year, date.Month, 1); + lastDate = lastDate.AddMonths(1).AddDays(-1); + string orgaName = ""; + if (row[7] != null) + { + orgaName = row[7].ToString(); + } + + sb.Append(String.Format("\"{0}\"", row[0])); + sb.Append(";"); + sb.Append(String.Format("{0:0.00}", row[1])); + sb.Append(";;;"); + string gKonto = GetErlöskonto(orgaName); + sb.Append(String.Format("{0}", gKonto)); //Gegenkonto + sb.Append(";"); + sb.Append(String.Format("{0}", row[3])); + sb.Append(";;"); + sb.Append(String.Format("{0:ddMMyyyy}", lastDate)); //Simba nimmt nur Buchungen an, ReDatum = Abrechnungszeitraum + //sb.Append(String.Format("{0:ddMMyyyy}", row[4])); + sb.Append(";;"); + sb.Append(String.Format("{0}", row[5])); // Debitornummer Orga + sb.Append(";"); + string costcenter = GetKostenstelle(orgaName); + sb.Append(String.Format("{0}", costcenter)); // Kostenstelle Organisation + sb.Append(";;;"); + sb.Append(String.Format("\"{0}, {1} {2}\"", row[7], row[8], row[9])); + sb.Append(";\"EUR\";;;;;;;;;;"); + sb.Append(String.Format("{0}", row[3])); + sb.Append(";;;;"); + sb.Append(String.Format("\"Rechnung {0}.pdf\"", row[3])); + } + return sb.ToString(); + } + + private static List CreateInvoiceFiles(DataTable dt) + { + try + { + List liste = new List(); + foreach (DataRow row in dt.Rows) + { + var pdf = new FileAttachmentDC(); + + var invoiceOid = row[10].ToString(); + if (!String.IsNullOrEmpty(invoiceOid)) + { + var oid = long.Parse(invoiceOid); + var invoice = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(oid); + //var invoice = DAOFactory.GenericDAO.LoadByID(oid); + var idc = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(invoice); + var ro = ServiceInvoiceRO.Create(idc); + + if (idc.InvoiceBase.RecipientOrganisation == "Landschaftsverband Rheinland" || idc.InvoiceBase.RecipientOrganisation.Contains("Amt für Soziales ")) + { + var anhang = new Rechnung67(); + anhang.SetReportDataSource(ro); + anhang.CreateDocument(); + pdf.FileName = anhang.PrintingSystem.Document.Name + ".pdf"; + using (var ms = new MemoryStream()) + { + anhang.ExportToPdf(ms); + pdf.BinaryData = ms.ToArray(); + } + liste.Add(pdf); + } + else + { + var anhang = new RechnungFlex(); + anhang.SetReportDataSource(ro); + anhang.CreateDocument(); + pdf.FileName = "Rechnung " + ro.InvoiceNumber + ".pdf"; + using (var ms = new MemoryStream()) + { + anhang.ExportToPdf(ms); + pdf.BinaryData = ms.ToArray(); + } + liste.Add(pdf); + } + } + } + return liste; + } + catch (Exception) + { + // continue - auch wenn gar nichts stimmt + } + return null; + } + + private static String GetMonatlicheRechnungenSql(DateTime date) + { + String sql = @" + select + 'BCH', + sip.Claim, + '8030' as 'Gegenkonto', + ib.invoicenumber, + ib.InvoiceDate, + org.DebitorNumber, + '32', + org.Name, + p.FirstName, + p.LastName, + ib.Oid + from + person p + inner join customer c on c.personoid = p.oid + inner join supportconcept sc on sc.customeroid = c.oid + inner join costbearer2supportconcept c2s on c2s.supportconceptoid = sc.oid + inner join costbearer cb on c2s.costbeareroid = cb.oid + inner join organisation org on org.costbeareroid = cb.oid + inner join invoicebase ib on ib.costbearer2supportconceptoid = c2s.oid + inner join serviceinvoice si on si.invoicebaseoid = ib.oid + inner join serviceinvoiceperiod sip on sip.serviceinvoiceoid = si.oid + WHERE ib.`AccountingPeriodEnd` >= ':Monat_Start' AND ib.`AccountingPeriodEnd` < ':Monat_End' and ib.IsActive = 1 + order by ib.invoicenumber + "; + + return sql; + } + + public static DataTable ExecuteQuery(String sql, DateTime dt) + { + var newsql = sql; + newsql = newsql.Replace(":Abrechnungsmonat", String.Format("{0:dd.MM.yyyy}", dt)); + newsql = newsql.Replace(":Belegnr", String.Format("{0:yyMM}", dt)); + newsql = newsql.Replace(":Monat_Start", String.Format("{0:yyyy-MM}-01", dt)); + dt = dt.AddMonths(1); + newsql = newsql.Replace(":Monat_End", String.Format("{0:yyyy-MM}-01", dt)); + + return DAOFactory.AdoDAO.ExecuteQuery(newsql).Tables[0]; + } + } +} \ No newline at end of file diff --git a/ReportImp/BellaDonna/Rechnung67.Designer.cs b/ReportImp/BellaDonna/Rechnung67.Designer.cs index f5f184d6f..1723fbb19 100644 --- a/ReportImp/BellaDonna/Rechnung67.Designer.cs +++ b/ReportImp/BellaDonna/Rechnung67.Designer.cs @@ -54,6 +54,7 @@ namespace BellaDonna this.GroupFooter1 = new DevExpress.XtraReports.UI.GroupFooterBand(); this.xrLabel14 = new DevExpress.XtraReports.UI.XRLabel(); this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); + this.lblRechnungnr = new DevExpress.XtraReports.UI.XRLabel(); ((System.ComponentModel.ISupportInitialize)(this.xrRichText2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrRichText1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit(); @@ -103,6 +104,7 @@ namespace BellaDonna // Page1 // this.Page1.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { + this.lblRechnungnr, this.lblGP, this.xrLabel5, this.xrRichText1, @@ -131,9 +133,9 @@ namespace BellaDonna this.xrLabel5.LocationFloat = new DevExpress.Utils.PointFloat(0F, 259.3611F); this.xrLabel5.Name = "xrLabel5"; this.xrLabel5.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel5.SizeF = new System.Drawing.SizeF(437.9164F, 23F); + this.xrLabel5.SizeF = new System.Drawing.SizeF(99.37471F, 23F); this.xrLabel5.StylePriority.UseTextAlignment = false; - this.xrLabel5.Text = "Rechnungnr.: [InvoiceNumber]"; + this.xrLabel5.Text = "Rechnungnr.:"; // // xrRichText1 // @@ -281,6 +283,15 @@ namespace BellaDonna // this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.ServiceInvoiceRO); // + // lblRechnungnr + // + this.lblRechnungnr.LocationFloat = new DevExpress.Utils.PointFloat(100F, 259.3611F); + this.lblRechnungnr.Name = "lblRechnungnr"; + this.lblRechnungnr.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.lblRechnungnr.SizeF = new System.Drawing.SizeF(437.9164F, 23F); + this.lblRechnungnr.StylePriority.UseTextAlignment = false; + this.lblRechnungnr.Text = "[InvoiceNumber]"; + // // Rechnung67 // this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { @@ -301,6 +312,7 @@ namespace BellaDonna this.PageWidth = 827; this.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.A4; this.Version = "23.2"; + this.BeforePrint += new DevExpress.XtraReports.UI.BeforePrintEventHandler(this.ChangeName); ((System.ComponentModel.ISupportInitialize)(this.xrRichText2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.xrRichText1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit(); @@ -333,5 +345,6 @@ namespace BellaDonna private DevExpress.XtraReports.UI.XRLabel xrLabel14; private DevExpress.XtraReports.UI.XRLabel xrLabel5; private DevExpress.XtraReports.UI.XRLabel lblGP; + private DevExpress.XtraReports.UI.XRLabel lblRechnungnr; } } diff --git a/ReportImp/BellaDonna/Rechnung67.cs b/ReportImp/BellaDonna/Rechnung67.cs index 13eb2c6fd..2dc4a3bc3 100644 --- a/ReportImp/BellaDonna/Rechnung67.cs +++ b/ReportImp/BellaDonna/Rechnung67.cs @@ -43,6 +43,7 @@ namespace BellaDonna DateTime start = pRO.AccountingPeriodStart; DateTime end = pRO.AccountingPeriodEnd; + lblRechnungnr.Text = pRO.InvoiceNumber; String text = ""; if (start.Month == end.Month && start.Year == end.Year) @@ -57,5 +58,10 @@ namespace BellaDonna this.bindingSource1.DataSource = pRO; } + + private void ChangeName(object sender, System.ComponentModel.CancelEventArgs e) + { + PrintingSystem.Document.Name = String.Format("Rechnung {0}", lblRechnungnr.Text); + } } } \ No newline at end of file diff --git a/ReportImp/BellaDonna/ServiceInvoiceReport.Designer.cs b/ReportImp/BellaDonna/ServiceInvoiceReport.Designer.cs index c71474627..407598373 100644 --- a/ReportImp/BellaDonna/ServiceInvoiceReport.Designer.cs +++ b/ReportImp/BellaDonna/ServiceInvoiceReport.Designer.cs @@ -42,7 +42,6 @@ namespace BellaDonna this.xrRichText1 = new DevExpress.XtraReports.UI.XRRichText(); this.lblAdresse = new DevExpress.XtraReports.UI.XRLabel(); this.lblBetreff = new DevExpress.XtraReports.UI.XRLabel(); - this.xrLabel2 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel8 = new DevExpress.XtraReports.UI.XRLabel(); this.lblAbrechnungszeitraum = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel15 = new DevExpress.XtraReports.UI.XRLabel(); @@ -55,6 +54,8 @@ namespace BellaDonna this.GroupFooter1 = new DevExpress.XtraReports.UI.GroupFooterBand(); this.xrLabel14 = new DevExpress.XtraReports.UI.XRLabel(); this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); + this.lblRechnungnr = new DevExpress.XtraReports.UI.XRLabel(); + this.xrLabel5 = new DevExpress.XtraReports.UI.XRLabel(); ((System.ComponentModel.ISupportInitialize)(this.xrRichText2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrRichText1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit(); @@ -104,11 +105,12 @@ namespace BellaDonna // Page1 // this.Page1.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { + this.lblRechnungnr, + this.xrLabel5, this.lblGP, this.xrRichText1, this.lblAdresse, this.lblBetreff, - this.xrLabel2, this.xrLabel8, this.lblAbrechnungszeitraum}); this.Page1.HeightF = 504.0834F; @@ -158,21 +160,6 @@ namespace BellaDonna this.lblBetreff.StylePriority.UseFont = false; this.lblBetreff.Text = "##### [CustomerSalutation] [CustomerName], geb. [CustomerBirthdate!dd.MM.yyyy]\r\nA" + "ktenzeichen: [CustomerReferenceNumber]"; - // - // xrLabel2 - // - this.xrLabel2.BackColor = System.Drawing.Color.Transparent; - this.xrLabel2.CanShrink = true; - this.xrLabel2.Font = new DevExpress.Drawing.DXFont("Arial", 11F, DevExpress.Drawing.DXFontStyle.Bold, DevExpress.Drawing.DXGraphicsUnit.Point, new DevExpress.Drawing.DXFontAdditionalProperty[] { - new DevExpress.Drawing.DXFontAdditionalProperty("GdiCharSet", ((byte)(0)))}); - this.xrLabel2.LocationFloat = new DevExpress.Utils.PointFloat(1.059638E-05F, 332.2222F); - this.xrLabel2.Name = "xrLabel2"; - this.xrLabel2.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel2.SizeF = new System.Drawing.SizeF(650F, 20F); - this.xrLabel2.StylePriority.UseBackColor = false; - this.xrLabel2.StylePriority.UseFont = false; - this.xrLabel2.Text = "Rechnung Nr.: [InvoiceNumber]"; - this.xrLabel2.WordWrap = false; // // xrLabel8 // @@ -284,6 +271,30 @@ namespace BellaDonna // this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.ServiceInvoiceRO); // + // lblRechnungnr + // + this.lblRechnungnr.Font = new DevExpress.Drawing.DXFont("Arial", 11F, DevExpress.Drawing.DXFontStyle.Bold, DevExpress.Drawing.DXGraphicsUnit.Point, new DevExpress.Drawing.DXFontAdditionalProperty[] { + new DevExpress.Drawing.DXFontAdditionalProperty("GdiCharSet", ((byte)(0)))}); + this.lblRechnungnr.LocationFloat = new DevExpress.Utils.PointFloat(113.5417F, 332.2222F); + this.lblRechnungnr.Name = "lblRechnungnr"; + this.lblRechnungnr.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.lblRechnungnr.SizeF = new System.Drawing.SizeF(424.3747F, 23F); + this.lblRechnungnr.StylePriority.UseFont = false; + this.lblRechnungnr.StylePriority.UseTextAlignment = false; + this.lblRechnungnr.Text = "[InvoiceNumber]"; + // + // xrLabel5 + // + this.xrLabel5.Font = new DevExpress.Drawing.DXFont("Arial", 11F, DevExpress.Drawing.DXFontStyle.Bold, DevExpress.Drawing.DXGraphicsUnit.Point, new DevExpress.Drawing.DXFontAdditionalProperty[] { + new DevExpress.Drawing.DXFontAdditionalProperty("GdiCharSet", ((byte)(0)))}); + this.xrLabel5.LocationFloat = new DevExpress.Utils.PointFloat(0F, 332.2222F); + this.xrLabel5.Name = "xrLabel5"; + this.xrLabel5.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel5.SizeF = new System.Drawing.SizeF(113.5417F, 23F); + this.xrLabel5.StylePriority.UseFont = false; + this.xrLabel5.StylePriority.UseTextAlignment = false; + this.xrLabel5.Text = "Rechnung Nr.:"; + // // RechnungFlex // this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { @@ -306,6 +317,7 @@ namespace BellaDonna this.Version = "23.2"; xrWatermark1.Id = "Watermark1"; this.Watermarks.Add(xrWatermark1); + this.BeforePrint += new DevExpress.XtraReports.UI.BeforePrintEventHandler(this.ChangeName); ((System.ComponentModel.ISupportInitialize)(this.xrRichText2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.xrRichText1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit(); @@ -322,7 +334,6 @@ namespace BellaDonna private DevExpress.XtraReports.UI.BottomMarginBand bottomMarginBand1; private DevExpress.XtraReports.UI.GroupHeaderBand Page1; private DevExpress.XtraReports.UI.XRLabel lblBetreff; - private DevExpress.XtraReports.UI.XRLabel xrLabel2; private DevExpress.XtraReports.UI.XRLabel xrLabel8; private DevExpress.XtraReports.UI.XRLabel lblAbrechnungszeitraum; private DevExpress.XtraReports.UI.XRLabel xrLabel15; @@ -338,5 +349,7 @@ namespace BellaDonna private DevExpress.XtraReports.UI.XRLabel xrLabel4; private DevExpress.XtraReports.UI.XRLabel xrLabel14; private DevExpress.XtraReports.UI.XRLabel lblGP; + private DevExpress.XtraReports.UI.XRLabel lblRechnungnr; + private DevExpress.XtraReports.UI.XRLabel xrLabel5; } } diff --git a/ReportImp/BellaDonna/ServiceInvoiceReport.cs b/ReportImp/BellaDonna/ServiceInvoiceReport.cs index bf7661af9..a2471af84 100644 --- a/ReportImp/BellaDonna/ServiceInvoiceReport.cs +++ b/ReportImp/BellaDonna/ServiceInvoiceReport.cs @@ -21,6 +21,7 @@ namespace BellaDonna SetzeAdresse(pRO); DateTime start = pRO.AccountingPeriodStart; DateTime end = pRO.AccountingPeriodEnd; + lblRechnungnr.Text = pRO.InvoiceNumber; String text = ""; if (start.Month == end.Month && start.Year == end.Year) @@ -140,5 +141,15 @@ namespace BellaDonna lblAdresse.Text = sb.ToString(); } + + public static implicit operator RechnungFlex(Rechnung67 v) + { + throw new NotImplementedException(); + } + + private void ChangeName(object sender, System.ComponentModel.CancelEventArgs e) + { + PrintingSystem.Document.Name = String.Format("Rechnung {0}", lblRechnungnr.Text); + } } } \ No newline at end of file diff --git a/ReportImp/CaritasverbandDuerenJuelichEV/Invoicing/CustomInvoiceCreation.cs b/ReportImp/CaritasverbandDuerenJuelichEV/Invoicing/CustomInvoiceCreation.cs index 80eb64553..a36e35585 100644 --- a/ReportImp/CaritasverbandDuerenJuelichEV/Invoicing/CustomInvoiceCreation.cs +++ b/ReportImp/CaritasverbandDuerenJuelichEV/Invoicing/CustomInvoiceCreation.cs @@ -64,5 +64,11 @@ namespace CaritasverbandDuerenJuelichEV.Invoicing } return ii; } + + public override void CheckMaxApprovedAmount(ServiceInvoice invoice, ServiceInvoicePeriod sip, SupportConceptApprovalPeriodDC scap, CostBearer2SupportConcept costBearer2SupportConcept, DateTimeSpan invoicePeriod, List serviceRecords) + { + // ab 14.04.2025 kein Check mehr + return; + } } } diff --git a/ReportImp/LebenshilfeRemscheidWohngruppe/Quittierungsbeleg.cs b/ReportImp/LebenshilfeRemscheidWohngruppe/Quittierungsbeleg.cs index 65de49b0e..fe3b53ef3 100644 --- a/ReportImp/LebenshilfeRemscheidWohngruppe/Quittierungsbeleg.cs +++ b/ReportImp/LebenshilfeRemscheidWohngruppe/Quittierungsbeleg.cs @@ -70,6 +70,7 @@ namespace LebenshilfeRemscheidWohngruppe lblHatGruppen.Text = "X"; } + SetzeBewilligungInfos(pRO); ErstelleAbwesenheitenTabelle(pRO); bindingSource1.DataSource = pRO; diff --git a/Service/DCEntityMapper/AbstractIDCEntityMapper.cs b/Service/DCEntityMapper/AbstractIDCEntityMapper.cs index aba334de8..fbc1345f0 100644 --- a/Service/DCEntityMapper/AbstractIDCEntityMapper.cs +++ b/Service/DCEntityMapper/AbstractIDCEntityMapper.cs @@ -1,148 +1,181 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using BeWo.Data.Entities; using BeWo.Service.Core; - +using BS.Shared; using BS.Shared.Extensions; namespace BeWo.Service.DCEntityMapper { - public abstract class AbstractIDCEntityMapper : IDCEntityMapper - where TDC : new() where TEntity : BeWoEntityBase, new() - { - public bool ConcurrencyCheck(long? pDataContractVersion, BeWoEntityBase pEntity) - { - return ServiceLogic.ConcurrencyCheck(pDataContractVersion, pEntity); - } - - public virtual List MapToNewDCs(IEnumerable pEntitys) - { - List lResult = new List(); - if (pEntitys != null) - { - foreach (TEntity iEntity in pEntitys) - { - lResult.Add(this.MergeWithDC(iEntity, CreateNewDC())); - } - } - return lResult; - } - public virtual TDC MapToNewDC(TEntity pEntity, bool ignoreNullEntity) + public abstract class AbstractIDCEntityMapper : IDCEntityMapper + where TDC : new() where TEntity : BeWoEntityBase, new() + { + public bool ConcurrencyCheck(long? pDataContractVersion, BeWoEntityBase pEntity) { - if (ignoreNullEntity || pEntity is object) - return MapToNewDC(pEntity); - - return CreateNewDC(); - } - public virtual TDC MapToNewDC(TEntity pEntity) - { - return MergeWithDC(pEntity, CreateNewDC()); - } - public virtual TDC CreateNewDC() - { - return new TDC(); - } - - public virtual List MapToNewEntities(IEnumerable pDataContracts) - { - List lResult = new List(); - if (pDataContracts != null) - { - foreach (TDC iDataContract in pDataContracts) - { - lResult.Add(this.MergeWithEntity(iDataContract, new TEntity())); - } - } - return lResult; - } - public virtual TEntity MapToNewEntity(TDC pDataContract, bool ignoreNullDC) - { - if (ignoreNullDC || pDataContract is object) - return MergeWithEntity(pDataContract, new TEntity()); - - return CreateNewEntity(); - } - public virtual TEntity MapToNewEntity(TDC pDataContract) - { - return MergeWithEntity(pDataContract, new TEntity()); - } - public virtual TEntity CreateNewEntity() - { - return new TEntity(); - } - - public abstract TDC MergeWithDC(TEntity pEntity, TDC pDataContract); - - public virtual void MergeWithEntitys(IList pDataContractList, IList pEntityList) - { - if (pEntityList.Count == 0 && pDataContractList != null && pDataContractList.Count > 0) - { - pEntityList.AddRange(pDataContractList.Select(dc => this.MapToNewEntity(dc))); - return; - } - - if (pDataContractList == null || pDataContractList.Count == 0) - { - pEntityList.Clear(); - return; - } - - // remove deleted - pEntityList.RemoveRange(entity => pDataContractList.Count(dc => this.AreDCAndEntityEqual(dc, entity)) == 0); - - // merge same - var lToMerge = pEntityList.Select(entity => new { Entity = entity, DataContract = pDataContractList.Single(dc => this.AreDCAndEntityEqual(dc, entity)) }); - - foreach (var iToMerge in lToMerge) - { - MergeWithEntity(iToMerge.DataContract, iToMerge.Entity); - } - - // add new - List newList = new List(); - - foreach (TDC dc in pDataContractList) - { - bool isnew = true; - foreach (TEntity entity in pEntityList) - { - if (isnew && AreDCAndEntityEqual(dc, entity)) - { - isnew = false; - } - } - if (isnew) - newList.Add(dc); - } - - foreach (TDC newDC in newList) - { - pEntityList.Add(MapToNewEntity(newDC)); - } - - //pEntityList.AddRange( - // pDataContractList - // .Where(dc => pEntityList - // .Count(entity => AreDCAndEntityEqual(dc, entity)) == 0) - // .Select(dc => MapToNewEntity(dc))); - - } - public virtual TEntity MergeWithEntity(TDC pDataContract, TEntity pEntity, bool ignoreNullDC) - { - if (ignoreNullDC || pDataContract is object) - { - if (pEntity is null) - pEntity = CreateNewEntity(); - - return MergeWithEntity(pDataContract, pEntity); - } - - return null; + return ServiceLogic.ConcurrencyCheck(pDataContractVersion, pEntity); } - public abstract TEntity MergeWithEntity(TDC pDataContract, TEntity pEntity); - protected abstract bool AreDCAndEntityEqual(TDC pDC, TEntity pEntity); - } + public virtual List MapToNewDCs(IEnumerable pEntitys) + { + List lResult = new List(); + if (pEntitys != null) + { + foreach (TEntity iEntity in pEntitys) + { + lResult.Add(this.MergeWithDC(iEntity, CreateNewDC())); + } + } + return lResult; + } + public virtual TDC MapToNewDC(TEntity pEntity, bool ignoreNullEntity) + { + if (ignoreNullEntity || pEntity is object) + return MapToNewDC(pEntity); + + return CreateNewDC(); + } + public virtual TDC MapToNewDC(TEntity pEntity) + { + return MergeWithDC(pEntity, CreateNewDC()); + } + public virtual TDC CreateNewDC() + { + return new TDC(); + } + + public virtual List MapToNewEntities(IEnumerable pDataContracts) + { + List lResult = new List(); + if (pDataContracts != null) + { + foreach (TDC iDataContract in pDataContracts) + { + lResult.Add(this.MergeWithEntity(iDataContract, new TEntity())); + } + } + return lResult; + } + public virtual TEntity MapToNewEntity(TDC pDataContract, bool ignoreNullDC) + { + if (ignoreNullDC || pDataContract is object) + return MergeWithEntity(pDataContract, new TEntity()); + + return CreateNewEntity(); + } + public virtual TEntity MapToNewEntity(TDC pDataContract) + { + return MergeWithEntity(pDataContract, new TEntity()); + } + public virtual TEntity CreateNewEntity() + { + return new TEntity(); + } + + public abstract TDC MergeWithDC(TEntity pEntity, TDC pDataContract); + + public virtual void MergeWithEntitys(IList pDataContractList, IList pEntityList) + { + if (pEntityList.Count == 0 && pDataContractList != null && pDataContractList.Count > 0) + { + pEntityList.AddRange(pDataContractList.Select(dc => this.MapToNewEntity(dc))); + return; + } + + if (pDataContractList == null || pDataContractList.Count == 0) + { + pEntityList.Clear(); + return; + } + + // remove deleted + pEntityList.RemoveRange(entity => pDataContractList.Count(dc => this.AreDCAndEntityEqual(dc, entity)) == 0); + + // merge same + var lToMerge = pEntityList.Select(entity => new { Entity = entity, DataContract = pDataContractList.Single(dc => this.AreDCAndEntityEqual(dc, entity)) }); + + foreach (var iToMerge in lToMerge) + { + MergeWithEntity(iToMerge.DataContract, iToMerge.Entity); + } + + // add new + List newList = new List(); + + foreach (TDC dc in pDataContractList) + { + bool isnew = true; + foreach (TEntity entity in pEntityList) + { + if (isnew && AreDCAndEntityEqual(dc, entity)) + { + isnew = false; + } + } + if (isnew) + newList.Add(dc); + } + + foreach (TDC newDC in newList) + { + pEntityList.Add(MapToNewEntity(newDC)); + } + + //pEntityList.AddRange( + // pDataContractList + // .Where(dc => pEntityList + // .Count(entity => AreDCAndEntityEqual(dc, entity)) == 0) + // .Select(dc => MapToNewEntity(dc))); + + } + public virtual TEntity MergeWithEntity(TDC pDataContract, TEntity pEntity, bool ignoreNullDC) + { + if (ignoreNullDC || pDataContract is object) + { + if (pEntity is null) + pEntity = CreateNewEntity(); + + return MergeWithEntity(pDataContract, pEntity); + } + + return null; + } + public abstract TEntity MergeWithEntity(TDC pDataContract, TEntity pEntity); + + protected abstract bool AreDCAndEntityEqual(TDC pDC, TEntity pEntity); + + public virtual Dictionary ToJsonDictionary(TDC pDC) + { + throw new NotImplementedException("ToJsonDictionary"); + } + + public Dictionary ToJsonDictionary(TEntity pEntity) + { + var dc = MapToNewDC(pEntity); + var dict = ToJsonDictionary(dc); + return dict; + } + + public IList> ToJsonDictionary(IList pEntities) + { + var dcs = MapToNewDCs(pEntities); + var dicts = ToJsonDictionary(dcs); + return dicts; + } + + public IList> ToJsonDictionary(IList pDCs) + { + var dicts = new List>(); + + if (pDCs == null) + return dicts; + + foreach (var dc in pDCs) + dicts.Add(ToJsonDictionary(dc)); + + return dicts; + } + } } \ No newline at end of file diff --git a/Service/DCEntityMapper/AiConfigDC_AiConfig.cs b/Service/DCEntityMapper/AiConfigDC_AiConfig.cs new file mode 100644 index 000000000..04fa46820 --- /dev/null +++ b/Service/DCEntityMapper/AiConfigDC_AiConfig.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using System.Linq; + +using BeWo.Data.Access; +using BeWo.Data.Entities; + +using BS.Shared; +using BS.Shared.Core; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Feature.AI; + +namespace BeWo.Service.DCEntityMapper +{ + public class AiConfigDC_AiConfig : AbstractIDCEntityMapper + { + public override AiConfigDC MergeWithDC(AiConfig pEntity, AiConfigDC pDataContract) + { + pDataContract.Oid = pEntity.Oid; + pDataContract.Version = pEntity.Version; + pDataContract.Notice = pEntity.Notice; + pDataContract.Temperature = pEntity.Temperature; + pDataContract.Top_P = pEntity.Top_P; + pDataContract.Max_Gen_Len = pEntity.Max_Gen_Len; + + pDataContract.SelectedModel = MapperFactory.AiModel.MapToNewDC(pEntity.SelectedModel); + + return pDataContract; + } + + public override AiConfig MergeWithEntity(AiConfigDC pDataContract, AiConfig pEntity) + { + ConcurrencyCheck(pDataContract.Version, pEntity); + + pEntity.Oid = pDataContract.Oid; + pEntity.Version = pDataContract.Version; + pEntity.Notice = pDataContract.Notice; + pEntity.Temperature = pDataContract.Temperature; + pEntity.Top_P = pDataContract.Top_P; + pEntity.Max_Gen_Len = pDataContract.Max_Gen_Len; + + if (pDataContract.SelectedModel?.Oid is long oid) + pEntity.SelectedModel = DAOFactory.GenericDAO.LoadByID(oid); + else + pEntity.SelectedModel = null; + + return pEntity; + } + + protected override bool AreDCAndEntityEqual(AiConfigDC pDC, AiConfig pEntity) + { + throw new System.NotImplementedException(); + } + } +} diff --git a/Service/DCEntityMapper/AiConversationDC_AiConversation.cs b/Service/DCEntityMapper/AiConversationDC_AiConversation.cs new file mode 100644 index 000000000..306002822 --- /dev/null +++ b/Service/DCEntityMapper/AiConversationDC_AiConversation.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using BeWo.Data.Access; +using BeWo.Data.Entities; + +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 +{ + public class AiConversationDC_AiConversation : AbstractIDCEntityMapper + { + public override AiConversationDC MergeWithDC(AiConversation pEntity, AiConversationDC pDataContract) + { + pDataContract.Oid = pEntity.Oid; + pDataContract.Version = pEntity.Version; + pDataContract.Notice = pEntity.Notice; + pDataContract.Displayname = pEntity.Displayname; + pDataContract.Created = pEntity.Created; + pDataContract.Updated = pEntity.Updated; + pDataContract.Context = pEntity.Context; + pDataContract.ContextBeWoObjects = Parse(pEntity.ContextBeWoObjects); + pDataContract.UIContext = pEntity.UIContext; + + if (pEntity.Messages is IList list && list.Any()) + pDataContract.Messages = MapperFactory.AiConversationMessage.MapToNewDCs(list); + + if (pEntity.Modell is AiModel model) + pDataContract.Modell = MapperFactory.AiModel.MapToNewDC(model); + + return pDataContract; + } + + public override AiConversation MergeWithEntity(AiConversationDC pDataContract, AiConversation pEntity) + { + throw new NotImplementedException(); + + ConcurrencyCheck(pDataContract.Version, pEntity); + + //pEntity.Oid = pDataContract.Oid; + //pEntity.Version = pDataContract.Version; + pEntity.Notice = pDataContract.Notice; + pEntity.Displayname = pDataContract.Displayname; + pEntity.Created = pDataContract.Created; + pEntity.Updated = pDataContract.Updated; + pEntity.Context = pDataContract.Context; + pEntity.UIContext = pDataContract.UIContext; + pEntity.ContextBeWoObjects = Parse(pDataContract.ContextBeWoObjects); + + MapperFactory.AiConversationMessage.MergeWithEntitys(pDataContract.Messages, pEntity.Messages); + + if (pDataContract.Modell?.Oid is long oid) + pEntity.Modell = DAOFactory.GenericDAO.LoadByID(oid); + + return pEntity; + } + + protected override bool AreDCAndEntityEqual(AiConversationDC pDC, AiConversation pEntity) + { + 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/DCEntityMapper/AiConversationMessageDC_AiConversationMessage.cs b/Service/DCEntityMapper/AiConversationMessageDC_AiConversationMessage.cs new file mode 100644 index 000000000..108da0350 --- /dev/null +++ b/Service/DCEntityMapper/AiConversationMessageDC_AiConversationMessage.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using BeWo.Data.Access; +using BeWo.Data.Entities; + +using BS.Shared; +using BS.Shared.Core; +using BS.Shared.DataContracts; + +namespace BeWo.Service.DCEntityMapper +{ + public class AiConversationMessageDC_AiConversationMessage : AbstractIDCEntityMapper + { + public override AiConversationMessageDC MergeWithDC(AiConversationMessage pEntity, AiConversationMessageDC pDataContract) + { + pDataContract.Oid = pEntity.Oid; + pDataContract.Version = pEntity.Version; + pDataContract.Notice = pEntity.Notice; + pDataContract.Message = pEntity.Message; + pDataContract.Role = pEntity.Role; + pDataContract.Created = pEntity.Created; + pDataContract.Duration = pEntity.Duration; + pDataContract.ModelName = pEntity.ModelName; + + return pDataContract; + } + + public override AiConversationMessage MergeWithEntity(AiConversationMessageDC pDataContract, AiConversationMessage pEntity) + { + throw new InvalidOperationException(); + + ConcurrencyCheck(pDataContract.Version, pEntity); + + pEntity.Oid = pDataContract.Oid; + pEntity.Version = pDataContract.Version; + pEntity.Notice = pDataContract.Notice; + pEntity.Message = pDataContract.Message; + pEntity.Role = pDataContract.Role; + pEntity.Created = pDataContract.Created; + pEntity.Duration = pDataContract.Duration; + pEntity.ModelName = pDataContract.ModelName; + + return pEntity; + } + + protected override bool AreDCAndEntityEqual(AiConversationMessageDC pDC, AiConversationMessage pEntity) + { + throw new System.NotImplementedException(); + } + } +} diff --git a/Service/DCEntityMapper/AiModelDC_AiModel.cs b/Service/DCEntityMapper/AiModelDC_AiModel.cs new file mode 100644 index 000000000..c604ac3a0 --- /dev/null +++ b/Service/DCEntityMapper/AiModelDC_AiModel.cs @@ -0,0 +1,45 @@ +using System.Collections.Generic; +using System.Linq; + +using BeWo.Data.Access; +using BeWo.Data.Entities; + +using BS.Shared; +using BS.Shared.Core; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Feature.AI; + +namespace BeWo.Service.DCEntityMapper +{ + public class AiModelDC_AiModel : AbstractIDCEntityMapper + { + public override AiModelDC MergeWithDC(AiModel pEntity, AiModelDC pDataContract) + { + pDataContract.Oid = pEntity.Oid; + pDataContract.Version = pEntity.Version; + pDataContract.Notice = pEntity.Notice; + pDataContract.ModelName = pEntity.ModelName; + pDataContract.Value = pEntity.Value; + + return pDataContract; + } + + public override AiModel MergeWithEntity(AiModelDC pDataContract, AiModel pEntity) + { + ConcurrencyCheck(pDataContract.Version, pEntity); + + pEntity.Oid = pDataContract.Oid; + pEntity.Version = pDataContract.Version; + pEntity.Notice = pDataContract.Notice; + pEntity.ModelName = pDataContract.ModelName; + pEntity.Value = pDataContract.Value; + + return pEntity; + } + + protected override bool AreDCAndEntityEqual(AiModelDC pDC, AiModel pEntity) + { + throw new System.NotImplementedException(); + } + } +} diff --git a/Service/DCEntityMapper/CompactCustomerDC_Customer.cs b/Service/DCEntityMapper/CompactCustomerDC_Customer.cs index a62031db1..d7d80097d 100644 --- a/Service/DCEntityMapper/CompactCustomerDC_Customer.cs +++ b/Service/DCEntityMapper/CompactCustomerDC_Customer.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using BeWo.Data.Access; using BeWo.Data.Entities; @@ -67,5 +68,21 @@ namespace BeWo.Service.DCEntityMapper { return pDC.CustomerOid == pEntity.Oid; } - } + + public override Dictionary ToJsonDictionary(CompactCustomerDC customer) + { + var record_dict = new Dictionary + { + {"Address", customer.AddressString}, + {"Alias", customer.CustomerAlias}, + {"CustomerOid", customer.CustomerOid}, + {"DateOfBirth", customer.DateOfBirthString}, + {"EqutyContribution", customer.EquityContribution}, + {"Fullname", customer.FullName}, + {"InvoiceAddress", customer.InvoiceAddressString} + }; + + return record_dict; + } + } } \ No newline at end of file diff --git a/Service/DCEntityMapper/CompactEmployeeDC_Employee.cs b/Service/DCEntityMapper/CompactEmployeeDC_Employee.cs index bc84033e4..34d1244fb 100644 --- a/Service/DCEntityMapper/CompactEmployeeDC_Employee.cs +++ b/Service/DCEntityMapper/CompactEmployeeDC_Employee.cs @@ -2,37 +2,49 @@ using BeWo.Data.Entities; using System.Linq; using BS.Shared.DataContracts.Compact; +using System.Collections.Generic; namespace BeWo.Service.DCEntityMapper { - public class CompactEmployeeDC_Employee : AbstractIDCEntityMapper - { - public override CompactEmployeeDC MergeWithDC(Employee pEntity, CompactEmployeeDC pDataContract) - { - pDataContract.EmployeeOid = pEntity.Oid.Value; - pDataContract.PersonOid = pEntity.Person.Oid.Value; - pDataContract.EmployeeVersion = pEntity.Version.Value; - pDataContract.FirstName = pEntity.Person.FirstName; - pDataContract.LastName = pEntity.Person.LastName; - pDataContract.PersonnelNumber = pEntity.PersonnelNumber; - //pDataContract.FLSPerWeek = pEntity.WeeklyFLS; - pDataContract.ActivationType = pEntity.IsActive; - pDataContract.ValueListEntries = pEntity.ValueList.ToDictionary(i => i.Entry.Oid.Value, i => i.Entry.Type); - pDataContract.EmployeeColor = pEntity.EmployeeColor; - pDataContract.RelatedCustomerOIDList = pEntity.Employee2CustomerList.Where(w => w.CustomerOid.HasValue).Select(s => s.CustomerOid.Value).ToList(); + public class CompactEmployeeDC_Employee : AbstractIDCEntityMapper + { + public override CompactEmployeeDC MergeWithDC(Employee pEntity, CompactEmployeeDC pDataContract) + { + pDataContract.EmployeeOid = pEntity.Oid.Value; + pDataContract.PersonOid = pEntity.Person.Oid.Value; + pDataContract.EmployeeVersion = pEntity.Version.Value; + pDataContract.FirstName = pEntity.Person.FirstName; + pDataContract.LastName = pEntity.Person.LastName; + pDataContract.PersonnelNumber = pEntity.PersonnelNumber; + //pDataContract.FLSPerWeek = pEntity.WeeklyFLS; + pDataContract.ActivationType = pEntity.IsActive; + pDataContract.ValueListEntries = pEntity.ValueList.ToDictionary(i => i.Entry.Oid.Value, i => i.Entry.Type); + pDataContract.EmployeeColor = pEntity.EmployeeColor; + pDataContract.RelatedCustomerOIDList = pEntity.Employee2CustomerList.Where(w => w.CustomerOid.HasValue).Select(s => s.CustomerOid.Value).ToList(); - return pDataContract; - } + return pDataContract; + } - // COMPACT EMPLOYEES ARE NOT EDITABLE - public override Employee MergeWithEntity(CompactEmployeeDC pDataContract, Employee pEntity) - { - return DAOFactory.GenericDAO.LoadByID(pDataContract.EmployeeOid); - } + // COMPACT EMPLOYEES ARE NOT EDITABLE + public override Employee MergeWithEntity(CompactEmployeeDC pDataContract, Employee pEntity) + { + return DAOFactory.GenericDAO.LoadByID(pDataContract.EmployeeOid); + } - protected override bool AreDCAndEntityEqual(CompactEmployeeDC pDC, Employee pEntity) - { - return pDC.EmployeeOid == pEntity.Oid; - } - } + protected override bool AreDCAndEntityEqual(CompactEmployeeDC pDC, Employee pEntity) + { + return pDC.EmployeeOid == pEntity.Oid; + } + + public override Dictionary ToJsonDictionary(CompactEmployeeDC pDC) + { + var dict = new Dictionary() + { + {"PersonellNumber", pDC.PersonnelNumber }, + {"FullName", pDC.FirstNameLastName }, + }; + + return dict; + } + } } \ No newline at end of file diff --git a/Service/DCEntityMapper/CompactPersonDC_Person.cs b/Service/DCEntityMapper/CompactPersonDC_Person.cs index 0d9dbd7cb..9baa325f3 100644 --- a/Service/DCEntityMapper/CompactPersonDC_Person.cs +++ b/Service/DCEntityMapper/CompactPersonDC_Person.cs @@ -1,63 +1,80 @@ using BeWo.Data.Entities; using BS.Shared.DataContracts.Compact; +using System.Collections.Generic; namespace BeWo.Service.DCEntityMapper { - public class CompactPersonDC_Person : AbstractIDCEntityMapper - { - public override CompactPersonDC MergeWithDC(Person pEntity, CompactPersonDC pDataContract) - { - pDataContract.DateOfBirth = pEntity.DateOfBirth; - pDataContract.FirstName = pEntity.FirstName; - pDataContract.LastName = pEntity.LastName; - pDataContract.PersonOid = pEntity.Oid.Value; - pDataContract.PersonVersion = pEntity.Version.Value; - pDataContract.ActivationType = pEntity.IsActive; - pDataContract.PersonType = pEntity.Type; - pDataContract.FamilyStatus = pEntity.FamilyStatus; - pDataContract.Geschlecht = pEntity.Sex; + public class CompactPersonDC_Person : AbstractIDCEntityMapper + { + public override CompactPersonDC MergeWithDC(Person pEntity, CompactPersonDC pDataContract) + { + pDataContract.DateOfBirth = pEntity.DateOfBirth; + pDataContract.FirstName = pEntity.FirstName; + pDataContract.LastName = pEntity.LastName; + pDataContract.PersonOid = pEntity.Oid.Value; + pDataContract.PersonVersion = pEntity.Version.Value; + pDataContract.ActivationType = pEntity.IsActive; + pDataContract.PersonType = pEntity.Type; + pDataContract.FamilyStatus = pEntity.FamilyStatus; + pDataContract.Geschlecht = pEntity.Sex; - if (pEntity.Title != null) - { - pDataContract.Title = pEntity.Title.Value; - } + if (pEntity.Title != null) + { + pDataContract.Title = pEntity.Title.Value; + } - if (pEntity.Function != null) - { - pDataContract.Function = pEntity.Function.Value; - } + if (pEntity.Function != null) + { + pDataContract.Function = pEntity.Function.Value; + } - if (pEntity.Address != null) - { - pDataContract.Street = pEntity.Address.Street; - pDataContract.PostalCode = pEntity.Address.PostalCode; - pDataContract.Town = pEntity.Address.Town; - } + if (pEntity.Address != null) + { + pDataContract.Street = pEntity.Address.Street; + pDataContract.PostalCode = pEntity.Address.PostalCode; + pDataContract.Town = pEntity.Address.Town; + } - pDataContract.OrganisationRelations = MapperFactory.Organisation2PersonDC_Organisation2Person.MapToNewDCs(pEntity.Organisation2Persons); + pDataContract.OrganisationRelations = MapperFactory.Organisation2PersonDC_Organisation2Person.MapToNewDCs(pEntity.Organisation2Persons); - return pDataContract; - } + return pDataContract; + } - public override Person MergeWithEntity(CompactPersonDC pDataContract, Person pEntity) - { - this.ConcurrencyCheck(pDataContract.PersonVersion, pEntity); + public override Person MergeWithEntity(CompactPersonDC pDataContract, Person pEntity) + { + this.ConcurrencyCheck(pDataContract.PersonVersion, pEntity); - pEntity.Oid = pDataContract.PersonOid; - pEntity.DateOfBirth = pDataContract.DateOfBirth; - pEntity.FirstName = pDataContract.FirstName; - pEntity.LastName = pDataContract.LastName; - pEntity.IsActive = pDataContract.ActivationType; + pEntity.Oid = pDataContract.PersonOid; + pEntity.DateOfBirth = pDataContract.DateOfBirth; + pEntity.FirstName = pDataContract.FirstName; + pEntity.LastName = pDataContract.LastName; + pEntity.IsActive = pDataContract.ActivationType; - MapperFactory.Organisation2PersonDC_Organisation2Person.MergeWithEntitys(pDataContract.OrganisationRelations, pEntity.Organisation2Persons); + MapperFactory.Organisation2PersonDC_Organisation2Person.MergeWithEntitys(pDataContract.OrganisationRelations, pEntity.Organisation2Persons); - return pEntity; - } + return pEntity; + } - protected override bool AreDCAndEntityEqual(CompactPersonDC pDC, Person pEntity) - { - return pDC.PersonOid == pEntity.Oid; - } - } + protected override bool AreDCAndEntityEqual(CompactPersonDC pDC, Person pEntity) + { + return pDC.PersonOid == pEntity.Oid; + } + + public override Dictionary ToJsonDictionary(CompactPersonDC pDC) + { + var jsonObject = new Dictionary() + { + {"Address", pDC.AddressString }, + {"DateOfBirth", pDC.Birthday }, + {"CustomerOid", pDC.CustomerOid }, + {"EmployeeOid", pDC.EmployeeOid }, + { "FullName", pDC.FullName }, + {"Gender", pDC.Geschlecht.ToString() }, + {"Function", pDC.Function }, + }; + + return jsonObject; + } + } } \ No newline at end of file diff --git a/Service/DCEntityMapper/IDCEntityMapper.cs b/Service/DCEntityMapper/IDCEntityMapper.cs index 4a089fffe..fda5ef580 100644 --- a/Service/DCEntityMapper/IDCEntityMapper.cs +++ b/Service/DCEntityMapper/IDCEntityMapper.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using BeWo.Data.Entities; @@ -18,5 +19,10 @@ namespace BeWo.Service.DCEntityMapper TDC MergeWithDC(TEntity pEntity, TDC pDataContract); TEntity MergeWithEntity(TDC pDataContract, TEntity pEntity); - } + + Dictionary ToJsonDictionary(TDC pDC); + Dictionary ToJsonDictionary(TEntity pEntity); + IList> ToJsonDictionary(IList pEntities); + IList> ToJsonDictionary(IList pDCs); + } } \ No newline at end of file diff --git a/Service/DCEntityMapper/MandatorDC_Mandator.cs b/Service/DCEntityMapper/MandatorDC_Mandator.cs index bfbfff385..f8244607d 100644 --- a/Service/DCEntityMapper/MandatorDC_Mandator.cs +++ b/Service/DCEntityMapper/MandatorDC_Mandator.cs @@ -27,7 +27,7 @@ namespace BeWo.Service.DCEntityMapper to.IsSchedulerAllowed = from.IsSchedulerAllowed; to.IsMedicationAllowed = from.IsMedicationAllowed; - to.BankAccount = MapperFactory.BankAccountDC_BankAccount.MapToNewDC(from.BankAccount, false); + to.BankAccount = MapperFactory.BankAccount.MapToNewDC(from.BankAccount, false); to.AllowSbd = !string.IsNullOrEmpty(to.ClientId) && to.ClientId == "SBD"; @@ -76,7 +76,7 @@ namespace BeWo.Service.DCEntityMapper // HACK: BankAccount ist neu, alte Clients: from.BankAccount null if (from.BankAccount is object) { - to.BankAccount = MapperFactory.BankAccountDC_BankAccount.MergeWithEntity(from.BankAccount, to.BankAccount, false); + to.BankAccount = MapperFactory.BankAccount.MergeWithEntity(from.BankAccount, to.BankAccount, false); to.SoziotherapieAnsprechpartner = MapperFactory.CompactEmployeeDC_Employee.MergeWithEntity(from.SoziotherapieAnsprechpartner, to.SoziotherapieAnsprechpartner, false); to.Logo = MapperFactory.ImageDC_Image.MergeWithEntity(from.Logo, to.Logo, false); diff --git a/Service/DCEntityMapper/MapperFactory.cs b/Service/DCEntityMapper/MapperFactory.cs index 21238db1f..c382650aa 100644 --- a/Service/DCEntityMapper/MapperFactory.cs +++ b/Service/DCEntityMapper/MapperFactory.cs @@ -784,7 +784,15 @@ namespace BeWo.Service.DCEntityMapper public static CompactGkvAbrechnungDC_GkvAbrechnung CompactGkvAbrechnungDC_GkvAbrechnung => _CompactGkvAbrechnungDC_GkvAbrechnung ?? (_CompactGkvAbrechnungDC_GkvAbrechnung = new CompactGkvAbrechnungDC_GkvAbrechnung()); - public static BankAccountDC_BankAccount BankAccountDC_BankAccount { get; } - = new BankAccountDC_BankAccount(); - } + + // Neuer Style + // - Kürzere Namen -> Länge reduzieren + // - Einfaches Init -> Bei Bedarf erweitern + + public static BankAccountDC_BankAccount BankAccount { get; } = new BankAccountDC_BankAccount(); + public static AiConversationDC_AiConversation AiConversation { get; } = new AiConversationDC_AiConversation(); + public static AiConversationMessageDC_AiConversationMessage AiConversationMessage { get; } = new AiConversationMessageDC_AiConversationMessage(); + public static AiModelDC_AiModel AiModel { get; } = new AiModelDC_AiModel(); + public static AiConfigDC_AiConfig AiConfig { get; } = new AiConfigDC_AiConfig(); + } } \ No newline at end of file diff --git a/Service/DCEntityMapper/ServiceRecordDC_ServiceRecord.cs b/Service/DCEntityMapper/ServiceRecordDC_ServiceRecord.cs index 45e661de7..05a06e014 100644 --- a/Service/DCEntityMapper/ServiceRecordDC_ServiceRecord.cs +++ b/Service/DCEntityMapper/ServiceRecordDC_ServiceRecord.cs @@ -266,5 +266,29 @@ namespace BeWo.Service.DCEntityMapper return pDC.ServiceRecordOid == pEntity.Oid; } - } + + public override Dictionary ToJsonDictionary(ServiceRecordDC service_record) + { + var record_dict = new Dictionary + { + { "StartDate", service_record.Start }, + { "EndDate", service_record.End }, + { "Duration (Std)", service_record.DurationInStunden }, + { "ServiceCategory", service_record.ServiceDescription.Category.Name }, + { "ServiceDescription", service_record.ServiceDescription.Name }, + { "Documentation", service_record.Notice + + "\n" + service_record.Notice2 + + "\n" + service_record.Notice3 + + "\n" + service_record.Notice4 + + "\n" + service_record.Notice5}, + { "Distance (Meter)", service_record.DistanceInMeter ?? 0 }, + { "InsertedOn", service_record.InsertedOn }, + { "Betrag", service_record.Betrag }, + { "InsertUser", service_record.InsUser }, + { "Employee", service_record.Employee } + }; + + return record_dict; + } + } } \ No newline at end of file diff --git a/Service/Plugins/AiService.cs b/Service/Plugins/AiService.cs index 9420dc89a..b9da83942 100644 --- a/Service/Plugins/AiService.cs +++ b/Service/Plugins/AiService.cs @@ -79,8 +79,6 @@ namespace BeWo.Service.Plugins acdc.Prompt = String.Format("{0}\n{1}\n{2}", json.pmt.pre, acdc.Prompt, json.pmt.post); } } - - } public AiChatDC CreateAiQuery(AiChatDC acdc) diff --git a/Service/Service.csproj b/Service/Service.csproj index 4130629d6..3eddb439c 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -235,6 +235,10 @@ + + + + @@ -501,18 +505,24 @@ + + + + + + @@ -520,6 +530,8 @@ + + @@ -533,11 +545,14 @@ + + + @@ -581,7 +596,6 @@ - @@ -595,6 +609,15 @@ + + + + + + + + +