Example #1
0
        public string Get(webReq req)
        {
            var    status      = req.status;
            string search      = req.search == null ? "" : req.search; //搜索内容
            int    index       = Convert.ToInt32(req.index);           //页码
            int    articleType = Convert.ToInt32(req.articleType);
            int    pages       = 0;                                    //总页数
            int    size        = 12;                                   //一页size条数据

            var condition = " isdeleted=0 ";

            if (articleType != 2)
            {
                condition += " and isarticle = " + articleType;
            }

            if (status != 2)
            {
                condition += " and status = " + status;
            }

            condition += " and ( articleName like '%" + search + "%' or content like '%" + search + "%' )";

            string str     = "select id,lasttime,status from articleInfo where " + condition + " order by status desc,lastTime desc";
            var    listAll = SqlHelperHere.ExecuteGetList <ArticleInfo>(str);

            if (listAll.Count < 1)
            {
                return(JsonHelperHere.EmptyJson());
            }
            var ids = listAll.Skip((index - 1) * size).Take(size).Select(p => p.id).ToArray();

            if (ids.Count() < 1)
            {
                return(JsonHelperHere.EmptyJson());
            }
            var idsStr = string.Join(",", ids);

            var list = CacheHelper.GetByCondition <ArticleView>("ArticleView", " id in (" + idsStr + ")");

            var count = listAll.Count;

            pages = count / size;
            //总页数
            pages = pages * size == count ? pages : pages + 1;
            var listR = new List <ArticleViewForWeb>();

            foreach (var item in list)
            {
                ArticleViewForWeb temp = new ArticleViewForWeb(item);
                listR.Add(temp);
            }

            return(JsonHelperHere.JsonAddPage(pages, JsonConvert.SerializeObject(listR.OrderByDescending(p => p.status).ThenBy(p => p.lastTime)), index));
        }
Example #2
0
        public string GetDownloadList(webReq req)
        {
            ResultForWeb r = new ResultForWeb
            {
                HttpCode = 200,
                Message  = "",
                data     = "{}"
            };
            string search    = req.search == null ? "" : req.search; //搜索内容
            int    index     = Convert.ToInt32(req.index);           //页码
            int    pages     = 0;                                    //总页数
            int    size      = 12;                                   //一页size条数据
            var    isRepeat  = Convert.ToInt32(req.isRepeat);
            var    condition = " ";

            if (isRepeat != 2)
            {
                condition += " isRepeat=" + isRepeat + " and ";
            }
            condition += " 1=1 and  name like '%" + search + "%' ";

            string str     = "select * from couponView where " + condition + " order by createTime desc";
            var    listAll = SqlHelperHere.ExecuteGetList <CouponView>(str);

            if (listAll.Count < 1)
            {
                r.data = JsonHelperHere.EmptyJson();
                return(JsonConvert.SerializeObject(r));
            }
            //分页
            var list2 = listAll.Skip((index - 1) * size).Take(size).ToArray();

            if (list2.Length < 1)
            {
                r.data = JsonHelperHere.EmptyJson();
                return(JsonConvert.SerializeObject(r));
            }

            var count = listAll.Count;

            pages = count / size;
            //总页数
            pages = pages * size == count ? pages : pages + 1;
            var listR = new List <DownList>();

            foreach (var item in list2)
            {
                DownList d = new DownList(item);
                listR.Add(d);
            }

            r.data = JsonHelperHere.JsonAddPage(pages, JsonConvert.SerializeObject(listR), index);
            return(JsonConvert.SerializeObject(r));
        }
Example #3
0
        public string GetDownloadList(webReq req)
        {
            string search    = Request["search"] == null ? "" : Request["search"]; //搜索内容
            int    index     = Convert.ToInt32(Request["index"]);                  //页码
            int    pages     = 0;                                                  //总页数
            int    size      = 12;                                                 //一页size条数据
            var    isRepeat  = Convert.ToInt32(req.isRepeat);
            var    condition = " ";

            if (isRepeat != 2)
            {
                condition += " isRepeat=" + isRepeat + " and ";
            }
            condition += " 1=1 and  name like '%" + search + "%' ";

            string str     = "select * from couponView where " + condition + " order by createTime desc";
            var    listAll = SqlHelperHere.ExecuteGetList <CouponView>(str);

            if (listAll.Count < 1)
            {
                return(JsonHelperHere.EmptyJson());
            }
            //分页
            var list2 = listAll.Skip((index - 1) * size).Take(size).ToArray();

            if (list2.Length < 1)
            {
                return(JsonHelperHere.EmptyJson());
            }
            //var idsStr = string.Join(",", ids);
            //查具体信息
            //var viewList = CacheHelper.GetByCondition<CouponView>("CouponView", " name in (" + idsStr + ")");


            var count = listAll.Count;

            pages = count / size;
            //总页数
            pages = pages * size == count ? pages : pages + 1;
            var listR = new List <DownList>();

            foreach (var item in list2)
            {
                DownList d = new DownList(item);
                listR.Add(d);
            }

            return(JsonHelperHere.JsonAddPage(pages, JsonConvert.SerializeObject(listR), index));
        }
Example #4
0
        /// <summary>
        /// 清除过期的预定菜品
        /// </summary>
        public void ClearWeekFood()
        {
            var now = Convert.ToInt32(DateTime.Now.DayOfWeek);

            now = now == 0 ? 7 : now;
            var    dt   = DateTime.Now.AddDays((7 - now) - 14);
            string str  = "select id from foodview where isWeek=0 and foodTime<'" + dt.ToString("yyyy-MM-dd") + "'";
            var    list = SqlHelperHere.ExecuteGetList <FoodView>(str);

            if (list.Count > 0)
            {
                foreach (var item in list)
                {
                    var food = new FoodInfo();
                    food.id        = item.id;
                    food.isDeleted = true;
                    food.isOn      = false;
                    FoodInfoOper.Instance.Update(food);
                }
            }
        }