Example #1
0
        public IEnumerable <ProductVM> GetList(string query, int typeId, int cateId, int limited, int offset, ProductSort?sort)
        {
            var result = _productSer.GetList(query, typeId, cateId, limited, offset, sort);

            RespHelper.AddTotalPage(HttpContext, result.Total);
            return(result.Products);
        }
Example #2
0
        public IEnumerable <UserVM> GetList(int limited, int offset, string query = null)
        {
            var result = _userSer.GetList(query, limited, offset);

            RespHelper.AddTotalPage(HttpContext, result.TotalItem);
            return(result.Users);
        }
Example #3
0
        public ActionResult <IEnumerable <OrderVM> > GetListByUser(string userId, int provinceId, int limited, int offset)
        {
            if (string.IsNullOrEmpty(userId) || string.IsNullOrWhiteSpace(userId))
            {
                return(BadRequest());
            }
            var result = _orderSer.GetListByUser(userId, provinceId, limited, offset);

            RespHelper.AddTotalPage(HttpContext, result.TotalItem);
            return(Ok(result.Orders));
        }
Example #4
0
        public ActionResult <ICollection <OrderVM> > GetList(string start, string end, int provinceId, int limited, int offset)
        {
            if (start == null || end == null)
            {
                return(BadRequest());
            }
            var result = _orderSer.GetList(start, end, provinceId, limited, offset);

            RespHelper.AddTotalPage(HttpContext, result.TotalItem);
            return(Ok(result.Orders));
        }
Example #5
0
		public void Get(string key, Stream destination, int bufferSize = 1024)
		{
			var cmd = "GET".Input(key).FlagKey(key);
			LogCall(cmd, () =>
			{
				using (var rds = _adapter.GetRedisSocket(cmd))
				{
					rds.Write(cmd);
					RespHelper.ReadChunk(rds.Stream, destination, bufferSize);
				}
				return default(string);
			});
		}
Example #6
0
            static void EndPipe(IRedisSocket rds, IEnumerable <PipelineCommand> cmds)
            {
                var err = new List <PipelineCommand>();
                var ms  = new MemoryStream();

                try
                {
                    foreach (var cmd in cmds)
                    {
                        RespHelper.Write(ms, rds.Encoding, cmd.Command, rds.Protocol);
                    }

                    if (rds.IsConnected == false)
                    {
                        rds.Connect();
                    }
                    ms.Position = 0;
                    ms.CopyTo(rds.Stream);

                    foreach (var pc in cmds)
                    {
                        pc.Command._redisSocket = rds;
                        pc.Result = pc.Parse(pc);
                        if (pc.Command.ReadResult.IsError)
                        {
                            err.Add(pc);
                        }
                    }
                }
                finally
                {
                    ms.Close();
                    ms.Dispose();
                    rds?.Dispose();
                }

                if (err.Any())
                {
                    var sb = new StringBuilder();
                    for (var a = 0; a < err.Count; a++)
                    {
                        var cmd = err[a].Command;
                        if (a > 0)
                        {
                            sb.Append("\r\n");
                        }
                        sb.Append(cmd.ReadResult.SimpleError).Append(" {").Append(cmd.ToString()).Append("}");
                    }
                    throw new RedisException(sb.ToString());
                }
            }
Example #7
0
 private JArray getRes(JToken res = null) => RespHelper.getRes(res);
Example #8
0
 private JArray getErrorRes(string code) => RespHelper.getErrorRes(code);
Example #9
0
 private bool checkResCode(JArray res) => RespHelper.checkResCode(res);