diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs index 2bae0584b..73f29e1e8 100644 --- a/BeWo/BeWoApp.xaml.cs +++ b/BeWo/BeWoApp.xaml.cs @@ -633,8 +633,8 @@ namespace BeWo //showInfoButtonInCalender = true; //IsInDeveloperMode = true; //IsInDeveloperMode = false; - AppSettings.ModuleAiEnabled = true; - AppSettings.ModuleAiSettingsEnabled = false; + //AppSettings.ModuleAiEnabled = true; + //AppSettings.ModuleAiSettingsEnabled = false; AppSettings.IsSchedulerAllowed = true; #endif diff --git a/BeWo/Core/Commands/CommandFactory.cs b/BeWo/Core/Commands/CommandFactory.cs index eb2090f52..5589c6658 100644 --- a/BeWo/Core/Commands/CommandFactory.cs +++ b/BeWo/Core/Commands/CommandFactory.cs @@ -14,11 +14,11 @@ namespace BeWo.Core.Commands public static DelegateCommand GetAiViewCommand(Action openView, UserRightType userRightType, Func additionalCheckup = null) { bool canExecute() => - BeWoApp.AppSettings.ModuleAiEnabled && + (BeWoApp.AppSettings?.ModuleAiEnabled ?? false) && BeWoApp.HasLoggedOnUserRight(userRightType) && (additionalCheckup is null || additionalCheckup()); - return GetTestClientCommand(openView, canExecute, false); + return GetTestClientCommand(openView, () => CheckupSafe(canExecute), null); } public static DelegateCommand GetTestClientCommand(Action action, Func canExecute = null, bool? useCommandManager = null) @@ -27,7 +27,19 @@ namespace BeWo.Core.Commands CheckupTestVersion() && (canExecute is null || canExecute()); - return new DelegateCommand(action, canExecute2, useCommandManager); + return new DelegateCommand(action, () => CheckupSafe(canExecute2), useCommandManager); + } + + private static bool CheckupSafe(Func predicate) + { + try + { + return predicate(); + } + catch (Exception ex) + { + return false; + } } private static bool CheckupTestVersion() diff --git a/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml.cs b/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml.cs index 35e908036..fa76cc33d 100644 --- a/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml.cs +++ b/BeWo/View/Detail/Zeiterfassung/ServiceRecordView2.xaml.cs @@ -350,21 +350,11 @@ namespace BeWo.View.Detail.Zeiterfassung OpenAiWindowCommand = CommandFactory.GetAiViewCommand(OpenAiWindow, UserRightType.AiModuleView); OpenAiPopupCommand = CommandFactory.GetAiViewCommand(OpenAiPopup, UserRightType.AiModuleView2); - - if (!BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView)) - { - btnOpenAi2.Visibility = Visibility.Collapsed; - } - if (!BeWoApp.HasLoggedOnUserRight(UserRightType.AiModuleView2)) - { - btnOpenAi3.Visibility = Visibility.Collapsed; - } } public ICommand OpenAiWindowCommand { get; set; } public ICommand OpenAiPopupCommand { get; set; } - private void SrGridControl_ItemsSourceChanged(object sender, DevExpress.Xpf.Grid.ItemsSourceChangedEventArgs e) { ErstelleRecordInformationString(); diff --git a/BeWo/View/Navigation/MainNavigationView.xaml.cs b/BeWo/View/Navigation/MainNavigationView.xaml.cs index 06f8052e0..e2416ea32 100644 --- a/BeWo/View/Navigation/MainNavigationView.xaml.cs +++ b/BeWo/View/Navigation/MainNavigationView.xaml.cs @@ -506,7 +506,9 @@ namespace BeWo.View.Navigation private void OnLoaded(object sender, RoutedEventArgs e) { - textbox_search.Focus(); + CommandManager.InvalidateRequerySuggested(); + + textbox_search.Focus(); } private void OnOpenObject()