Exemplo n.º 1
0
        /// <summary>
        /// 更新配置信息
        /// </summary>
        /// <param name="file">配置文件名称</param>
        /// <param name="propertyInfo">配置信息</param>
        /// <returns></returns>
        public void Update(string file, List <ModifiedPropertyInfo> propertyInfo)
        {
            if (propertyInfo == null || propertyInfo.Count == 0)
            {
                throw new FrameworkException(ErrorCode.InvalidParameter, "参数无效, 配置更新列表为空");
            }

            var request = new ConfigurationModifyRequestType()
            {
                File               = file,
                AddedProperties    = Convert(propertyInfo.FindAll(p => p.Modify == false)),
                ModifiedProperties = Convert(propertyInfo.FindAll(p => p.Modify == true)),
                ForceOverride      = true
            };

            var result = client.Call <ConfigurationModifyRequestType, SoaResponseType>
                             ($"{GetConfigurationServerUri()}/api/configuration/modify", request, DEFAULT_TIMEOUT_IN_MS, serailzer);

            var response = result.Result;

            if (response.Header.ResponseCode != (int)ErrorCode.Success)
            {
                logger.Error("Synchronize configuration system failure");
                throw new SoaClientException(ErrorCode.ConfiurationModifyFailure,
                                             $"Configuration Update Failure, error code : {response.Header.ResponseCode}, remark : {response.Header.Remark}");
            }
        }
Exemplo n.º 2
0
        private ConfigurationQueryResponseType CallService(ConfigurationQueryRequestType request)
        {
            // 使用默认的地址 :
            // http://[env].configuration.colorstudio.com.cn
            var result = client.Call <ConfigurationQueryRequestType, ConfigurationQueryResponseType>
                             ($"{GetConfigurationServerUri()}/api/configuration/query", request, DEFAULT_TIMEOUT_IN_MS, serailzer);

            return(result.Result);
        }
Exemplo n.º 3
0
        public async Task <Resp> Call <Req, Resp>
            (string uri, string serviceId, string operationName, Req request, int timeoutInMs = DEFAULT_TIMEOUT_IN_MS)
        {
            if (string.IsNullOrEmpty(uri) || string.IsNullOrEmpty(serviceId) || string.IsNullOrEmpty(operationName))
            {
                throw new XFramework.Core.Abstractions.Error.FrameworkException(ErrorCode.InvalidUri,
                                                                                $"Invalid arguments, url : {uri}, service Id : {serviceId}, " +
                                                                                $"operation Name : {operationName}, any of these parameters is empty");
            }

            var address = BuildAddress(uri, serviceId, operationName);

            return(await serviceClient.Call <Req, Resp>(address, request, timeoutInMs, serializer));
        }