Beispiel #1
0
        /// <summary>
        /// 创建帖子
        /// </summary>
        /// <param name="postInfo">帖子信息</param>
        /// <param name="postTableId">分表ID</param>
        /// <returns>帖子ID</returns>
        public static int CreatePost(PostInfo postInfo, string postTableId)
        {
            int postId = DatabaseProvider.GetInstance().CreatePost(postInfo, postTableId);
            //更新TTCache缓存中的用户信息
            if (postInfo.Invisible == 0 && Users.appDBCache && Users.IUserService != null)
            {
                UserInfo userInfo = Users.IUserService.GetUserInfo(postInfo.Posterid);
                if (userInfo != null)
                {
                    userInfo.Lastpost = postInfo.Postdatetime;
                    userInfo.Lastpostid = postId;
                    userInfo.Lastposttitle = postInfo.Title;
                    userInfo.Posts = userInfo.Posts + 1;
                    userInfo.Lastactivity = DateTime.Now.ToString();
                    userInfo.Newpm = 1;
                    Users.IUserService.UpdateUser(userInfo);
                }
            }

            //更新Cache缓存中的用户信息
            if (postInfo.Invisible == 0 && Topics.appDBCache && Topics.ITopicService != null)
                Topics.ITopicService.ResetTopicByTid(postInfo.Tid);

            //创建Cache缓存中的帖子信息(权限于当前正在使用的分表)
            if (appDBCache && IPostService != null && PostTables.GetPostTableId(postInfo.Tid) == postTableId)
            {
                postInfo.Pid = postId;
                IPostService.CreatePost(postInfo, postTableId);
            }

            return postId;
        }
Beispiel #2
0
 /// <summary>
 /// 更新指定版块的最新发帖数信息
 /// </summary>
 public static void UpdateForumLastPost(ForumInfo forumInfo, PostInfo postInfo)
 {
     DatabaseProvider.GetInstance().UpdateLastPost(forumInfo, postInfo);
 }
Beispiel #3
0
 /// <summary>
 /// 装帖子信息
 /// </summary>
 /// <param name="reader"></param>
 /// <returns></returns>
 private static PostInfo LoadSinglePostInfo(IDataReader reader)
 {
     PostInfo postInfo = new PostInfo();
     postInfo.Pid = TypeConverter.ObjectToInt(reader["pid"]);
     postInfo.Fid = TypeConverter.ObjectToInt(reader["fid"]);
     postInfo.Tid = TypeConverter.ObjectToInt(reader["tid"]);
     postInfo.Parentid = TypeConverter.ObjectToInt(reader["parentid"]);
     postInfo.Layer = TypeConverter.ObjectToInt(reader["layer"]);
     postInfo.Poster = reader["poster"].ToString();
     postInfo.Posterid = TypeConverter.ObjectToInt(reader["posterid"]);
     postInfo.Title = reader["title"].ToString();
     postInfo.Postdatetime = reader["postdatetime"].ToString();
     postInfo.Message = reader["message"].ToString();
     postInfo.Ip = reader["ip"].ToString();
     postInfo.Lastedit = reader["lastedit"].ToString();
     postInfo.Invisible = TypeConverter.ObjectToInt(reader["invisible"]);
     postInfo.Usesig = TypeConverter.ObjectToInt(reader["usesig"]);
     postInfo.Htmlon = TypeConverter.ObjectToInt(reader["htmlon"]);
     postInfo.Smileyoff = TypeConverter.ObjectToInt(reader["smileyoff"]);
     postInfo.Bbcodeoff = TypeConverter.ObjectToInt(reader["bbcodeoff"]);
     postInfo.Parseurloff = TypeConverter.ObjectToInt(reader["parseurloff"]);
     postInfo.Attachment = TypeConverter.ObjectToInt(reader["attachment"]);
     postInfo.Rate = TypeConverter.ObjectToInt(reader["rate"]);
     postInfo.Ratetimes = TypeConverter.ObjectToInt(reader["ratetimes"]);
     return postInfo;
 }
Beispiel #4
0
 /// <summary>
 /// 更新指定帖子信息
 /// </summary>
 /// <param name="postInfo">帖子信息</param>
 /// <returns>更新数量</returns>
 public static int UpdatePost(PostInfo postInfo, string postTableId)
 {
     int result = DatabaseProvider.GetInstance().UpdatePost(postInfo, postTableId);
     //更新Cache缓存中的帖子信息
     if (appDBCache && IPostService != null)
     {
         IPostService.UpdatePost(postInfo, postTableId);
     }
     return result;
 }
Beispiel #5
0
        /// <summary>
        /// 通过主题ID得到主帖内容,此方法可继续扩展
        /// </summary>
        /// <param name="tid"></param>
        /// <returns>ShowtopicPagePostInfo</returns>
        public static PostInfo GetTopicPostInfo(int tid)
        {
            PostInfo postInfo = new PostInfo();
            IDataReader reader = DatabaseProvider.GetInstance().GetSinglePost(tid, PostTables.GetPostTableId(tid));

            if (reader.Read())
            {
                postInfo = LoadSinglePostInfo(reader);
            }

            reader.Close();
            return postInfo;
        }
Beispiel #6
0
 public static PostInfo GetPostInfo(string postTableId, int pid)
 {
     PostInfo postInfo = new PostInfo();
     IDataReader reader = DatabaseProvider.GetInstance().GetPostInfo(postTableId, pid);
     if (reader.Read())
     {
         postInfo = LoadSinglePostInfo(reader);
         reader.Close();
         return postInfo;
     }
     reader.Close();
     return null;
 }
Beispiel #7
0
 public static PostInfo GetLastPostByTid(int tid, string tableName)
 {
     PostInfo postinfo = new PostInfo();
     DataTable dt = DatabaseProvider.GetInstance().GetLastPostByTid(tid, tableName);
     if (dt.Rows.Count > 0)
     {
         postinfo.Pid = TypeConverter.ObjectToInt(dt.Rows[0]["pid"]);
         postinfo.Tid = TypeConverter.ObjectToInt(dt.Rows[0]["tid"]);
         postinfo.Title = dt.Rows[0]["title"].ToString().Trim();
         postinfo.Postdatetime = dt.Rows[0]["postdatetime"].ToString().Trim();
         postinfo.Poster = dt.Rows[0]["poster"].ToString().Trim();
         postinfo.Posterid = TypeConverter.ObjectToInt(dt.Rows[0]["posterid"]);
         postinfo.Topictitle = Topics.GetTopicInfo(postinfo.Tid, 0, 0).Title;
     }
     else
     {
         postinfo.Pid = 0;
         postinfo.Tid = 0;
         postinfo.Title = "从未";
         postinfo.Topictitle = "从未";
         postinfo.Postdatetime = "1900-1-1";
         postinfo.Poster = "";
         postinfo.Posterid = 0;
     }
     dt.Dispose();
     return postinfo;
 }