- 本文转载自:http://blog.csdn.net/hehui21/article/details/2874198
- public DataTable GetListReader(int pageI,int pPageListSize,out int pagecountI){
- if(!IndexReader.IndexExists(directory))MakeInit(directory);
- IndexReader reader = IndexReader.Open(directory);
- pagecountI=reader.NumDocs();
- DataTable DT=this.GetSegmentTable();
- pageI=Math.Max(1,pageI);
- int startLoopI=Math.Min(reader.NumDocs(),(pageI-1)*pPageListSize);
- int stopLoopI=Math.Min(reader.NumDocs(),pageI*pPageListSize);
- int trueID = -1;
- for(int iLoop=reader.MaxDoc()-1;iLoop>-1;iLoop--){
- if(!reader.IsDeleted(iLoop)){
- ++trueID;
- //System.Web.HttpContext.Current.Response.Write(trueID);
- if(trueID>stopLoopI )break;
- if(trueID>=startLoopI && trueID<stopLoopI){
- DataRow dr=DT.NewRow();
- dr[1]=Model.TUtility.CInt(reader.Document(iLoop).Get("ID"));
- dr[2]=Model.TUtility.CInt(reader.Document(iLoop).Get("UserID"));
- dr[3]=reader.Document(iLoop).Get("UserName");
- dr[4]=Model.TUtility.CInt(reader.Document(iLoop).Get("CatID"));
- dr[5]=reader.Document(iLoop).Get("Title");
- dr[6]=DateField.StringToDate(reader.Document(iLoop).Get("Time"));
- DT.Rows.Add(dr);
- }
- }
- }
- reader.Close();
- //IndexReader.Unlock(directory);
- return DT;
- }