Esempio n. 1
0
        public IActionResult Index()
        {
            List <Model.Blog> list = dal.GetList("1=1 order by sort asc,id desc");

            ViewBag.calist = cadal.GetList("");
            return(View(list));
        }
Esempio n. 2
0
        public IActionResult List(string key, string startdate, string enddate, string cabh, int pagesize = 12, int pageindex = 1)
        {
            string cond = "1=1";

            if (!string.IsNullOrEmpty(key))
            {
                key   = CommonTools.GetSafeSQL(key);
                cond += $" and Title like '%{key}%'";
            }
            if (!string.IsNullOrEmpty(startdate))
            {
                startdate = CommonTools.GetSafeSQL(startdate);
                cond     += $" and replace(CONVERT(char(10),CreateDate,111),'/','-')>='{startdate}'";
            }
            if (!string.IsNullOrEmpty(enddate))
            {
                enddate = CommonTools.GetSafeSQL(enddate);
                cond   += $" and replace(CONVERT(char(10),CreateDate,111),'/','-')<='{enddate}'";
            }
            if (!string.IsNullOrEmpty(cabh) && cabh != "0")
            {
                cabh  = CommonTools.GetSafeSQL(cabh);
                cond += $" and CateNo='{cabh}'";
            }
            int total              = blogdal.CalcCount(cond);
            int pagecount          = total % pagesize == 0 ? total / pagesize : total / pagesize + 1;//总页数
            List <Model.Blog> list = blogdal.GetList("id desc", pagesize, pageindex, cond);
            string            str  = CommonTools.ToJsonString(new { totalrecord = total, pagecount = pagecount, list = list });

            return(Content(str));
        }
Esempio n. 3
0
        public IActionResult List(string key, string month, string cate, int pagesize = 12, int pageindex = 1)
        {
            string cond = "1=1";

            if (!string.IsNullOrEmpty(key))
            {
                key   = CommonTools.GetSafeSQL(key);
                cond += $" and Title like '%{key}%'";
            }
            if (!string.IsNullOrEmpty(month))
            {
                month = CommonTools.GetSafeSQL(month);
                DateTime d = DateTime.Parse(month + "-01");
                cond += $"and CreateDate >= '{d:yyyy-MM-dd}' and CreateDate < '{d.AddMonths(1):yyyy-MM-dd}'";
            }
            if (!string.IsNullOrEmpty(cate) && cate != "0")
            {
                cate  = CommonTools.GetSafeSQL(cate);
                cond += $" and CateNo='{cate}'";
            }
            int total              = blogdal.CalcCount(cond);
            int pagecount          = total % pagesize == 0 ? total / pagesize : total / pagesize + 1;//总页数
            List <Model.Blog> list = blogdal.GetList("id desc", pagesize, pageindex, cond);
            string            str  = CommonTools.ToJsonString(new { totalrecord = total, pagecount = pagecount, list = list });

            return(Content(str));
        }
Esempio n. 4
0
        public IActionResult List(int pageindex, int pagesize, string key, string Date, string CaBh)
        {
            List <Model.Blog> list = dal.GetList("*", "sort asc,id desc", pagesize, pageindex, GetCond(key, Date, CaBh));
            ArrayList         arr  = new ArrayList();

            foreach (var item in list)
            {
                arr.Add(new
                {
                    id         = item.Id,
                    title      = item.Title,
                    createTime = item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    desc       = Tool.StringTruncat(Tool.GetNoHTMLString(item.Body), 60, "..."),
                    caName     = item.CaName,
                });
            }
            return(Json(arr));
        }
Esempio n. 5
0
        public IActionResult GetBlogList(int pageIndex, int pageSize, string key, string start, string end, string number)
        {
            List <Model.Blog> list  = dal.GetList("sort asc,id asc", pageIndex, pageSize, GetCond(key, start, end, number));
            ArrayList         alist = new ArrayList();

            foreach (Model.Blog b in list)
            {
                alist.Add(new {
                    id           = b.Id,
                    createDate   = b.CreateDate.ToString("yyyy-MM-dd hh:mm"),
                    title        = b.Title,
                    visitNum     = b.VisitNum,
                    categoryName = b.CategoryName,
                    sort         = b.Sort
                });
            }
            return(Json(alist));
        }
Esempio n. 6
0
        /// <summary>
        /// 取分页数据,返回 JSON
        /// </summary>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public IActionResult List(int pageindex, int pagesize, string key, string month, string cabh)
        {
            List <Model.Blog> list = dal.GetList("sort asc,id desc", pagesize, pageindex, GetCond(key, month, cabh));
            ArrayList         arr  = new ArrayList();

            foreach (var item in list)
            {
                arr.Add(new
                {
                    id         = item.Id,
                    title      = item.Title,
                    createDate = item.CreateDate,
                    caName     = item.CaName,
                    desc       = Tool.ReplaceHtmlTag(item.Body, 60),
                });
            }
            return(Json(arr));
        }
Esempio n. 7
0
        public IActionResult GetBlogList(int pageIndex, int pageSize, string key, string para)
        {
            List <Model.Blog> list  = dal.GetList("sort asc,id asc", pageIndex, pageSize, GetCond(key, para));
            ArrayList         alist = new ArrayList();

            foreach (Model.Blog b in list)
            {
                alist.Add(new {
                    id           = b.Id,
                    createDate   = b.CreateDate.ToString("yyyy-MM-dd"),
                    title        = b.Title,
                    body         = Tool.StringTruncat(Tool.GetNoHTMLString(b.Body), 60, "......"),
                    categoryName = b.CategoryName,
                    categoryNum  = b.CategoryNum
                });
            }
            return(Json(alist));
        }
Esempio n. 8
0
        /// <summary>
        /// 取分页数据,返回 JSON
        /// </summary>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public IActionResult List(int pageindex, int pagesize, string key, string start, string end, string cabh)
        {
            List <Model.Blog> list = dal.GetList("sort asc,id desc", pagesize, pageindex, GetCond(key, start, end, cabh));
            ArrayList         arr  = new ArrayList();

            foreach (var item in list)
            {
                arr.Add(new
                {
                    id         = item.Id,
                    title      = item.Title,
                    createDate = item.CreateDate.ToString("yyyy-MM-dd HH:mm"),
                    visitNum   = item.VisitNum,
                    caName     = item.CaName,
                    sort       = item.Sort,
                });
            }
            return(Json(arr));
        }
Esempio n. 9
0
        /// <summary>
        /// 取博客总记录数
        /// </summary>
        /// <returns></returns>

        /// <summary>
        /// 取分页数据,返回json
        /// </summary>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public ActionResult List(int pageindex, int pagesize, string key, string month, string cabh)
        {
            List <Model.Blog> list = dal.GetList("sort asc,id desc", pagesize, pageindex, GetCond(key, month, cabh));
            ArrayList         arr  = new ArrayList();

            foreach (var item in list)
            {
                arr.Add(new
                {
                    id    = item.Id,
                    title = item.Title,
                    //  updatetime = item..ToString("yyyy-MM-dd HH:mm"),
                    createDate = item.CreateDate.ToString("yyyy-MM-dd HH:mm"),
                    caName     = item.CaName,
                    desc       = Tool.StringTruncat(Tool.ReplaceHtmlTag(item.Body), 60, "....."),//取出HTML标签,再取出60个字符
                });
            }
            return(Json(arr));
        }