public SystemConfiguration QueryByName(string name) { return(_kvcacheVisitor.GetSync( (k) => { return _systemConfigurationRepository.QueryByName(name); }, name )); }
public async Task <RemoteServiceDescriptionInfo> GetServiceInfo(string name) { //获取配置服务基地址 var serviceAddressConfig = _systemConigurationRepository.QueryByName(SystemConfigurationNames.ConfigurationServiceBaseAddress); var serviceAddress = serviceAddressConfig.GetConfigurationValue <string>(); var logInfos = await _commonLogInfoGeneratorService.Generate(); //调用配置服务中获取服务信息的方法 var serviceInfo = await HttpClinetHelper.GetAsync <RemoteServiceDescriptionInfo>($"{serviceAddress}/api/serviceinfo/getbyname?name={name.ToUrlEncode()}", logInfos); return(serviceInfo); }
public TCenterService(ISystemConfigurationRepository systemConigurationRepository) { var crmService = StartupHelper.CreateCrmService(); _systemConigurationRepository = systemConigurationRepository; _crmService = crmService; dicHeadKey = "Prefer"; dicHead = new Dictionary <string, IEnumerable <string> >(); dicHead.Add(dicHeadKey, new List <string>() { "odata.include-annotations=\"*\"" }); //获取服务描述 var remoteServiceTCenter = _systemConigurationRepository.QueryByName(RemoteServiceNames.RemoteServiceTCenter); if (remoteServiceTCenter == null) { var fragment = new TextFragment() { Code = TextCodes.NotFoundRemoteServiceDescriptionByName, DefaultFormatting = "找不到名称为{0}的远程服务配置", ReplaceParameters = new List <object>() { RemoteServiceNames.RemoteServiceTCenter } }; throw new UtilityException((int)Errors.NotFoundRemoteServiceDescriptionByName, fragment); } //获取认证信息 var tCenterConfiguration = remoteServiceTCenter.GetConfigurationValue <TCenterConfiguration>(); if (tCenterConfiguration != null) { BaseUrl = tCenterConfiguration.Url; AuthInfos = tCenterConfiguration.AuthInfos; } }
public void Do(IEnumerable <Claim> claims) { var defaultContextInfoConfig = _systemConfigurationRepository.QueryByName(SystemConfigurationNames.DefaultContextInfo); if (defaultContextInfoConfig == null) { var fragment = new TextFragment() { Code = TextCodes.NotFoundSystemConfigurationByName, DefaultFormatting = "找不到名称为{0}的系统配置", ReplaceParameters = new List <object>() { SystemConfigurationNames.DefaultContextInfo } }; throw new UtilityException((int)Errors.NotFoundSystemConfigurationByName, fragment); } var contextInfo = defaultContextInfoConfig.GetConfigurationValue <DefaultContextInfo>(); if (contextInfo == null) { var fragment = new TextFragment() { Code = TextCodes.SystemConfigurationConvertTypeFail, DefaultFormatting = "系统配置{0}转成类型{1}失败,配置内容为{2}", ReplaceParameters = new List <object>() { SystemConfigurationNames.DefaultContextInfo, typeof(DefaultContextInfo).FullName, defaultContextInfoConfig.Content } }; throw new UtilityException((int)Errors.SystemConfigurationConvertTypeFail, fragment); } ContextContainer.SetValue <string>(ContextTypes.CurrentUserId, contextInfo.UserID); ContextContainer.SetValue <int>(ContextTypes.CurrentUserLcid, contextInfo.Lcid); ContextContainer.SetValue <int>(ContextTypes.CurrentUserTimezoneOffset, contextInfo.TimezoneOffset); ContextContainer.SetValue <Dictionary <string, object> >(ContextTypes.Dictionary, new Dictionary <string, object>()); }