public static EssencePostItem AssembleItem(BCW.Model.Text _text) { EssencePostItem _item = new EssencePostItem(); _item.threadId = _text.ID; _item.authorId = _text.UsID; _item.author = _text.UsName; _item.authorImg = "http://" + Utils.GetDomain() + new BCW.BLL.User().GetPhoto(_text.UsID); _item.forumId = _text.ForumId; _item.title = _text.Title; _item.content = Out.SysUBB(_text.Content); _item.ubb_content = _text.Content; _item.preview = "http://" + Utils.GetDomain() + new BCW.BLL.User().GetPhoto(_text.UsID);//string.IsNullOrEmpty(_text.GoodSmallIcon) ? "http://" + Utils.GetDomain() + "/Files/threadImg/def.png" : "http://" + Utils.GetDomain() + new BCW.BLL.User().GetPhoto(_text.UsID); ; BCW.Model.Forum _forummodel = new BCW.BLL.Forum().GetForum(_item.forumId); _item.forum = _forummodel != null ? _forummodel.Title : ""; _item.views = _text.ReadNum; _item.replys = _text.ReplyNum; System.DateTime _startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); _item.addTime = (long)(_text.AddTime - _startTime).TotalSeconds; //打赏 DataSet _dsCent = new BCW.BLL.Textcent().GetList("isnull(SUM(Cents),0)cents", "BID='" + _item.threadId + "'"); _item.likes = int.Parse(_dsCent.Tables[0].Rows[0]["cents"].ToString()); _item.IsGood = _text.IsGood; _item.IsRecom = _text.IsRecom; _item.IsLock = _text.IsLock; _item.IsTop = _text.IsTop; return(_item); }
public void InitData(int ForumId, int postId, int ptype, int _userId) { this.finish = true; items.Clear(); string strWhere = string.Empty; string strOrder = string.Empty; string[] pageValUrl = { "act", "forumid", "tsid", "ptype", "backurl" }; strWhere = "IsDel=0 and HideType<>9"; if (ptype == 1) { strWhere += " and IsGood=1"; } else if (ptype == 2) { strWhere += " and IsRecom=1"; } if (ptype == 3) { strWhere += " and AddTime>='" + DateTime.Now.AddDays(-2) + "'"; } else if (ptype == 4) { strWhere += " and IsLock=1"; } else if (ptype == 5) { strWhere += " and IsTop=-1"; } if (ForumId > 0) { strWhere += " and ForumId=" + ForumId.ToString(); } if (_userId > 0) { strWhere += " and UsID=" + _userId.ToString(); } if (postId >= 0) { strWhere += " and 1=1"; } //排序条件 if (ForumId > 0 && postId < 0) { strOrder += "IsTop desc,"; } strOrder += "ID Desc"; DataSet _ds = new BCW.BLL.Text().GetList(string.Format("TOP {0} ID,ForumId,Types,LabelId,Title,Content,UsID,UsName,ReplyNum,ReadNum,IsGood,IsRecom,IsLock,IsTop,IsOver,AddTime,Gaddnum,Gwinnum,GoodSmallIcon", RECORD_COUNT), strWhere.Replace("1=1", "ID<" + postId) + " Order by " + strOrder); if (_ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < _ds.Tables[0].Rows.Count; i++) { BCW.Model.Text _textModal = new BCW.BLL.Text().GetText(int.Parse(_ds.Tables[0].Rows[i]["ID"].ToString())); EssencePostItem _essencePostItem = AssembleItem(_textModal); //new EssencePostItem(); //_essencePostItem.threadId = int.Parse(_ds.Tables[0].Rows[i]["ID"].ToString()); //_essencePostItem.authorId = int.Parse(_ds.Tables[0].Rows[i]["UsID"].ToString()); //_essencePostItem.author = _ds.Tables[0].Rows[i]["UsName"].ToString(); //_essencePostItem.authorImg = "http://" + Utils.GetDomain() + new BCW.BLL.User().GetPhoto(int.Parse(_ds.Tables[0].Rows[i]["UsID"].ToString())); //_essencePostItem.forumId = int.Parse(_ds.Tables[0].Rows[i]["ForumId"].ToString()); //_essencePostItem.title = _ds.Tables[0].Rows[i]["Title"].ToString();//.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("\n", "\\n"); //_essencePostItem.content = Out.SysUBB(_ds.Tables[0].Rows[i]["Content"].ToString());//.Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("\n", "\\n"); //_essencePostItem.ubb_content =_ds.Tables[0].Rows[i]["Content"].ToString(); //_essencePostItem.preview = string.IsNullOrEmpty(_ds.Tables[0].Rows[i]["GoodSmallIcon"].ToString()) ? "http://" + Utils.GetDomain() + "/Files/threadImg/def.png" : _ds.Tables[0].Rows[i]["GoodSmallIcon"].ToString(); //BCW.Model.Forum _forummodel = new BCW.BLL.Forum().GetForum(_essencePostItem.forumId); //_essencePostItem.forum = _forummodel != null ? _forummodel.Title : ""; //_essencePostItem.views = int.Parse(_ds.Tables[0].Rows[i]["ReadNum"].ToString()); //_essencePostItem.replys = int.Parse(_ds.Tables[0].Rows[i]["ReplyNum"].ToString()); //System.DateTime _startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); //_essencePostItem.addTime = (long)(DateTime.Parse(_ds.Tables[0].Rows[i]["AddTime"].ToString()) - _startTime).TotalSeconds; ////打赏 //DataSet _dsCent = new BCW.BLL.Textcent().GetList("isnull(SUM(Cents),0)cents", "BID='" + _essencePostItem.threadId + "'"); //_essencePostItem.likes = int.Parse(_dsCent.Tables[0].Rows[0]["cents"].ToString()); //_essencePostItem.IsGood = int.Parse(_ds.Tables[0].Rows[i]["IsGood"].ToString()); //_essencePostItem.IsRecom = int.Parse(_ds.Tables[0].Rows[i]["IsRecom"].ToString()); //_essencePostItem.IsLock = int.Parse(_ds.Tables[0].Rows[i]["IsLock"].ToString()); //_essencePostItem.IsTop = int.Parse(_ds.Tables[0].Rows[i]["IsTop"].ToString()); items.Add(_essencePostItem); //检查是否到底 if (i == _ds.Tables[0].Rows.Count - 1) { if (strWhere.Contains("1=1") == false) { strWhere += " and 1=1"; } DataSet _dsCheck = new BCW.BLL.Text().GetList("TOP 1 * ", strWhere.Replace("1=1", "ID<" + _essencePostItem.threadId) + " Order by " + strOrder); finish = _dsCheck.Tables[0].Rows.Count <= 0; } } } }