public void AddPage(Type t, String condition, ObjectPage pager, IList list) { String key = CacheKey.getPageList(t, condition, pager.getSize(), pager.getCurrent()); addList(key, list); addToApplication(CacheKey.getPagerInfoKey(key), pager); // 添加分页统计数据 }
/// <summary> /// 根据查询条件、每页数量,返回分页数据集合 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="condition">查询条件</param> /// <param name="pageSize">每页需要显示的数据量</param> /// <returns>分页数据列表,包括当前页、总记录数、分页条等</returns> public static DataPage <T> findPage <T>(String condition, int pageSize) where T : IEntity { if (pageSize <= 0) { pageSize = 20; } ObjectInfo state = new ObjectInfo(typeof(T)); state.includeAll(); state.Pager.setSize(pageSize); IPageList result = ObjectPool.FindPage(typeof(T), condition, state.Pager); if (result == null) { IList list = ObjectDB.FindPage(state, condition); ObjectPage p = state.Pager; ObjectPool.AddPage(typeof(T), condition, p, list); result = new PageList(); result.Results = list; result.PageCount = p.PageCount; result.RecordCount = p.RecordCount; result.Size = p.getSize(); result.PageBar = p.PageBar; result.Current = p.getCurrent(); } else { result.PageBar = new ObjectPage(result.RecordCount, result.Size, result.Current).PageBar; } return(new DataPage <T>(result)); }
public IPageList FindPage(Type t, String condition, ObjectPage pager) { String key = CacheKey.getPageList(t, condition, pager.getSize(), pager.getCurrent()); logger.Debug("FindPage=>" + t.FullName); IList list = getListFromCache(key, t); if (list == null) { return(null); } IPageList result = new PageList(); ObjectPage pageInfo = getPagerInfo(key); if (pageInfo == null) { return(null); } result.Results = list; result.PageCount = pageInfo.PageCount; result.RecordCount = pageInfo.RecordCount; result.Size = pageInfo.getSize(); result.PageBar = pageInfo.PageBar; result.Current = pageInfo.getCurrent(); return(result); }
public int beginCount( String countSql, ObjectPage pager, EntityInfo entityInfo ) { String commandText = countSql; logger.Info( "[Page Record Count] " + commandText ); IDbCommand command = DataFactory.GetCommand( commandText, DbContext.getConnection( entityInfo ) ); pager.RecordCount = cvt.ToInt( command.ExecuteScalar() ); pager.computePageCount(); pager.resetCurrent(); return pager.getCurrent(); }
public int beginCount(String countSql, ObjectPage pager, EntityInfo entityInfo) { String commandText = countSql; logger.Info("[Page Record Count] " + commandText); IDbCommand command = DataFactory.GetCommand(commandText, DbContext.getConnection(entityInfo)); pager.RecordCount = cvt.ToInt(command.ExecuteScalar()); pager.computePageCount(); pager.resetCurrent(); return(pager.getCurrent()); }
public static DataPage <T> GetPage(List <T> list, int pageSize, int pageIndex = 0) { ObjectPage op = new ObjectPage(); if (pageSize <= 0) { pageSize = 20; } op.setSize(pageSize); op.RecordCount = list.Count; // 计算页数 op.computePageCount(); // 矫正当前页码 int currentPageNumber = CurrentRequest.getCurrentPage(); if (pageIndex > 0) { currentPageNumber = pageIndex; } op.setCurrent(currentPageNumber); op.resetCurrent(); currentPageNumber = op.getCurrent(); // 得到结果集 List <T> results = new List <T>(); int start = (currentPageNumber - 1) * pageSize; int count = 1; for (int i = start; i < list.Count; i++) { if (count > pageSize) { break; } results.Add(list[i]); count++; } // 填充分页数据 DataPage <T> page = new DataPage <T>(); page.Results = results; page.Current = currentPageNumber; page.Size = pageSize; page.RecordCount = list.Count; page.PageCount = op.PageCount; return(page); }
public void AddPage( Type t, String condition, ObjectPage pager, IList list ) { String key = CacheKey.getPageList( t, condition, pager.getSize(), pager.getCurrent() ); addList( key, list ); addToApplication( CacheKey.getPagerInfoKey( key ), pager ); // 添加分页统计数据 }
public IPageList FindPage( Type t, String condition, ObjectPage pager ) { String key = CacheKey.getPageList( t, condition, pager.getSize(), pager.getCurrent() ); logger.Debug( "FindPage=>" + t.FullName ); IList list = getListFromCache( key, t ); if (list == null) return null; IPageList result = new PageList(); ObjectPage pageInfo = getPagerInfo( key ); if (pageInfo == null) return null; result.Results = list; result.PageCount = pageInfo.PageCount; result.RecordCount = pageInfo.RecordCount; result.Size = pageInfo.getSize(); result.PageBar = pageInfo.PageBar; result.Current = pageInfo.getCurrent(); return result; }
public void AddPage(Type t, String condition, ObjectPage pager, IList list) { String key = CacheKey.getPageList(t, condition, pager.getSize(), pager.getCurrent()); addList(key, list); }
public void AddPage( Type t, String condition, ObjectPage pager, IList list ) { String key = CacheKey.getPageList( t, condition, pager.getSize(), pager.getCurrent() ); addList( key, list ); }