Exemplo n.º 1
0
 public string GetLastChangedTime(FetchFilter filter)
 {
     return(this.CallApi(GetLastChangedTimeResource, request =>
     {
         request.AddJsonBody(filter);
     }));
 }
Exemplo n.º 2
0
 public string GetAllConfigs(FetchFilter filter)
 {
     return(this.CallApi(GetAllConfigsResource, request =>
     {
         request.AddJsonBody(filter);
         request.Timeout = 300000;
     }));
 }
Exemplo n.º 3
0
 /// <summary>
 /// 获取指定应用的最后一次更新时间
 /// </summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 public Task <DateTime> GetLastChangedTime(FetchFilter filter)
 {
     return(this.CallApi <DateTime>(GetLastChangedTimeResource, async r =>
     {
         var response = await this._client.ExecuteTaskAsync(r).ConfigureAwait(false);
         return DateTime.Parse(response.Content);
     }, filter));
 }
Exemplo n.º 4
0
 protected override Expression VisitBinary(BinaryExpression b)
 {
     // this means we'll tend to have a redundant filter on top, but it eases the code
     FetchFilter filter = new FetchFilter(FetchFilterType.And);
     this.stmt.Entity.Filter = filter;
     this.VisitBinary(b, filter);
     return b;
 }
Exemplo n.º 5
0
        //[CheckModelForNull]
        public async Task <IHttpActionResult> GetConfigs([FromBody] FetchFilter request)
        {
            var condition = new ConfigRequest
            {
                AppId   = await GetAppId(request.AppName),
                EnvId   = await GetEnvId(request.Environment),
                Version = request.Version,
            };
            var response = await _configService.GetConfigs(condition);

            if (response.HasError)
            {
                return(Json(response.Error));
            }
            else
            {
                return(Json(response.Result));
            }
        }
Exemplo n.º 6
0
 public Struct(string style, string conentType, FetchFilter getFilter)
 {
     Style       = style;
     ContentType = conentType;
     GetFilter   = getFilter;
 }
Exemplo n.º 7
0
 /// <summary>
 /// 批量获取所有的配置信息
 /// </summary>
 /// <param name="filter"></param>
 /// <returns></returns>
 public Task <IDictionary <ConfigType, IDictionary <string, string> > > GetAllConfigs(FetchFilter filter)
 {
     return(this.CallApi(GetAllConfigsResource, async r =>
     {
         var response = await this._client.ExecuteTaskAsync <IDictionary <ConfigType, IDictionary <string, string> > >(r).ConfigureAwait(false);
         return response.Data;
     }));
 }
Exemplo n.º 8
0
        private async Task <IDictionary <ConfigType, IDictionary <string, string> > > GetConfigsFromServer(FetchFilter filter, DateTime ltimeFromServer)
        {
            var configs = await this._fetcher.GetAllConfigs(filter).ConfigureAwait(false);

            if (configs != null && configs.Count > 0)
            {
                //本地持久化
                foreach (var kv in configs)
                {
                    var pre = this._preservations.FirstOrDefault(p => p.ConfigType == kv.Key);
                    if (pre != null)
                    {
                        pre.WriteAll(kv.Value);
                        pre.LastWriteTime = ltimeFromServer;
                    }
                }
            }
            return(configs);
        }
Exemplo n.º 9
0
        protected void VisitBinary(Expression e, FetchFilter filter)
        {

            if (e is BinaryExpression)
            {
                BinaryExpression b = e as BinaryExpression;
                FetchFilter newFilter;
                FetchCondition cond = new FetchCondition();
                switch (b.NodeType)
                {
                    case ExpressionType.And:
                    case ExpressionType.AndAlso:
                        newFilter = new FetchFilter(FetchFilterType.And);
                        this.VisitBinary(b.Left, newFilter);
                        this.VisitBinary(b.Right, newFilter);
                        filter.Filters.Add(newFilter);
                        break;
                    case ExpressionType.Or:
                    case ExpressionType.OrElse:
                        newFilter = new FetchFilter(FetchFilterType.Or);
                        this.VisitBinary(b.Left, newFilter);
                        this.VisitBinary(b.Right, newFilter);
                        filter.Filters.Add(newFilter);
                        break;
                    case ExpressionType.Equal:
                        cond.ConditionOperator = FetchConditionOperator.Equal;
                        SetConditionalValues(cond, b);
                        filter.Conditions.Add(cond);
                        break;
                    case ExpressionType.NotEqual:
                        cond.ConditionOperator = FetchConditionOperator.NotEqual;
                        SetConditionalValues(cond, b);
                        filter.Conditions.Add(cond);
                        break;
                    case ExpressionType.LessThan:
                        cond.ConditionOperator = FetchConditionOperator.LowerThan;
                        SetConditionalValues(cond, b);
                        filter.Conditions.Add(cond);
                        break;
                    case ExpressionType.LessThanOrEqual:
                        cond.ConditionOperator = FetchConditionOperator.LowerEqual;
                        SetConditionalValues(cond, b);
                        filter.Conditions.Add(cond);
                        break;
                    case ExpressionType.GreaterThan:
                        cond.ConditionOperator = FetchConditionOperator.GreaterThan;
                        SetConditionalValues(cond, b);
                        filter.Conditions.Add(cond);
                        break;
                    case ExpressionType.GreaterThanOrEqual:
                        cond.ConditionOperator = FetchConditionOperator.GreaterEqual;
                        SetConditionalValues(cond, b);
                        filter.Conditions.Add(cond);
                        break;
                    default:
                        throw new NotSupportedException(string.Format("The binary operator '{0}' is not supported", b.NodeType));
                }
            }
            else
            {
                //not binaryexpression, boolean constant?
                throw new ArgumentException();
            }
        }