2025-06-10 16:15:34 +02:00
|
|
|
|
using BS.Shared;
|
|
|
|
|
|
using DevExpress.Mvvm;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2025-06-11 10:42:16 +02:00
|
|
|
|
using static DevExpress.Mvvm.Native.Either;
|
2025-06-10 16:15:34 +02:00
|
|
|
|
|
|
|
|
|
|
namespace BeWo.Core.Commands
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class CommandFactory
|
|
|
|
|
|
{
|
|
|
|
|
|
public static DelegateCommand GetAiViewCommand(Action openView, UserRightType userRightType, Func<bool> additionalCheckup = null)
|
|
|
|
|
|
{
|
2025-06-11 10:42:16 +02:00
|
|
|
|
bool canExecute() =>
|
2025-06-23 12:29:57 +02:00
|
|
|
|
(BeWoApp.AppSettings?.ModuleAiEnabled ?? false) &&
|
2025-06-11 10:42:16 +02:00
|
|
|
|
BeWoApp.HasLoggedOnUserRight(userRightType) &&
|
|
|
|
|
|
(additionalCheckup is null || additionalCheckup());
|
2025-06-11 10:06:25 +02:00
|
|
|
|
|
2025-06-23 12:33:15 +02:00
|
|
|
|
return GetTestClientCommand(openView, () => CheckupSafe(canExecute), null);
|
2025-06-11 12:51:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static DelegateCommand GetTestClientCommand(Action action, Func<bool> canExecute = null, bool? useCommandManager = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool canExecute2() =>
|
|
|
|
|
|
CheckupTestVersion() &&
|
|
|
|
|
|
(canExecute is null || canExecute());
|
|
|
|
|
|
|
2025-06-23 12:33:15 +02:00
|
|
|
|
return new DelegateCommand(action, () => CheckupSafe(canExecute2), useCommandManager);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static bool CheckupSafe(Func<bool> predicate)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
return predicate();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2025-06-11 10:06:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-11 10:42:16 +02:00
|
|
|
|
private static bool CheckupTestVersion()
|
2025-06-11 10:06:25 +02:00
|
|
|
|
{
|
|
|
|
|
|
var version = BeWoApp.Version.Split(' ');
|
|
|
|
|
|
var test_string = version[version.Length - 1].ToLower();
|
|
|
|
|
|
return test_string == "test";
|
2025-06-10 16:15:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|