public JsonResult Get(int pageIndex, int pageSize, string pageOrder, int articleID, string fromDate, string toDate, int?groupID ) { DateTime?sDate = null, eDate = null; if (!String.IsNullOrWhiteSpace(fromDate)) { sDate = Utilities.ToEnglishDate(fromDate).Date; } if (!String.IsNullOrWhiteSpace(toDate)) { eDate = Utilities.ToEnglishDate(toDate).Date; } var list = ArticleVisits.Get(pageIndex, pageSize, pageOrder, articleID, sDate, eDate, groupID ); int total = ArticleVisits.Count(articleID, sDate, eDate, groupID); int totalPage = (int)Math.Ceiling((decimal)total / pageSize); if (pageSize > total) { pageSize = total; } if (list.Count < pageSize) { pageSize = list.Count; } JsonResult result = new JsonResult() { Data = new { TotalPages = totalPage, PageIndex = pageIndex, PageSize = pageSize, Rows = list }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return(result); }
private void increaseVisits(int id) { var ip = Utilities.GetIP(); var now = DateTime.Now; var threadStart = new ThreadStart(() => { Articles.AddVisits(id); ArticleVisit visit = new ArticleVisit { IP = ip, LastUpdate = now, UserID = UserID, ArticleID = id }; ArticleVisits.Insert(visit); }); Thread thread = new Thread(threadStart); thread.Start(); }