Esempio n. 1
0
        /// <summary>
        /// 分页查询数据
        /// </summary>
        /// <param name="page"></param>
        /// <param name="rows"></param>
        /// <param name="sidx"></param>
        /// <param name="sord"></param>
        /// <returns></returns>
        public ActionResult GetPageDataListForContacts(int page = 1, int rows = 50, string sidx = "", string sord = "")
        {
            string Manager = Request["Manager"];
            //分页
            PageInfo pager = new PageInfo();

            pager.CurrentPageIndex = page;
            pager.PageSize         = rows;
            pager.Sidx             = sidx;
            pager.Sord             = sord;
            long          total = 0;
            QueryDocument query = new QueryDocument();

            if (!string.IsNullOrWhiteSpace(Manager))
            {
                query.Set("_id", new MongoDB.Bson.BsonRegularExpression(Manager));
            }
            SortByDocument sortBy = new SortByDocument();

            sortBy.Set("LatestTime", -1);
            var list = appService.GetPageListAppContacts(query, sortBy, pager.CurrentPageIndex, pager.PageSize, out total);

            #region 分页处理
            //翻页处理
            SubPageResult <AppContactsInfo> result = new SubPageResult <AppContactsInfo>();
            result.rows    = list;
            result.page    = page;
            result.records = (int)total;
            result.total   = (result.records + pager.PageSize - 1) / pager.PageSize;
            #endregion
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        /// <summary>
        /// 分页查询数据
        /// </summary>
        /// <param name="serviceId"></param>
        /// <param name="page"></param>
        /// <param name="rows"></param>
        /// <param name="sidx"></param>
        /// <param name="sord"></param>
        /// <returns></returns>
        public ActionResult GetPageDataListForContacts(string serviceId, int page = 1, int rows = 50, string sidx = "", string sord = "")
        {
            //分页
            var pager = new PageInfo
            {
                CurrentPageIndex = page,
                PageSize         = rows,
                Sidx             = sidx,
                Sord             = sord
            };
            long total = 0;
            var  query = new QueryDocument();

            var sortBy = new SortByDocument();

            sortBy.Set("LatestTime", -1);
            var list = new List <ServiceAlertContactsInfo>();
            int id;

            if (!string.IsNullOrWhiteSpace(serviceId) && int.TryParse(serviceId, out id))
            {
                query.Set("ServiceId", id);
                list = AppService.GetPageListServiceAlertContactsInfos(query, sortBy, pager.CurrentPageIndex, pager.PageSize, out total);
            }
            #region 分页处理
            //翻页处理
            SubPageResult <ServiceAlertContactsInfo> result = new SubPageResult <ServiceAlertContactsInfo>();
            result.rows    = list;
            result.page    = page;
            result.records = (int)total;
            result.total   = (result.records + pager.PageSize - 1) / pager.PageSize;
            #endregion
            return(Json(result, JsonRequestBehavior.AllowGet));
        }