using BS.Shared; using DevExpress.Mvvm; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static DevExpress.Mvvm.Native.Either; namespace BeWo.Core.Commands { public static class CommandFactory { public static DelegateCommand GetAiViewCommand(Action openView, UserRightType userRightType, Func additionalCheckup = null) { bool canExecute() => (BeWoApp.AppSettings?.ModuleAiEnabled ?? false) && BeWoApp.HasLoggedOnUserRight(userRightType) && (additionalCheckup is null || additionalCheckup()); return GetTestClientCommand(openView, () => CheckupSafe(canExecute), null); } public static DelegateCommand GetTestClientCommand(Action action, Func canExecute = null, bool? useCommandManager = null) { bool canExecute2() => CheckupTestVersion() && (canExecute is null || canExecute()); 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() { var version = BeWoApp.Version.Split(' '); var test_string = version[version.Length - 1].ToLower(); return test_string == "test"; } } }