ErrorCallback on ServiceFacade

This commit is contained in:
2025-04-24 14:48:47 +02:00
parent e8c4c4e65f
commit d252863fc5
3 changed files with 29 additions and 16 deletions

View File

@@ -80,10 +80,10 @@ namespace BeWo.ServiceProxy
=> DoSync<AiEnhancedServiceClient, IAiEnhancedService>(pAction);
public static T DoAiEnhancedServiceSnyc<T>(Func<IAiEnhancedService, T> pFunc)
=> DoSync<AiEnhancedServiceClient, IAiEnhancedService, T>(pFunc);
public static void DoAiEnhancedServiceAsnyc(Action<IAiEnhancedService> pAction, Action pCallback = null, bool showWaitDialog = true, UserControl caller = null)
=> DoAsync<AiEnhancedServiceClient, IAiEnhancedService>(pAction, pCallback, showWaitDialog, caller?.Dispatcher);
public static void DoAiEnhancedServiceAsnyc<T>(Func<IAiEnhancedService, T> pFunc, Action<T> pCallback = null, bool showWaitDialog = true, UserControl caller = null)
=> DoAsync<AiEnhancedServiceClient, IAiEnhancedService, T>(pFunc, pCallback, showWaitDialog, caller?.Dispatcher);
public static void DoAiEnhancedServiceAsnyc(Action<IAiEnhancedService> pAction, Action pCallback = null, Action pErrorCallback = null, bool showWaitDialog = true, UserControl caller = null)
=> DoAsync<AiEnhancedServiceClient, IAiEnhancedService>(pAction, pCallback, pErrorCallback, showWaitDialog, caller?.Dispatcher);
public static void DoAiEnhancedServiceAsnyc<T>(Func<IAiEnhancedService, T> pFunc, Action<T> pCallback = null, Action pErrorCallback = null, bool showWaitDialog = true, UserControl caller = null)
=> DoAsync<AiEnhancedServiceClient, IAiEnhancedService, T>(pFunc, pCallback, pErrorCallback, showWaitDialog, caller?.Dispatcher);
#endregion
#region OperationsEnhancedService
@@ -91,10 +91,10 @@ namespace BeWo.ServiceProxy
=> DoSync<OperationsEnhancedServiceClient, IOperationsEnhancedService>(pAction);
public static T DoOperationsEnhancedServiceSnyc<T>(Func<IOperationsEnhancedService, T> pFunc)
=> DoSync<OperationsEnhancedServiceClient, IOperationsEnhancedService, T>(pFunc);
public static void DoOperationsEnhancedServiceAsnyc(Action<IOperationsEnhancedService> pAction, Action pCallback = null, bool showWaitDialog = true, UserControl caller = null)
=> DoAsync<OperationsEnhancedServiceClient, IOperationsEnhancedService>(pAction, pCallback, showWaitDialog, caller?.Dispatcher);
public static void DoOperationsEnhancedServiceAsnyc<T>(Func<IOperationsEnhancedService, T> pFunc, Action<T> pCallback = null, bool showWaitDialog = true, UserControl caller = null)
=> DoAsync<OperationsEnhancedServiceClient, IOperationsEnhancedService, T>(pFunc, pCallback, showWaitDialog, caller?.Dispatcher);
public static void DoOperationsEnhancedServiceAsnyc(Action<IOperationsEnhancedService> pAction, Action pCallback = null, Action pErrorCallback = null, bool showWaitDialog = true, UserControl caller = null)
=> DoAsync<OperationsEnhancedServiceClient, IOperationsEnhancedService>(pAction, pCallback, pErrorCallback, showWaitDialog, caller?.Dispatcher);
public static void DoOperationsEnhancedServiceAsnyc<T>(Func<IOperationsEnhancedService, T> pFunc, Action<T> pCallback = null, Action pErrorCallback = null, bool showWaitDialog = true, UserControl caller = null)
=> DoAsync<OperationsEnhancedServiceClient, IOperationsEnhancedService, T>(pFunc, pCallback, pErrorCallback, showWaitDialog, caller?.Dispatcher);
#endregion
@@ -311,7 +311,7 @@ namespace BeWo.ServiceProxy
}
public static void DoGkvAccountingServiceAsyncGUI<T>(Func<IGkvAccountingService, T> pFunc, Action<T> pCallBack, Dispatcher dispatcher)
{
DoAsync<GkvAccountingServiceClient, IGkvAccountingService, T>(pFunc, pCallBack, true, dispatcher);
DoAsync<GkvAccountingServiceClient, IGkvAccountingService, T>(pFunc, pCallBack, null, true, dispatcher);
}
public static void DoGkvAccountingServiceAsync(Action<IGkvAccountingService> pAction)
@@ -694,12 +694,12 @@ namespace BeWo.ServiceProxy
DoAsync<TClient, TInterface, T>(pFunc, pCallback, null, showWaitDialog);
}
private static void DoAsync<TClient, TInterface, T>(Func<TInterface, T> pFunc, Action<T> pCallback, bool showWaitDialog, Dispatcher dispatcher)
private static void DoAsync<TClient, TInterface, T>(Func<TInterface, T> pFunc, Action<T> pCallback, Action pErrorCallback, bool showWaitDialog, Dispatcher dispatcher)
where TClient : ClientBase<TInterface>, TInterface, new()
where TInterface : class
{
if(dispatcher is null)
if (dispatcher is null)
{
dispatcher = BeWoApp.Current.Dispatcher;
}
@@ -711,7 +711,7 @@ namespace BeWo.ServiceProxy
pCallback(t);
});
DoAsync<TClient, TInterface, T>(pFunc, action, showWaitDialog);
DoAsync<TClient, TInterface, T>(pFunc, action, pErrorCallback, showWaitDialog);
}
private static void DoAsync<TClient, TInterface, T>(Func<TInterface, T> pFunc, Action<T> pCallback, Action pErrorCallback, bool showWaitDialog)
@@ -785,7 +785,7 @@ namespace BeWo.ServiceProxy
DoAsync<TClient, TInterface>(pAction, null, showWaitDialog);
}
private static void DoAsync<TClient, TInterface>(Action<TInterface> pAction, Action pCallback, bool showWaitDialog, Dispatcher dispatcher)
private static void DoAsync<TClient, TInterface>(Action<TInterface> pAction, Action pCallback, Action pErrorCallback, bool showWaitDialog, Dispatcher dispatcher)
where TClient : ClientBase<TInterface>, TInterface, new()
where TInterface : class
{
@@ -801,7 +801,7 @@ namespace BeWo.ServiceProxy
});
}
DoAsync<TClient, TInterface>(pAction, action, showWaitDialog);
DoAsync<TClient, TInterface>(pAction, action, pErrorCallback, showWaitDialog);
}
// private static void DoAsync<TClient, TInterface>(Action<TInterface> pAction, Action pCallback, bool )
@@ -809,6 +809,13 @@ namespace BeWo.ServiceProxy
private static void DoAsync<TClient, TInterface>(Action<TInterface> pAction, Action pCallback, bool showWaitDialog)
where TClient : ClientBase<TInterface>, TInterface, new()
where TInterface : class
{
DoAsync<TClient, TInterface>(pAction, pCallback, null, showWaitDialog);
}
private static void DoAsync<TClient, TInterface>(Action<TInterface> pAction, Action pCallback, Action pErrorCallback, bool showWaitDialog)
where TClient : ClientBase<TInterface>, TInterface, new()
where TInterface : class
{
try
{
@@ -846,6 +853,11 @@ namespace BeWo.ServiceProxy
}
ShowErrorMessage(e);
if (pErrorCallback != null)
{
pErrorCallback();
}
}
},
null);

View File

@@ -32,7 +32,6 @@ namespace BeWo.Services
ShowWindowDialog(
cf => cf.GetAiConversationControl(uIContext, bewoObjects),
(wf, ctrl) => wf.GetAiConversationWindow(uIContext, ctrl));
}
public void ShowAiConversationModalViewWindow(UIContext uIContext, Dictionary<TableID, long[]> bewoObjects)
{

View File

@@ -172,6 +172,8 @@ namespace BeWo.ViewModel.ListViewModel
msg_vm.DataContract = messages[0];
conv.Messages.VMList.Add(new AiConversationMessageVM(messages[1]));
});
}
public void Test()