From b122048ea1518965d682f4bf952913af86cbde0f Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Mon, 14 Apr 2025 13:04:13 +0200 Subject: [PATCH] service client ausgelagert --- .gitignore | 1 + BeWo/BeWo.csproj | 1 + .../GeneratedAiEnhancedService.cs | 152 ------------------ .../GeneratedOperationsEnhancedService.cs | 56 +------ BeWo/ServiceProxy/ServiceFacade.cs | 17 +- .../Detail/AI/AiConversationChatView.xaml.cs | 2 +- BeWo/View/Master/AiConversationView.xaml.cs | 14 +- .../ListViewModel/AiConversationListVM.cs | 12 +- BeWo/app.config | 1 + .../IOperationsEnhancedService.cs | 4 +- .../OperationsEnhancedServiceImp.cs | 5 +- 11 files changed, 45 insertions(+), 220 deletions(-) diff --git a/.gitignore b/.gitignore index d63c8a04a..58942535c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ DebugConfig.txt Host/Multitenancy/demo.config *.log.txt +*temp.txt # Folder bin[Rr]elease/ diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index 07e99f71a..71a377028 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -95,6 +95,7 @@ + AiConfigView.xaml diff --git a/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs b/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs index 7235b05c6..8193d1fab 100644 --- a/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs +++ b/BeWo/ServiceProxy/GeneratedAiEnhancedService.cs @@ -7,160 +7,8 @@ // der Code erneut generiert wird. // //------------------------------------------------------------------------------ - namespace BeWo.ServiceProxy { - using System.Runtime.Serialization; - - - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] - [System.Runtime.Serialization.DataContractAttribute(Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - public partial class BeWoFault : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged - { - - private System.Runtime.Serialization.ExtensionDataObject extensionDataField; - - private BeWo.ServiceProxy.BeWoFaultType FaultTypeField; - - private string InnerExceptionMessageField; - - private string InnerExceptionStackTraceField; - - private string MessageField; - - private string StackTraceField; - - public System.Runtime.Serialization.ExtensionDataObject ExtensionData - { - get - { - return this.extensionDataField; - } - set - { - this.extensionDataField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public BeWo.ServiceProxy.BeWoFaultType FaultType - { - get - { - return this.FaultTypeField; - } - set - { - if ((this.FaultTypeField.Equals(value) != true)) - { - this.FaultTypeField = value; - this.RaisePropertyChanged("FaultType"); - } - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string InnerExceptionMessage - { - get - { - return this.InnerExceptionMessageField; - } - set - { - if ((object.ReferenceEquals(this.InnerExceptionMessageField, value) != true)) - { - this.InnerExceptionMessageField = value; - this.RaisePropertyChanged("InnerExceptionMessage"); - } - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string InnerExceptionStackTrace - { - get - { - return this.InnerExceptionStackTraceField; - } - set - { - if ((object.ReferenceEquals(this.InnerExceptionStackTraceField, value) != true)) - { - this.InnerExceptionStackTraceField = value; - this.RaisePropertyChanged("InnerExceptionStackTrace"); - } - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string Message - { - get - { - return this.MessageField; - } - set - { - if ((object.ReferenceEquals(this.MessageField, value) != true)) - { - this.MessageField = value; - this.RaisePropertyChanged("Message"); - } - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string StackTrace - { - get - { - return this.StackTraceField; - } - set - { - if ((object.ReferenceEquals(this.StackTraceField, value) != true)) - { - this.StackTraceField = value; - this.RaisePropertyChanged("StackTrace"); - } - } - } - - public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - - protected void RaisePropertyChanged(string propertyName) - { - System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; - if ((propertyChanged != null)) - { - propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); - } - } - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] - [System.Runtime.Serialization.DataContractAttribute(Name="BeWoFaultType", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - public enum BeWoFaultType : int - { - - [System.Runtime.Serialization.EnumMemberAttribute()] - Unknown = 0, - - [System.Runtime.Serialization.EnumMemberAttribute()] - Concurrency = 1, - - [System.Runtime.Serialization.EnumMemberAttribute()] - DeleteNotPossible = 2, - - [System.Runtime.Serialization.EnumMemberAttribute()] - LoginNameTaken = 3, - - [System.Runtime.Serialization.EnumMemberAttribute()] - CustomWithoutDetails = 4, - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] [System.ServiceModel.ServiceContractAttribute(ConfigurationName="BeWo.ServiceProxy.IAiEnhancedService")] public interface IAiEnhancedService diff --git a/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs b/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs index 4967b28de..17311477e 100644 --- a/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs +++ b/BeWo/ServiceProxy/GeneratedOperationsEnhancedService.cs @@ -7,7 +7,6 @@ // der Code erneut generiert wird. // //------------------------------------------------------------------------------ - namespace BeWo.ServiceProxy { [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] @@ -15,29 +14,9 @@ namespace BeWo.ServiceProxy public interface IOperationsEnhancedService { - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/GetAiConfig", ReplyAction="http://tempuri.org/IOperationsEnhancedService/GetAiConfigResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/GetAiConfigBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - BS.Shared.DataContracts.Feature.AI.AiConfigDC GetAiConfig(); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/UpdateAiConfig", ReplyAction="http://tempuri.org/IOperationsEnhancedService/UpdateAiConfigResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/UpdateAiConfigBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - BS.Shared.DataContracts.Feature.AI.AiConfigDC UpdateAiConfig(BS.Shared.DataContracts.Feature.AI.AiConfigDC toUpdate); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/GetAiModels", ReplyAction="http://tempuri.org/IOperationsEnhancedService/GetAiModelsResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/GetAiModelsBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - System.Collections.Generic.List GetAiModels(); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/GetAiConversations", ReplyAction="http://tempuri.org/IOperationsEnhancedService/GetAiConversationsResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/GetAiConversationsBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - System.Collections.Generic.List GetAiConversations(int uicontext); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/CreateAiConversation", ReplyAction="http://tempuri.org/IOperationsEnhancedService/CreateAiConversationResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/CreateAiConversationBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - BS.Shared.DataContracts.Feature.AI.AiConversationDC CreateAiConversation(BS.Shared.DataContracts.Feature.AI.AiConversationDC conversation, long modell_oid); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/SendNewMessage", ReplyAction="http://tempuri.org/IOperationsEnhancedService/SendNewMessageResponse")] - [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/SendNewMessageBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] - System.Collections.Generic.List SendNewMessage(long conversation, string message); + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IOperationsEnhancedService/HelloWorld", ReplyAction="http://tempuri.org/IOperationsEnhancedService/HelloWorldResponse")] + [System.ServiceModel.FaultContractAttribute(typeof(BeWo.ServiceProxy.BeWoFault), Action="http://tempuri.org/IOperationsEnhancedService/HelloWorldBeWoFaultFault", Name="BeWoFault", Namespace="http://schemas.datacontract.org/2004/07/BeWo.Service.ServiceContracts")] + void HelloWorld(); } [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] @@ -74,34 +53,9 @@ namespace BeWo.ServiceProxy { } - public BS.Shared.DataContracts.Feature.AI.AiConfigDC GetAiConfig() + public void HelloWorld() { - return base.Channel.GetAiConfig(); - } - - public BS.Shared.DataContracts.Feature.AI.AiConfigDC UpdateAiConfig(BS.Shared.DataContracts.Feature.AI.AiConfigDC toUpdate) - { - return base.Channel.UpdateAiConfig(toUpdate); - } - - public System.Collections.Generic.List GetAiModels() - { - return base.Channel.GetAiModels(); - } - - public System.Collections.Generic.List GetAiConversations(int uicontext) - { - return base.Channel.GetAiConversations(uicontext); - } - - public BS.Shared.DataContracts.Feature.AI.AiConversationDC CreateAiConversation(BS.Shared.DataContracts.Feature.AI.AiConversationDC conversation, long modell_oid) - { - return base.Channel.CreateAiConversation(conversation, modell_oid); - } - - public System.Collections.Generic.List SendNewMessage(long conversation, string message) - { - return base.Channel.SendNewMessage(conversation, message); + base.Channel.HelloWorld(); } } } diff --git a/BeWo/ServiceProxy/ServiceFacade.cs b/BeWo/ServiceProxy/ServiceFacade.cs index 0bee0e2c3..b06a17d35 100644 --- a/BeWo/ServiceProxy/ServiceFacade.cs +++ b/BeWo/ServiceProxy/ServiceFacade.cs @@ -64,7 +64,8 @@ namespace BeWo.ServiceProxy { typeof(IMailService), new EndpointAddress(_ServerName + "MailService.svc") }, { typeof(IAccountingService), new EndpointAddress(_ServerName + "AccountingService.svc") }, { typeof(IGkvAccountingService), new EndpointAddress(_ServerName + "GkvAccountingService.svc") }, - { typeof(IReportService), new EndpointAddress(_ServerName + "ReportService.svc") } + { typeof(IReportService), new EndpointAddress(_ServerName + "ReportService.svc") }, + { typeof(IAiEnhancedService), new EndpointAddress(_ServerName + "AiEnhancedService.svc") } }; } @@ -74,6 +75,18 @@ namespace BeWo.ServiceProxy _ProxyCache = new Dictionary(); } + #region AiEnhancedService + public static void DoAiEnhancedServiceSnyc(Action pAction) + => DoSync(pAction); + public static T DoAiEnhancedServiceSnyc(Func pFunc) + => DoSync(pFunc); + public static void DoAiEnhancedServiceAsnyc(Action pAction, Action pCallback = null, bool showWaitDialog = true, UserControl caller = null) + => DoAsync(pAction, pCallback, showWaitDialog, caller?.Dispatcher); + public static void DoAiEnhancedServiceAsnyc(Func pFunc, Action pCallback = null, bool showWaitDialog = true, UserControl caller = null) + => DoAsync(pFunc, pCallback, showWaitDialog, caller?.Dispatcher); + #endregion + + #region OperationsEnhancedService public static void DoOperationsEnhancedServiceSnyc(Action pAction) => DoSync(pAction); public static T DoOperationsEnhancedServiceSnyc(Func pFunc) @@ -82,6 +95,8 @@ namespace BeWo.ServiceProxy => DoAsync(pAction, pCallback, showWaitDialog, caller?.Dispatcher); public static void DoOperationsEnhancedServiceAsnyc(Func pFunc, Action pCallback = null, bool showWaitDialog = true, UserControl caller = null) => DoAsync(pFunc, pCallback, showWaitDialog, caller?.Dispatcher); + #endregion + public static void DoAccountingServiceAsync(Func pFunc, Action pCallBack, bool showWaitDialog) { diff --git a/BeWo/View/Detail/AI/AiConversationChatView.xaml.cs b/BeWo/View/Detail/AI/AiConversationChatView.xaml.cs index 8caecae6b..228b195b3 100644 --- a/BeWo/View/Detail/AI/AiConversationChatView.xaml.cs +++ b/BeWo/View/Detail/AI/AiConversationChatView.xaml.cs @@ -55,7 +55,7 @@ namespace BeWo.View.Detail.AI private void OpenAiSetting() { - ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => + ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => { ViewModel.Models.MakeEqualTo(x); popup_settings.IsOpen = true; diff --git a/BeWo/View/Master/AiConversationView.xaml.cs b/BeWo/View/Master/AiConversationView.xaml.cs index 9f4e75bda..912e50c46 100644 --- a/BeWo/View/Master/AiConversationView.xaml.cs +++ b/BeWo/View/Master/AiConversationView.xaml.cs @@ -30,7 +30,7 @@ namespace BeWo.View.Master { InitializeComponent(); - OpenAiSettingCommand = new DelegateCommand(OpenAiSetting); + //OpenAiSettingCommand = new DelegateCommand(OpenAiSetting); } public AiConversationListVM ViewModel @@ -48,16 +48,16 @@ namespace BeWo.View.Master private void ReloadButton_OnClick(object sender, RoutedEventArgs e) { - ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => { ViewModel.Models.MakeEqualTo(x); }, true, this); + //ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => { ViewModel.Models.MakeEqualTo(x); }, true, this); } public void OpenAiSetting() { - ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => - { - ViewModel.Models.MakeEqualTo(x); - popup_settings.IsOpen = true; - }, true, this); + //ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => + //{ + // ViewModel.Models.MakeEqualTo(x); + // popup_settings.IsOpen = true; + //}, true, this); } } } diff --git a/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs b/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs index e878fd42e..8e5afb24f 100644 --- a/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs +++ b/BeWo/ViewModel/ListViewModel/AiConversationListVM.cs @@ -117,7 +117,7 @@ namespace BeWo.ViewModel.ListViewModel conv.UIContext = UIContext; conv.ContextBeWoObjects = ContextBeWoObjects; - ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.CreateAiConversation(conv, Config.SelectedModel.Oid.Value), dc => { + ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.CreateAiConversation(conv, Config.SelectedModel.Oid.Value), dc => { var vm = new AiConversationVM(dc); VMList.Insert(0, vm); SelectedVM = vm; @@ -137,7 +137,7 @@ namespace BeWo.ViewModel.ListViewModel conv.Messages.VMList.Add(msg_vm); - ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.SendNewMessage(conv.DataContract.Oid.Value, MessageInput), (messages) => + ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.SendNewMessage(conv.DataContract.Oid.Value, MessageInput), (messages) => { if (messages.Count != 2) throw new InvalidOperationException("message count: " + messages.Count); @@ -188,7 +188,7 @@ namespace BeWo.ViewModel.ListViewModel private void ReloadConfig() { - ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiConfig(), (x) => + ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.GetAiConfig(), (x) => { if (Config is null) Config = new AiConfigVM(x); @@ -201,7 +201,7 @@ namespace BeWo.ViewModel.ListViewModel if (!Config.IsDirty) return; - ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.UpdateAiConfig(Config.CommitToDataContract()), (x) => + ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.UpdateAiConfig(Config.CommitToDataContract()), (x) => { Config.Update(x); }); @@ -209,7 +209,7 @@ namespace BeWo.ViewModel.ListViewModel private void ReloadModels() { - ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => + ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => { Models.MakeEqualTo(x); @@ -221,7 +221,7 @@ namespace BeWo.ViewModel.ListViewModel { var ui_context = UIContext; - ServiceFacade.DoOperationsEnhancedServiceAsnyc(x => x.GetAiConversations(ui_context), (x) => + ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.GetAiConversations(ui_context), (x) => { x.Reverse(); var vms = new AiConversationListVM(x); diff --git a/BeWo/app.config b/BeWo/app.config index b46c4386e..694c950ad 100644 --- a/BeWo/app.config +++ b/BeWo/app.config @@ -48,6 +48,7 @@ + diff --git a/Service/ServiceContracts/IOperationsEnhancedService.cs b/Service/ServiceContracts/IOperationsEnhancedService.cs index 4ff9a0565..9465a3a95 100644 --- a/Service/ServiceContracts/IOperationsEnhancedService.cs +++ b/Service/ServiceContracts/IOperationsEnhancedService.cs @@ -15,6 +15,8 @@ namespace BeWo.Service.ServiceContracts [ServiceContract] public interface IOperationsEnhancedService : IService { - + [FaultContract(typeof(BeWoFault))] + [OperationContract] + void HelloWorld(); } } \ No newline at end of file diff --git a/Service/ServiceImplementations/OperationsEnhancedServiceImp.cs b/Service/ServiceImplementations/OperationsEnhancedServiceImp.cs index 1304bb850..e11e7da50 100644 --- a/Service/ServiceImplementations/OperationsEnhancedServiceImp.cs +++ b/Service/ServiceImplementations/OperationsEnhancedServiceImp.cs @@ -26,6 +26,9 @@ namespace BeWo.Service.ServiceImplementations [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)] public class OperationsEnhancedServiceImp : IOperationsEnhancedService { - + public void HelloWorld() + { + throw new NotImplementedException(); + } } }