Example #1
0
        /// <summary>
        ///     加载配置
        /// </summary>
        public Tuple <int, string, string> LoadDomainSwitch(string nodeName = "",
                                                            DomainSwitchNodeType nodeType = DomainSwitchNodeType.Unknown)
        {
            lock (LockDW)
            {
                try
                {
                    var configValue = string.Empty;
                    if (!string.IsNullOrEmpty(nodeName) && nodeType != DomainSwitchNodeType.Unknown)
                    {
                        if (nodeType == DomainSwitchNodeType.ServiceUrl)
                        {
                            configValue = DomainSwitch.GetServiceUrl(nodeName);
                        }
                        if (nodeType == DomainSwitchNodeType.SiteHost)
                        {
                            configValue = DomainSwitch.GetSiteHost(nodeName);
                        }

                        var nodePath = $"{nodeType}:{nodeName}";
                        if (!string.IsNullOrEmpty(configValue))
                        {
                            ConfigCenterContext.SetDomainSwitch(nodePath, configValue);
                        }
                        return(new Tuple <int, string, string>(0, "刷新成功", configValue));
                    }

                    LoadAllDomainSwitch();
                    return(new Tuple <int, string, string>(0, "刷新成功", ""));
                }
                catch (Exception ex)
                {
                    LogHelper.Warn($"LoadDomainSwitch({nodeName},{nodeType}) handler error ,{ex.Message}", ex);
                    return(new Tuple <int, string, string>(1, $"LoadDomainSwitch Failed {ex.Message}", ""));
                }
            }
        }