Example #1
0
        public WcfServerSetting GetServerSetting(string serviceType, string machineIP)
        {
            var setting = new WcfServerSetting
            {
                WcfCoreSetting = new WcfServerCoreSetting
                {
                    EnableUnity = false,
                },
                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 services = WcfConfig.GetServices().Where(service => service.ServiceTypeName == serviceType).ToList();
                var s = services.Where(service => machineIP.Contains(service.ServerMachineIP) || service.ServerMachineIP == "*").FirstOrDefault();
                if (s == null)
                {
                    Warning("Adhesive.DistributedService.Config", "WcfConfigService.GetServerSetting", string.Format("没有获取到Service,参数为{0},{1}", serviceType, machineIP));
                }
                else
                {
                    var config = s.ServerSetting;
                    if (config != null)
                    {
                        setting = config;
                    }
                    else
                    {
                        Warning("Adhesive.DistributedService.Config", "WcfConfigService.GetServerSetting", string.Format("没有获取到ServerSetting,参数为{0},{1}", serviceType, machineIP));
                    }
                }

            }
            catch (Exception ex)
            {
                Error("Adhesive.DistributedService.Config", "WcfConfigService.GetServerSetting", string.Format("GetServerSetting出错:{0},参数为{1},{2}", ex.ToString(), serviceType, machineIP));
            }

            return setting;
        }
Example #2
0
        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);
        }