From a06f4f47fefb9ac9fcb98078a5f3ff39315ab338 Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Wed, 29 Jan 2025 13:35:12 +0100 Subject: [PATCH] DebugConfig - EnableAutoRemoteDebugging --- BeWo/DebugConfig.cs | 9 ++++-- BeWo/ServiceProxy/ServiceFacade.cs | 52 ++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/BeWo/DebugConfig.cs b/BeWo/DebugConfig.cs index 668901304..25bbea25c 100644 --- a/BeWo/DebugConfig.cs +++ b/BeWo/DebugConfig.cs @@ -42,6 +42,8 @@ namespace BeWo /// public int? SelectIndex { get; set; } + public bool EnableAutoRemoteDebugging { get; set; } + public static DebugConfig SimpleAutoLogin => new DebugConfig() { DebugConfigMode = DebugConfigMode.SimpleAutoLogin, @@ -125,9 +127,10 @@ namespace BeWo AutoLogin = true, SelectView = UIContext.Finance, SelectIndex = 8, - //Username = "m1", - //Password = "bewobewo", - //Profilename = "5000000000" + Username = "m1", + Password = "bewobewo", + Profilename = "5000000000", + EnableAutoRemoteDebugging = true }); return name2config; diff --git a/BeWo/ServiceProxy/ServiceFacade.cs b/BeWo/ServiceProxy/ServiceFacade.cs index fc70f3866..de1cfe6d2 100644 --- a/BeWo/ServiceProxy/ServiceFacade.cs +++ b/BeWo/ServiceProxy/ServiceFacade.cs @@ -24,6 +24,7 @@ namespace BeWo.ServiceProxy { public static object _Lock = string.Empty; + private static string _ServerName; private static Dictionary _EndpointAddresses; private static readonly Dictionary _ProxyCache; @@ -39,26 +40,26 @@ namespace BeWo.ServiceProxy public static void UpdateServerAddresses(String siteOfOrigin) { + _ServerName = siteOfOrigin; + var test = _ServerName.Substring(_ServerName.Length - 1, 1); + if (_ServerName.Substring(_ServerName.Length - 1, 1) != "/") + _ServerName += "/"; - String serverName = siteOfOrigin; - var test = serverName.Substring(serverName.Length - 1, 1); - if (serverName.Substring(serverName.Length - 1, 1) != "/") - serverName += "/"; _EndpointAddresses = new Dictionary { - { typeof(IQueryService), new EndpointAddress(serverName + "QueryService.svc") }, - { typeof(IStreamingService), new EndpointAddress(serverName + "StreamingService.svc") }, - { typeof(IEmployeeService), new EndpointAddress(serverName + "EmployeeService.svc") }, - { typeof(ICustomerService), new EndpointAddress(serverName + "CustomerService.svc") }, - { typeof(IUserService), new EndpointAddress(serverName + "UserService.svc") }, - { typeof(IValueListService), new EndpointAddress(serverName + "ValueListService.svc") }, - { typeof(IDownloadService), new EndpointAddress(serverName + "DownloadService.svc") }, - { typeof(IResourceService), new EndpointAddress(serverName + "ResourceService.svc") }, - { typeof(IOperationsService), new EndpointAddress(serverName + "OperationsService.svc") }, - { typeof(IAnalysisService), new EndpointAddress(serverName + "AnalysisService.svc") }, - { typeof(IMailService), new EndpointAddress(serverName + "MailService.svc") }, - { typeof(IAccountingService), new EndpointAddress(serverName + "AccountingService.svc") }, - { typeof(IReportService), new EndpointAddress(serverName + "ReportService.svc") } + { typeof(IQueryService), new EndpointAddress(_ServerName + "QueryService.svc") }, + { typeof(IStreamingService), new EndpointAddress(_ServerName + "StreamingService.svc") }, + { typeof(IEmployeeService), new EndpointAddress(_ServerName + "EmployeeService.svc") }, + { typeof(ICustomerService), new EndpointAddress(_ServerName + "CustomerService.svc") }, + { typeof(IUserService), new EndpointAddress(_ServerName + "UserService.svc") }, + { typeof(IValueListService), new EndpointAddress(_ServerName + "ValueListService.svc") }, + { typeof(IDownloadService), new EndpointAddress(_ServerName + "DownloadService.svc") }, + { typeof(IResourceService), new EndpointAddress(_ServerName + "ResourceService.svc") }, + { typeof(IOperationsService), new EndpointAddress(_ServerName + "OperationsService.svc") }, + { typeof(IAnalysisService), new EndpointAddress(_ServerName + "AnalysisService.svc") }, + { typeof(IMailService), new EndpointAddress(_ServerName + "MailService.svc") }, + { typeof(IAccountingService), new EndpointAddress(_ServerName + "AccountingService.svc") }, + { typeof(IReportService), new EndpointAddress(_ServerName + "ReportService.svc") } }; } @@ -844,6 +845,23 @@ namespace BeWo.ServiceProxy _ProxyCache.Add(typeof(TClient), lClient); } +#if DEBUG + if (DebugConfig.CurrentConfig is DebugConfig current && current.EnableAutoRemoteDebugging) + { + if (lClient.Endpoint.Binding is BasicHttpBinding binding) + { + if(_ServerName.StartsWith("https")) + { + binding.Security.Mode = BasicHttpSecurityMode.Transport; + } + else + { + binding.Security.Mode = BasicHttpSecurityMode.None; + } + } + } + +#endif lClient.Endpoint.Behaviors.Add(new SecurityHeaderEndpointBehavior()); lClient.Endpoint.Behaviors.Add(new MultitenancyEndpointBehavior());