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); }
/// <summary> /// 编辑帖子 /// </summary> /// <param name="_reqData"></param> /// <returns></returns> public RspEditThread EditThread(ReqEditThread _reqData) { RspEditThread _rspEditThread = new RspEditThread(); //验证用户ID格式 if (_reqData.userId < 0) { _rspEditThread.header.status = ERequestResult.faild; _rspEditThread.header.statusCode = Error.MOBILE_ERROR_CODE.MOBILE_PARAMS_ERROR; return(_rspEditThread); } //验证贴子标题长度 if (Regex.IsMatch(_reqData.title, @"^[\s\S]{" + ub.GetSub("BbsThreadMin", xmlPath) + "," + ub.GetSub("BbsThreadMax", xmlPath) + "}$") == false) { _rspEditThread.header.status = ERequestResult.faild; _rspEditThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_THREAD_TITLE_LENGTH_ERROR; _rspEditThread.header.statusMsg = string.Format(_rspEditThread.header.statusMsg, ub.GetSub("BbsThreadMin", xmlPath), ub.GetSub("BbsThreadMax", xmlPath)); return(_rspEditThread); } //验证内容长度 if (Regex.IsMatch(_reqData.content, @"^[\s\S]{" + ub.GetSub("BbsContentMin", xmlPath) + "," + ub.GetSub("BbsContentMax", xmlPath) + "}$") == false) { _rspEditThread.header.status = ERequestResult.faild; _rspEditThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_THREAD_CONTENT_LENGTH_ERROR; _rspEditThread.header.statusMsg = string.Format(_rspEditThread.header.statusMsg, ub.GetSub("BbsContentMin", xmlPath), ub.GetSub("BbsContentMax", xmlPath)); return(_rspEditThread); } //检查是否登录状态 if (Common.Common.CheckLogin(_reqData.userId, _reqData.userKey) == 0) { _rspEditThread.header.status = ERequestResult.faild; _rspEditThread.header.statusCode = Error.MOBILE_ERROR_CODE.SYS_USER_NOLOGIN; return(_rspEditThread); } BCW.Model.Text model = new BCW.BLL.Text().GetText(_reqData.threadId); if (model == null) { _rspEditThread.header.status = ERequestResult.faild; _rspEditThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_THREAD_NOT_FOUND; return(_rspEditThread); } if (model.UsID != _reqData.userId && new BCW.User.Role().IsUserRole(BCW.User.Role.enumRole.Role_EditText, _reqData.userId, model.ForumId) == false) { _rspEditThread.header.status = ERequestResult.faild; _rspEditThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_FORUM_LIMIT_NOT_ENOUGH; return(_rspEditThread); } if (model.IsLock == 1) { _rspEditThread.header.status = ERequestResult.faild; _rspEditThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_THREAD_IS_LOCK; return(_rspEditThread); } if (model.IsTop == -1) { _rspEditThread.header.status = ERequestResult.faild; _rspEditThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_THREAD_IS_TOP; return(_rspEditThread); } BCW.Model.Text model2 = new BCW.Model.Text(); model2.ID = _reqData.threadId; model2.Title = _reqData.title; model2.Content = _reqData.content; new BCW.BLL.Text().Update(model2); //记录日志 string strLog = string.Empty; if (model.UsID != _reqData.userId) { strLog = "[url=/bbs/uinfo.aspx?uid=" + model.UsID + "]" + model.UsName + "[/url]的主题[url=/bbs/topic.aspx?forumid=" + model.ForumId + "&bid=" + _reqData.threadId + "]《" + model.Title + "》[/url]被[url=/bbs/uinfo.aspx?uid=" + _reqData.userId + "]" + new BCW.BLL.User().GetUsName(_reqData.userId) + "[/url]编辑!"; new BCW.BLL.Guest().Add(0, model.UsID, model.UsName, "您的主题[url=/bbs/topic.aspx?forumid=" + model.ForumId + "&bid=" + _reqData.threadId + "]《" + model.Title + "》[/url]被[url=/bbs/uinfo.aspx?uid=" + _reqData.userId + "]" + new BCW.BLL.User().GetUsName(_reqData.userId) + "[/url]编辑!"); } else { strLog = "[url=/bbs/uinfo.aspx?uid=" + model.UsID + "]" + model.UsName + "[/url]编辑自己的主题[url=/bbs/topic.aspx?forumid=" + model.ForumId + "&bid=" + _reqData.threadId + "]《" + model.Title + "》[/url]!"; } new BCW.BLL.Forumlog().Add(7, model.ForumId, _reqData.threadId, strLog); _rspEditThread.header.status = ERequestResult.success; _rspEditThread.threadId = _reqData.threadId; return(_rspEditThread); }
/// <summary> /// 发贴 /// </summary> /// <param name="ForumId"></param> /// <returns>发表贴子结果类</returns> public RspAddThread AddThread(ReqAddThread _reqData) { RspAddThread _rspAddThread = new RspAddThread(); //验证用户ID格式 if (_reqData.userId < 0) { _rspAddThread.header.status = ERequestResult.faild; _rspAddThread.header.statusCode = Error.MOBILE_ERROR_CODE.MOBILE_PARAMS_ERROR; return(_rspAddThread); } //验证帖子类型 if (Regex.IsMatch(_reqData.pType.ToString(), @"^[0-4]$|^6$|^7$|^8$") == false) { _rspAddThread.header.status = ERequestResult.faild; _rspAddThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_THREAD_TYPE_ERROR; return(_rspAddThread); } //验证帖子类型 if (Regex.IsMatch(_reqData.forumId.ToString(), @"^[0-9]\d*$") == false) { _rspAddThread.header.status = ERequestResult.faild; _rspAddThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_THREAD_TYPE_ERROR; return(_rspAddThread); } //验证贴子标题长度 if (Regex.IsMatch(_reqData.title, @"^[\s\S]{" + ub.GetSub("BbsThreadMin", xmlPath) + "," + ub.GetSub("BbsThreadMax", xmlPath) + "}$") == false) { _rspAddThread.header.status = ERequestResult.faild; _rspAddThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_THREAD_TITLE_LENGTH_ERROR; _rspAddThread.header.statusMsg = string.Format(_rspAddThread.header.statusMsg, ub.GetSub("BbsThreadMin", xmlPath), ub.GetSub("BbsThreadMax", xmlPath)); return(_rspAddThread); } //验证内容长度 if (Regex.IsMatch(_reqData.content, @"^[\s\S]{" + ub.GetSub("BbsContentMin", xmlPath) + "," + ub.GetSub("BbsContentMax", xmlPath) + "}$") == false) { _rspAddThread.header.status = ERequestResult.faild; _rspAddThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_THREAD_CONTENT_LENGTH_ERROR; _rspAddThread.header.statusMsg = string.Format(_rspAddThread.header.statusMsg, ub.GetSub("BbsContentMin", xmlPath), ub.GetSub("BbsContentMax", xmlPath)); return(_rspAddThread); } //检查是否登录状态 if (Common.Common.CheckLogin(_reqData.userId, _reqData.userKey) == 0) { _rspAddThread.header.status = ERequestResult.faild; _rspAddThread.header.statusCode = Error.MOBILE_ERROR_CODE.SYS_USER_NOLOGIN; return(_rspAddThread); } //版块是否可用 if (!new BCW.BLL.Forum().Exists2(_reqData.forumId)) { _rspAddThread.header.status = ERequestResult.faild; _rspAddThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_FORUM_NOT_FOUND; return(_rspAddThread); } //自身权限不足 if (new BCW.User.Limits().IsUserLimit(BCW.User.Limits.enumRole.Role_Text, _reqData.userId) == true) { _rspAddThread.header.status = ERequestResult.faild; _rspAddThread.header.statusCode = Error.MOBILE_ERROR_CODE.SYS_USER_LIMIT_NOT_ENOUGH; return(_rspAddThread); } //板块权限不足 if (Common.Common.CheckUserFLimit(BCW.User.FLimits.enumRole.Role_Text, _reqData.userId, _reqData.forumId)) { _rspAddThread.header.status = ERequestResult.faild; _rspAddThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_FORUM_LIMIT_NOT_ENOUGH; return(_rspAddThread); } string mename = new BCW.BLL.User().GetUsName(_reqData.userId); int ThreadNum = Utils.ParseInt(ub.GetSub("BbsThreadNum", xmlPath)); if (ThreadNum > 0) { int ToDayCount = new BCW.BLL.Forumstat().GetCount(_reqData.userId, 1);//今天发布帖子数 if (ToDayCount >= ThreadNum) { _rspAddThread.header.status = ERequestResult.faild; _rspAddThread.header.statusCode = Error.MOBILE_ERROR_CODE.BBS_THREAD_THREAD_NUM; return(_rspAddThread); } } BCW.Model.Forum model = new BCW.BLL.Forum().GetForum(_reqData.forumId); //论坛限制性 //BCW.User.Users.ShowForumLimit(_reqData.userId, model.Gradelt, model.Visitlt, model.VisitId, model.IsPc); //浏览限制 //发贴限制 Error.MOBILE_ERROR_CODE _result = Common.Common.ShowAddThread(_reqData.userId, model.Postlt); if (_result != Error.MOBILE_ERROR_CODE.MOBILE_MSG_NONE) { _rspAddThread.header.status = ERequestResult.faild; _rspAddThread.header.statusCode = _result; return(_rspAddThread); } //判断玩家是否刷屏 string Hide = string.Empty; int Price = 0; int Price2 = 0; long Prices = 0; int BzType = 0; int HideType = 0; int IsSeen = 0; string PayCi = string.Empty; string Vote = string.Empty; DateTime VoteExTime = DateTime.Now; int LabelId = 0; BCW.Model.Text addmodel = new BCW.Model.Text(); addmodel.ForumId = _reqData.forumId; addmodel.Types = _reqData.pType; addmodel.LabelId = LabelId; addmodel.Title = _reqData.title; addmodel.Content = _reqData.content; addmodel.HideContent = Hide; addmodel.UsID = _reqData.userId; addmodel.UsName = mename; addmodel.Price = Price; addmodel.Price2 = Price2; addmodel.Prices = Prices; addmodel.HideType = HideType; addmodel.BzType = BzType; addmodel.PayCi = PayCi; addmodel.IsSeen = IsSeen; addmodel.IsDel = 0; addmodel.AddTime = DateTime.Now; addmodel.ReTime = DateTime.Now; addmodel.PricesLimit = ""; addmodel.Gaddnum = 0; addmodel.Gqinum = 0; int k = 0; k = new BCW.BLL.Text().Add(addmodel); //论坛统计 BCW.User.Users.UpdateForumStat(1, _reqData.userId, mename, _reqData.forumId); //动态记录 if (model.GroupId > 0) { new BCW.BLL.Action().Add(-2, 0, _reqData.userId, mename, "在圈坛-" + model.Title + "发表了[URL=/bbs/topic.aspx?forumid=" + _reqData.forumId + "&bid=" + k + "]" + _reqData.title + "[/URL]的帖子"); } else { new BCW.BLL.Action().Add(-1, 0, _reqData.userId, mename, "在" + model.Title + "发表了[URL=/bbs/topic.aspx?forumid=" + _reqData.forumId + "&bid=" + k + "]" + _reqData.title + "[/URL]的帖子"); } //积分操作/论坛统计/圈子论坛不进行任何奖励 int GroupId = new BCW.BLL.Forum().GetGroupId(_reqData.forumId); int IsAcc = -1; if (GroupId == 0) { IsAcc = new BCW.User.Cent().UpdateCent2(BCW.User.Cent.enumRole.Cent_Text, _reqData.userId, true); } else { if (!Utils.GetDomain().Contains("th")) { IsAcc = new BCW.User.Cent().UpdateCent2(BCW.User.Cent.enumRole.Cent_Text, _reqData.userId, false); } } #region 这里开始修改提醒ID 发内线 string remind = ub.GetSub("remindid" + _reqData.forumId, xmlPath); //获取XML的值 if (remind != "") //如果有提醒ID { string[] IDS = remind.Split('#'); for (int i = 0; i < IDS.Length; i++) { if (model.GroupId > 0) { new BCW.BLL.Guest().Add(0, int.Parse(IDS[i]), new BCW.BLL.User().GetUsName(int.Parse(IDS[i])), "请注意!用户[url=/bbs/uinfo.aspx?uid=" + _reqData.userId + "]" + mename + "(" + _reqData.userId + ")[/url]在圈坛-" + model.Title + "发表了[URL=/bbs/topic.aspx?forumid=" + _reqData.forumId + "&bid=" + k + "]" + _reqData.title + "[/URL]的帖子"); } else { new BCW.BLL.Guest().Add(0, int.Parse(IDS[i]), new BCW.BLL.User().GetUsName(int.Parse(IDS[i])), "请注意!用户[url=/bbs/uinfo.aspx?uid=" + _reqData.userId + "]" + mename + "(" + _reqData.userId + ")[/url]在" + model.Title + "发表了[URL=/bbs/topic.aspx?forumid=" + _reqData.forumId + "&bid=" + k + "]" + _reqData.title + "[/URL]的帖子"); } } } #endregion _rspAddThread.header.status = ERequestResult.success; _rspAddThread.threadId = k; return(_rspAddThread); }