public WcfClientSetting GetClientSetting(string serviceContractType, string machineIP) { var setting = new WcfClientSetting { WcfCoreSetting = new WcfClientCoreSetting { }, WcfPerformanceServiceSetting = new WcfPerformanceServiceSetting { Enabled = true, ReportStateIntervalMilliSeconds = 10000, AllowMethods = new List<string> { "*" }, DenyMethods = new List<string>(), }, WcfLogSetting = new WcfLogSetting { Enabled = true, ExceptionInfoSetting = new ExceptionInfoSetting { Enabled = true, }, InvokeInfoSetting = new InvokeInfoSetting { Enabled = false, }, StartInfoSetting = new StartInfoSetting { Enabled = true, }, MessageInfoSetting = new MessageInfoSetting { Enabled = false, } }, WcfSecuritySetting = new WcfSecuritySetting { PasswordCheck = new PasswordCheck { Enable = false, } } }; try { var endpoints = WcfConfig.GetClientEndpoints().Where(ep => ep.ContractTypeName == serviceContractType).ToList(); var e = endpoints.Where(endpoint => machineIP.Contains(endpoint.ClientMachineIP) || endpoint.ClientMachineIP == "*").FirstOrDefault(); if (e == null) { Warning("Adhesive.DistributedService.Config", "WcfConfigService.GetClientSetting", string.Format("没有获取到ClientEndpoint,参数为{0},{1}", serviceContractType, machineIP)); } else { var clientConfig = e.ClientSetting; if (clientConfig != null) { setting.WcfCoreSetting = clientConfig.WcfCoreSetting; setting.WcfLogSetting = clientConfig.WcfLogSetting; } else { Warning("Adhesive.DistributedService.Config", "WcfConfigService.GetClientSetting", string.Format("没有获取到ClientSetting,参数为{0},{1}", serviceContractType, machineIP)); } var serviceEndpoint = WcfConfig.GetServiceEndpoints().Where(se => se.ContractTypeName == serviceContractType).FirstOrDefault(); if (serviceEndpoint != null) { var service = WcfConfig.GetServices().Where(s => s.ServiceTypeName == serviceEndpoint.ServiceTypeName).FirstOrDefault(); if (service != null) { var serviceConfig = service.ServerSetting; if (serviceConfig != null) { setting.WcfSecuritySetting = serviceConfig.WcfSecuritySetting; } else { Warning("Adhesive.DistributedService.Config", "WcfConfigService.GetClientSetting", string.Format("没有获取到ServerSetting,参数为{0},{1}", serviceContractType, machineIP)); } } else { Warning("Adhesive.DistributedService.Config", "WcfConfigService.GetClientSetting", string.Format("没有获取到Service,参数为{0},{1}", serviceContractType, machineIP)); } } else { Warning("Adhesive.DistributedService.Config", "WcfConfigService.GetClientSetting", string.Format("没有获取到ServiceEndpoint,参数为{0},{1}", serviceContractType, machineIP)); } } } catch (Exception ex) { Error("Adhesive.DistributedService.Config", "WcfConfigService.GetClientSetting", string.Format("GetClientSetting出错:{0},参数为{1},{2}", ex.ToString(), serviceContractType, machineIP)); } return setting; }
private static WcfSetting Current(Type type) { WcfSetting setting = null; if (!wcfSettings.ContainsKey(type)) { AppInfoCenterService.LoggingService.Warning(WcfLogProvider.ModuleName, "WcfSettingManager", "Current", string.Format("WcfSettingManager.Current 没有获取到 {0} 的配置", type.FullName)); Init(type); if (type.IsInterface) { setting = new WcfClientSetting { WcfCoreSetting = new WcfClientCoreSetting { }, WcfPerformanceServiceSetting = new WcfPerformanceServiceSetting { Enabled = true, ReportStateIntervalMilliSeconds = 10000, AllowMethods = new List <string> { "*" }, DenyMethods = new List <string>(), }, WcfLogSetting = new WcfLogSetting { Enabled = true, ExceptionInfoSetting = new ExceptionInfoSetting { Enabled = false, }, InvokeInfoSetting = new InvokeInfoSetting { Enabled = false, }, StartInfoSetting = new StartInfoSetting { Enabled = true, }, MessageInfoSetting = new MessageInfoSetting { Enabled = false, } }, WcfSecuritySetting = new WcfSecuritySetting { PasswordCheck = new PasswordCheck { Enable = false, } } }; } else { setting = new WcfServerSetting { WcfCoreSetting = new WcfServerCoreSetting { EnableUnity = true, }, WcfPerformanceServiceSetting = new WcfPerformanceServiceSetting { Enabled = true, ReportStateIntervalMilliSeconds = 10000, AllowMethods = new List <string> { "*" }, DenyMethods = new List <string>(), }, WcfLogSetting = new WcfLogSetting { Enabled = true, ExceptionInfoSetting = new ExceptionInfoSetting { Enabled = true, }, InvokeInfoSetting = new InvokeInfoSetting { Enabled = false, }, StartInfoSetting = new StartInfoSetting { Enabled = true, }, MessageInfoSetting = new MessageInfoSetting { Enabled = false, } }, WcfSecuritySetting = new WcfSecuritySetting { PasswordCheck = new PasswordCheck { Enable = false, } } }; } } else { setting = wcfSettings[type] as WcfSetting; } return(setting); }