/// <summary> /// 返回辩论帖子列表 /// </summary> /// <param name="postpramsInfo">参数对象</param> /// <param name="debateOpinion">辩论正反观点</param> /// <param name="postOrderType">排序类型</param> /// <returns></returns> public static List<ShowtopicPagePostInfo> GetDebatePostList(PostpramsInfo postpramsInfo, int debateOpinion, PostOrderType postOrderType) { IDataReader reader = DatabaseProvider.GetInstance().GetDebatePostList(postpramsInfo.Tid, debateOpinion, postpramsInfo.Pagesize, postpramsInfo.Pageindex, PostTables.GetPostTableId(postpramsInfo.Tid), postOrderType); return Posts.LoadPostList(postpramsInfo, reader); }
/// <summary> /// 装载帖子列表 /// </summary> /// <param name="postpramsInfo">参数对象</param> /// <param name="reader"></param> /// <returns></returns> public static List<ShowtopicPagePostInfo> LoadPostList(PostpramsInfo postpramsInfo, IDataReader reader) { List<ShowtopicPagePostInfo> postList = new List<ShowtopicPagePostInfo>(); //序号(楼层)的初值 int id = (postpramsInfo.Pageindex - 1) * postpramsInfo.Pagesize; while (reader.Read()) { //当帖子中的posterid字段为0时, 表示该数据出现异常 if (TypeConverter.ObjectToInt(reader["posterid"]) == 0) continue; ShowtopicPagePostInfo postInfo = LoadSingleShowtopicPagePostInfo(reader); //扩展属性 id++; postInfo.Id = id; postList.Add(postInfo); } reader.Close(); return postList; }
/// <summary> /// 获取ShowtopicPagePostInfo对象与ShowtopicPageAttachmentInfo对象列表 /// </summary> /// <param name="postPramsInfo">参数对象</param> /// <param name="attachmentList">输出附件列表</param> /// <returns></returns> public static ShowtopicPagePostInfo GetPostInfoWithAttachments(PostpramsInfo postPramsInfo, out List<ShowtopicPageAttachmentInfo> attachmentList) { attachmentList = new List<ShowtopicPageAttachmentInfo>(); //得到帖子对应主题的所有附件,因为ACCESS不支持存储过程,故此方法在ACCESS版中做了特殊处理 IDataReader attachmentReader; IDataReader reader = DatabaseProvider.GetInstance().GetSinglePost(out attachmentReader, postPramsInfo, PostTables.GetPostTableId(postPramsInfo.Tid)); //Access版运行此处逻辑 bool isAccess = false; if (attachmentReader == null) attachmentReader = reader; else isAccess = true; while (attachmentReader.Read()) attachmentList.Add(Attachments.LoadSingleAttachmentInfo(attachmentReader)); //bool next = false; //Access版运行此处逻辑 if (!isAccess) { reader.NextResult(); } ShowtopicPagePostInfo postInfo = null; if (reader.Read()) postInfo = LoadSingleShowtopicPagePostInfo(reader); reader.Close(); if (!attachmentReader.IsClosed) attachmentReader.Close(); return postInfo; }
/// <summary> /// 获取指定条件的帖子DataSet /// </summary> /// <param name="_postpramsinfo">参数列表</param> /// <returns>指定条件的帖子DataSet</returns> public static List<ShowtopicPagePostInfo> GetPostList(PostpramsInfo postpramsInfo) { IDataReader reader; string postTableId = PostTables.GetPostTableId(postpramsInfo.Tid); if (!postpramsInfo.Condition.Equals("")) reader = DatabaseProvider.GetInstance().GetPostListByCondition(postpramsInfo, postTableId); else { //更新Cache缓存中的帖子信息(目前只对当前分表进行查询,这主要出于将所有分表数据转换对于某些中型论坛的服务器硬盘内存要求过高的暂时方案) if (postTableId == PostTables.GetPostTableId() && appDBCache && IPostService != null) { List<ShowtopicPagePostInfo> list = IPostService.GetPostList(postpramsInfo, postTableId); if (list != null && list.Count > 0) return list; } reader = DatabaseProvider.GetInstance().GetPostList(postpramsInfo, postTableId); } return LoadPostList(postpramsInfo, reader); }
/// <summary> /// 获得最后回复的帖子列表,支持分页 /// </summary> /// <param name="postpramsInfo">参数对象</param> /// <returns></returns> public static DataTable GetPagedLastPostDataTable(PostpramsInfo postpramsInfo) { return DatabaseProvider.GetInstance().GetPagedLastPostList(postpramsInfo, PostTables.GetPostTableName(postpramsInfo.Tid)); }