/// <summary> /// 增加一条数据,内部已经处理分表回贴,版块统计,属归作者表,积分 /// </summary> public int Add(Model.Forum_Topic model, out int _subTable_id, out int _post_id) { Forum_PostSubTable bllSubTable = new Forum_PostSubTable(); Forum_Board bllBoard = new Forum_Board(); Model.Forum_PostSubTable modelSubTable = bllSubTable.GetModel("Avail=1"); //分表ID _subTable_id = modelSubTable.Id; model.PostSubTable = _subTable_id; //主题表ID int _topic_id = dal.Add(model); //回复表ID _post_id = new Forum_PostId().Add(new Model.Forum_PostId { TopicId = _topic_id }); new Forum_Post(_subTable_id).Add(model, new Model.Forum_Post { BoardId = model.BoardId, Message = model.Message, Title = model.Title, PostDateTime = model.PostDatetime, PostNickname = model.PostNickname, PostUsername = model.PostUsername, PostUserId = model.PostUserId, Id = _post_id, TopicId = _topic_id, First = 1 }); //版块包括父级版块的统计、标记最后发贴 string strValue = "[TodayTopicCount]=[TodayTopicCount]+1,[TopicCount]=[TopicCount]+1,[LastPostUserId]=" + model.PostUserId + ",[LastPostUsername]='" + model.PostUsername.Replace("'", "") + "',[LastPostNickname]='" + model.PostNickname.Replace("'", "") + "',[LastTopicId]=" + _topic_id + ",[LastTopicTitle]='" + model.Title.Replace("'", "") + "'"; Model.Forum_Board modelBoard = bllBoard.GetModel(model.BoardId); bllBoard.UpdateField(" Id in (0" + modelBoard.ClassList + "0) ", strValue); //文章归属 new Forum_MyTopic().Add(new Model.Forum_MyTopic { TopicId = _topic_id, UserId = model.PostUserId }); //获得实际积分 int _point = new BLL.Forum_BoardActionPoint().GetRealPoint(model.BoardId, 1); new Forum_UserExtended().UpdateField(model.PostUserId, " TopicCount=TopicCount+1 ,Credit=Credit+" + _point); modelSubTable.TopicCount += 1; bllSubTable.Update(modelSubTable); return(_topic_id); }
public static void BoardTodayTopicCount(bool bol = false) { //没有统计过 if (HttpContext.Current.Application["BoardTodayTopicTime"] == null) { bol = true; HttpContext.Current.Application["BoardTodayTopicTime"] = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd 00:00:01")); } DateTime dtTime = Convert.ToDateTime(HttpContext.Current.Application["BoardTodayTopicTime"]); TimeSpan ts = System.DateTime.Now - dtTime; //时间已经超过了24小时 if (ts.TotalSeconds > 86400.0) { bol = true; } if (bol) { BLL.Forum_Board bll = new BLL.Forum_Board(); bll.UpdateField(" 1=1 ", "TodayTopicCount=0"); List <Model.Forum_Board> list = bll.GetModelList(" 1=1 "); //所有版块重新统计 foreach (Model.Forum_Board modelBoard in list) { int _total = new BLL.Forum_Topic().GetTotal(" BoardId=" + modelBoard.Id + " and PostDatetime>'" + System.DateTime.Now.ToString("yyyy-MM-dd 00:00:01") + "' "); string strValue = "[TodayTopicCount]=[TodayTopicCount]+" + _total + ""; bll.UpdateField(" Id in (0" + modelBoard.ClassList + "0) ", strValue); } HttpContext.Current.Application["BoardTodayTopicTime"] = Convert.ToDateTime(System.DateTime.Now.ToString("yyyy-MM-dd 00:00:01")); } }