/// <summary>
        /// 重建指定论坛帖数
        /// </summary>
        public static void ReSetFourmTopicAPost(int fid, out int topiccount, out int postcount, out int lasttid, out string lasttitle, out string lastpost, out int lastposterid, out string lastposter, out int todaypostcount)
        {
            topiccount     = 0;
            postcount      = 0;
            lasttid        = 0;
            lasttitle      = "";
            lastpost       = "";
            lastposterid   = 0;
            lastposter     = "";
            todaypostcount = 0;
            if (fid < 1)
            {
                return;
            }

            topiccount = Data.Topics.GetTopicCountOfForumWithSub(fid);
            postcount  = GetPostsCountByFid(fid, out todaypostcount);

            IDataReader postreader = Data.Posts.GetLastPostByFid(fid, Posts.GetPostTableName());

            if (postreader.Read())
            {
                lasttid      = Utils.StrToInt(postreader["tid"], 0);
                lasttitle    = Topics.GetTopicInfo(lasttid).Title;//postreader["title"].ToString();
                lastpost     = postreader["postdatetime"].ToString();
                lastposterid = Utils.StrToInt(postreader["posterid"], 0);
                lastposter   = postreader["poster"].ToString();
            }

            postreader.Close();
        }
Beispiel #2
0
        private static StringBuilder IsValidDebates(int tid, string message, bool ispost)
        {
            StringBuilder xmlnode = new StringBuilder();

            xmlnode.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
            if (!ispost || ForumUtils.IsCrossSitePost())
            {
                xmlnode.Append("<error>您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。</error>");
                return(xmlnode);
            }

            Regex           r = new Regex(@"\[area=([\s\S]+?)\]([\s\S]+?)\[/area\]", RegexOptions.Singleline | RegexOptions.IgnoreCase);
            MatchCollection m = r.Matches(message);

            if (m.Count == 0)
            {
                xmlnode.Append("<error>评论内容不能为空</error>");
                return(xmlnode);
            }

            TopicInfo topicinfo = Topics.GetTopicInfo(tid);

            if (tid == 0 || topicinfo.Special != 4)
            {
                xmlnode.Append("<error>本主题不是辩论帖,无法点评</error>");
                return(xmlnode);
            }
            if (Debates.GetDebateTopic(tid).Terminaltime > DateTime.Now)
            {
                xmlnode.Append("<error>本辩论帖结束时间未到,无法点评</error>");
                return(xmlnode);
            }
            return(xmlnode);
        }
Beispiel #3
0
        /// <summary>
        /// 重建指定论坛帖数
        /// </summary>
        public static void ReSetFourmTopicAPost(int fid)
        {
            if (fid < 1)
            {
                return;
            }

            int    topiccount     = 0;
            int    postcount      = 0;
            int    lasttid        = 0;
            string lasttitle      = "";
            string lastpost       = "1900-1-1";
            int    lastposterid   = 0;
            string lastposter     = "";
            int    todaypostcount = 0;

            topiccount = Topics.GetAllTopicCount(fid);

            postcount = GetPostsCountByFid(fid, out todaypostcount);

            IDataReader postreader = DatabaseProvider.GetInstance().GetLastPostByFid(fid, Posts.GetPostTableName());

            if (postreader.Read())
            {
                lasttid      = Utils.StrToInt(postreader["tid"], 0);
                lasttitle    = Topics.GetTopicInfo(lasttid).Title;//postreader["title"].ToString();
                lastpost     = postreader["postdatetime"].ToString();
                lastposterid = Utils.StrToInt(postreader["posterid"], 0);
                lastposter   = postreader["poster"].ToString();
            }

            postreader.Close();

            DatabaseProvider.GetInstance().UpdateForum(fid, topiccount, postcount, lasttid, lasttitle, lastpost, lastposterid, lastposter, todaypostcount);
        }
Beispiel #4
0
        /// <summary>
        /// 复制主题
        /// </summary>
        /// <param name="topiclist">主题id列表</param>
        /// <param name="fid">目标版块id</param>
        /// <returns>更新记录数</returns>
        public static int CopyTopics(string topiclist, int fid)
        {
            if (!Utils.IsNumericList(topiclist))
            {
                return(-1);
            }

            int       tid;
            int       reval     = 0;
            TopicInfo topicinfo = null;

            foreach (string topicid in topiclist.Split(','))
            {
                topicinfo = Topics.GetTopicInfo(TypeConverter.StrToInt(topicid));
                if (topicinfo != null)
                {
                    topicinfo.Fid          = fid;
                    topicinfo.Readperm     = 0;
                    topicinfo.Price        = 0;
                    topicinfo.Postdatetime = Utils.GetDateTime();
                    topicinfo.Lastpost     = Utils.GetDateTime();
                    topicinfo.Lastposter   = Utils.GetDateTime();
                    topicinfo.Views        = 0;
                    topicinfo.Replies      = 0;
                    topicinfo.Displayorder = 0;
                    topicinfo.Highlight    = "";
                    topicinfo.Digest       = 0;
                    topicinfo.Rate         = 0;
                    topicinfo.Hide         = 0;
                    topicinfo.Special      = 0;
                    topicinfo.Attachment   = 0;
                    topicinfo.Moderated    = 0;
                    topicinfo.Closed       = 0;
                    tid = Topics.CreateTopic(topicinfo);

                    if (tid > 0)
                    {
                        PostInfo postinfo = Posts.GetPostInfo(tid, Posts.GetFirstPostId(TypeConverter.StrToInt(topicid)));
                        postinfo.Fid          = topicinfo.Fid;
                        postinfo.Tid          = tid;
                        postinfo.Parentid     = 0;
                        postinfo.Layer        = 0;
                        postinfo.Postdatetime = Utils.GetDateTime();
                        postinfo.Invisible    = 0;
                        postinfo.Attachment   = 0;
                        postinfo.Rate         = 0;
                        postinfo.Ratetimes    = 0;
                        postinfo.Message      = UBB.ClearAttachUBB(postinfo.Message);
                        postinfo.Topictitle   = topicinfo.Title;

                        if (Posts.CreatePost(postinfo) > 0)
                        {
                            reval++;
                        }
                    }
                }
            }
            return(reval);
        }
Beispiel #5
0
        /// <summary>
        /// 通过待验证的主题
        /// </summary>
        /// <param name="postTableId">当前帖子分表Id</param>
        /// <param name="tid">主题Id</param>
        public static void PassAuditNewTopic(string tidList)
        {
            string[]  tidarray = tidList.Split(',');
            float[]   values   = null;
            ForumInfo forum    = null;
            TopicInfo topic    = null;
            int       fid      = -1;

            foreach (string tid in tidarray)
            {
                topic = Topics.GetTopicInfo(int.Parse(tid)); //获取主题信息
                if (fid != topic.Fid)                        //当上一个和当前主题不在一个版块内时,重新读取版块的积分设置
                {
                    fid   = topic.Fid;
                    forum = Discuz.Forum.Forums.GetForumInfo(fid);
                    if (!forum.Postcredits.Equals(""))
                    {
                        int   index   = 0;
                        float tempval = 0;
                        values = new float[8];
                        foreach (string ext in Utils.SplitString(forum.Postcredits, ","))
                        {
                            if (index == 0)
                            {
                                if (!ext.Equals("True"))
                                {
                                    values = null;
                                    break;
                                }
                                index++;
                                continue;
                            }
                            tempval           = Utils.StrToFloat(ext, 0);
                            values[index - 1] = tempval;
                            index++;
                            if (index > 8)
                            {
                                break;
                            }
                        }
                    }
                }

                if (values != null) //使用版块内积分
                {
                    UserCredits.UpdateUserCreditsByPostTopic(topic.Posterid, values);
                }
                else //使用默认积分
                {
                    UserCredits.UpdateUserCreditsByPostTopic(topic.Posterid);
                }
            }

            Data.Topics.PassAuditNewTopic(PostTables.GetPostTableId(), tidList);
        }
Beispiel #6
0
        /// <summary>
        /// 合并主题
        /// </summary>
        /// <param name="topiclist">主题id列表</param>
        /// <param name="othertid">被合并tid</param>
        /// <returns>更新记录数</returns>
        public static int MerrgeTopics(string topicId, int othertid)
        {
            int tid   = TypeConverter.StrToInt(topicId);
            int reval = 0;
            //获得要被合并的主题的信息
            TopicInfo topicinfo    = Topics.GetTopicInfo(othertid);
            TopicInfo newTopicInfo = Topics.GetTopicInfo(tid);

            //TODO: Move them to posts
            Discuz.Data.TopicAdmins.UpdatePostTidToAnotherTopic(othertid, tid);
            Discuz.Data.TopicAdmins.UpdatePostTidToAnotherTopic(tid, tid);
            //更新附件从属
            Discuz.Data.TopicAdmins.UpdateAttachmentTidToAnotherTopic(othertid, tid);

            reval = Discuz.Data.Topics.DeleteTopic(othertid);

            if (topicinfo != null)
            {
                if (newTopicInfo.Lastpostid < topicinfo.Lastpostid)
                {
                    newTopicInfo.Lastpostid   = topicinfo.Lastpostid;
                    newTopicInfo.Lastposterid = topicinfo.Lastposterid;
                    newTopicInfo.Lastpost     = topicinfo.Lastpost;
                    newTopicInfo.Lastposter   = topicinfo.Lastposter;
                    newTopicInfo.Replies     += topicinfo.Replies;
                }
                else
                {
                    newTopicInfo.Replies += topicinfo.Replies;
                }
            }

            //更新主题信息
            PostInfo topicPost = Posts.GetPostInfo(tid, Posts.GetFirstPostId(tid));

            Discuz.Data.Topics.SetPrimaryPost(topicPost.Title, tid, new string[] { topicPost.Pid.ToString() });

            newTopicInfo.Title    = topicPost.Title;
            newTopicInfo.Posterid = topicPost.Posterid;
            newTopicInfo.Poster   = topicPost.Poster;
            Topics.UpdateTopic(newTopicInfo);

            if (topicinfo.Lastpostid == 0)
            {
                Discuz.Data.Topics.UpdateTopicLastPosterId(topicinfo.Tid);
            }

            if (newTopicInfo.Lastpostid == 0)
            {
                Discuz.Data.Topics.UpdateTopicLastPosterId(newTopicInfo.Tid);
            }

            return(reval);
        }
Beispiel #7
0
        /// <summary>
        /// 撤消评分
        /// </summary>
        /// <param name="tid"></param>
        /// <param name="postidlist"></param>
        /// <param name="userid"></param>
        /// <param name="username"></param>
        /// <param name="reason"></param>
        public static void CancelRatePosts(string ratelogidlist, int tid, string pid, int userid, string username, int groupid, string grouptitle, int forumid, string forumname, string reason)
        {
            if (!Utils.IsNumeric(pid))
            {
                return;
            }

            int rateduserid = Posts.GetPostInfo(tid, Utils.StrToInt(pid, 0)).Posterid; //被评分的用户的UID

            if (rateduserid <= 0)
            {
                return;
            }

            string    posttableid = Data.PostTables.GetPostTableId(tid);
            DataTable dt          = AdminRateLogs.LogList(ratelogidlist.Split(',').Length, 1, "id IN(" + ratelogidlist + ")");//得到要删除的评分日志列表

            foreach (DataRow dr in dt.Rows)
            {
                SetPostRate(posttableid,
                            TypeConverter.StrToInt(pid),
                            TypeConverter.ObjectToInt(dr["extcredits"]),
                            TypeConverter.ObjectToInt(dr["score"]),
                            false);

                //乘-1是要进行分值的反向操作
                Discuz.Data.Users.UpdateUserExtCredits(rateduserid, TypeConverter.ObjectToInt(dr["extcredits"]), (-1) * TypeConverter.ObjectToFloat(dr["score"]));
            }

            AdminRateLogs.DeleteLog("[id] IN(" + ratelogidlist + ")");

            //当帖子已无评分记录时,则清空帖子相关的评分信息字段(rate,ratetimes)
            if (AdminRateLogs.LogList(1, 1, "pid = " + pid).Rows.Count == 0)
            {
                Discuz.Data.Posts.CancelPostRate(pid, posttableid);
            }

            TopicInfo topicinfo = Topics.GetTopicInfo(tid);

            Discuz.Data.ModeratorManageLog.InsertModeratorLog(userid.ToString(),
                                                              username,
                                                              groupid,
                                                              grouptitle,
                                                              Utils.GetRealIP(),
                                                              Utils.GetDateTime(),
                                                              forumid.ToString(),
                                                              forumname,
                                                              tid.ToString(),
                                                              topicinfo == null ? "暂无标题" : topicinfo.Title,
                                                              "撤消评分",
                                                              reason);
        }
        private static void ReSetFourmTopicPost(IDataReader reader, ref int fid, bool fixTopicCount)
        {
            if (reader != null)
            {
                int    topiccount     = 0;
                int    postcount      = 0;
                int    todaypostcount = 0;
                int    lasttid        = 0;
                string lasttitle      = "";
                string lastpost       = "1900-1-1";
                int    lastposterid   = 0;
                string lastposter     = "";

                while (reader.Read())
                {
                    fid        = Utils.StrToInt(reader["fid"], -1);
                    topiccount = Data.Topics.GetTopicCountOfForumWithSub(fid);
                    postcount  = GetPostsCountByFid(fid, out todaypostcount);
                    if (fixTopicCount)
                    {
                        Forums.SetRealCurrentTopics(fid);
                    }
                    else
                    {
                        lasttid      = 0;
                        lasttitle    = "";
                        lastpost     = "1900-1-1";
                        lastposterid = 0;
                        lastposter   = "";
                    }
                    IDataReader postreader = Discuz.Data.Posts.GetForumLastPost(fid, Posts.GetPostTableName(), topiccount, postcount, lasttid, lasttitle, lastpost, lastposterid, lastposter, todaypostcount);
                    if (postreader.Read())
                    {
                        TopicInfo topic = Topics.GetTopicInfo(TypeConverter.ObjectToInt(postreader["tid"]));
                        if (topic == null)
                        {
                            continue;
                        }
                        lasttid      = topic.Tid;
                        lasttitle    = topic.Title;//postreader["title"].ToString();
                        lastpost     = postreader["postdatetime"].ToString();
                        lastposterid = Utils.StrToInt(postreader["posterid"], 0);
                        lastposter   = postreader["poster"].ToString();
                    }
                    postreader.Close();

                    Discuz.Data.Forums.UpdateForum(fid, topiccount, postcount, lasttid, lasttitle, lastpost, lastposterid, lastposter, todaypostcount);
                }
                reader.Close();
            }
        }
Beispiel #9
0
        /// <summary>
        /// 通过待验证的主题
        /// </summary>
        /// <param name="postTableId">当前帖子分表Id</param>
        /// <param name="tid">主题Id</param>
        public static void PassAuditNewTopic(string tidList)
        {
            //string[] tidarray = tidList.Split(',');
            //float[] values = null;
            //ForumInfo forum = null;
            //TopicInfo topic = null;
            //int fid = -1;
            foreach (string tid in tidList.Split(','))
            {
                TopicInfo topic = Topics.GetTopicInfo(int.Parse(tid));    //获取主题信息
                CreditsFacade.PostTopic(topic.Posterid, Forums.GetForumInfo(topic.Fid));
                //if (fid != topic.Fid)    //当上一个和当前主题不在一个版块内时,重新读取版块的积分设置
                //{
                //    fid = topic.Fid;
                //    forum = Discuz.Forum.Forums.GetForumInfo(fid);
                //    if (!forum.Postcredits.Equals(""))
                //    {
                //        int index = 0;
                //        float tempval = 0;
                //        values = new float[8];
                //        foreach (string ext in Utils.SplitString(forum.Postcredits, ","))
                //        {
                //            if (index == 0)
                //            {
                //                if (!ext.Equals("True"))
                //                {
                //                    values = null;
                //                    break;
                //                }
                //                index++;
                //                continue;
                //            }
                //            tempval = Utils.StrToFloat(ext, 0);
                //            values[index - 1] = tempval;
                //            index++;
                //            if (index > 8)
                //            {
                //                break;
                //            }
                //        }
                //    }
                //}

                //if (values != null) //使用版块内积分
                //    UserCredits.UpdateUserCreditsByPostTopic(topic.Posterid, values);
                //else //使用默认积分
                //    UserCredits.UpdateUserCreditsByPostTopic(topic.Posterid);
            }

            Data.Topics.PassAuditNewTopic(PostTables.GetPostTableId(), tidList);
        }
Beispiel #10
0
        /// <summary>
        /// 重建论坛帖数
        /// </summary>
        /// <param name="statcount">要设置的版块数量</param>
        /// <param name="lastfid">输出参数:最后一个版块ID</param>
        public static void ReSetFourmTopicAPost(int statcount, ref int lastfid)
        {
            if (statcount < 1)
            {
                lastfid = -1;
                return;
            }


            Forums.SetRealCurrentTopics(lastfid);


            IDataReader reader = DatabaseProvider.GetInstance().GetTopForumFids(lastfid, statcount);

            lastfid = -1;
            if (reader != null)
            {
                int topiccount     = 0;
                int postcount      = 0;
                int todaypostcount = 0;

                while (reader.Read())
                {
                    lastfid = Utils.StrToInt(reader["fid"], -1);

                    topiccount = Topics.GetAllTopicCount(lastfid);

                    postcount = GetPostsCountByFid(lastfid, out todaypostcount);
                    int    lasttid      = 0;
                    string lasttitle    = "";
                    string lastpost     = "1900-1-1";
                    int    lastposterid = 0;
                    string lastposter   = "";

                    IDataReader postreader = DatabaseProvider.GetInstance().GetForumLastPost(lastfid, Posts.GetPostTableName(), topiccount, postcount, 0, "", "1900-1-1", 0, "", todaypostcount);
                    if (postreader.Read())
                    {
                        lasttid      = Utils.StrToInt(postreader["tid"], 0);
                        lasttitle    = Topics.GetTopicInfo(lasttid).Title;//postreader["title"].ToString();
                        lastpost     = postreader["postdatetime"].ToString();
                        lastposterid = Utils.StrToInt(postreader["posterid"], 0);
                        lastposter   = postreader["poster"].ToString();
                    }
                    postreader.Close();

                    DatabaseProvider.GetInstance().UpdateForum(lastfid, topiccount, postcount, lasttid, lasttitle, lastpost, lastposterid, lastposter, todaypostcount);
                }
                reader.Close();
            }
        }
Beispiel #11
0
        /// <summary>
        /// 重建论坛帖数
        /// </summary>
        /// <param name="start_fid">要设置的起始版块</param>
        /// <param name="end_fid">要设置的终止版块</param>
        public static void ReSetFourmTopicAPost(int start_fid, int end_fid)
        {
            IDataReader reader      = DatabaseProvider.GetInstance().GetForums(start_fid, end_fid);
            int         current_fid = start_fid;

            if (reader != null)
            {
                int    topiccount     = 0;
                int    postcount      = 0;
                int    todaypostcount = 0;
                int    lasttid        = 0;
                string lasttitle      = "";
                string lastpost       = "";
                int    lastposterid   = 0;
                string lastposter     = "";

                while (reader.Read())
                {
                    current_fid = Utils.StrToInt(reader["fid"], -1);

                    Forums.SetRealCurrentTopics(current_fid);

                    topiccount = Topics.GetAllTopicCount(current_fid);

                    postcount = GetPostsCountByFid(current_fid, out todaypostcount);

                    IDataReader postreader = DatabaseProvider.GetInstance().GetForumLastPost(current_fid, Posts.GetPostTableName(), topiccount, postcount, lasttid, lasttitle, lastpost, lastposterid, lastposter, todaypostcount);

                    if (postreader.Read())
                    {
                        lasttid      = Utils.StrToInt(postreader["tid"], 0);
                        lasttitle    = Topics.GetTopicInfo(lasttid).Title;//postreader["title"].ToString();
                        lastpost     = postreader["postdatetime"].ToString();
                        lastposterid = Utils.StrToInt(postreader["posterid"], 0);
                        lastposter   = postreader["poster"].ToString();
                        DatabaseProvider.GetInstance().UpdateForum(current_fid, topiccount, postcount, lasttid, lasttitle, lastpost, lastposterid, lastposter, todaypostcount);
                    }
                    postreader.Close();
                }
                reader.Close();
            }
        }
Beispiel #12
0
        /// <summary>
        /// 根据参数信息选择相应的模板
        /// </summary>
        /// <param name="strTemplateid">默认的模板ID</param>
        /// <param name="pagename">请求的页面名称</param>
        /// <param name="newUrl">请求参数</param>
        /// <returns>返回相应的模板ID</returns>
        public string SelectTemplate(string strTemplateid, string pagename, string newUrl)
        {
            string pagenamelist = "showforum,showtopic,showdebate,showbonus,posttopic,postreply,showtree,editpost,delpost,topicadmin";

            int forumid = 0;
            //要截取的字段串的开始位置
            int startindex = pagename.LastIndexOf("/") + 1;
            //如果是指定的页面则进行模板查询
            int length = pagename.LastIndexOf(".") - startindex;

            if (length > 0 && Utils.InArray(pagename.Substring(startindex, length), pagenamelist))
            {
                foreach (string urlvalue in newUrl.Split('&'))
                {
                    if ((urlvalue.IndexOf("forumid=") >= 0) && (urlvalue.Split('=')[1] != ""))
                    {
                        forumid = Utils.StrToInt(urlvalue.Split('=')[1], 0);
                    }
                    else
                    {
                        if ((urlvalue.IndexOf("topicid=") >= 0) && (urlvalue.Split('=')[1] != ""))
                        {
                            Discuz.Entity.TopicInfo topicinfo = Topics.GetTopicInfo(Utils.StrToInt(urlvalue.Split('=')[1], 0));
                            //主题存在时
                            if (topicinfo != null)
                            {
                                forumid = topicinfo.Fid;
                            }
                        }
                        else
                        {
                            forumid = DNTRequest.GetInt("forumid", 0);
                        }
                    }

                    if (forumid > 0)
                    {
                        Entity.ForumInfo forumInfo = Forums.GetForumInfo(forumid);
                        int templateid             = forumInfo == null ? 0 : forumInfo.Templateid;

                        //当前版块未指定模板时(使用用户选择的模版或系统默认模板)
                        if (templateid <= 0)
                        {
                            //从cookie中获取用户选择的模板
                            if (Utils.InArray(Utils.GetCookie(Utils.GetTemplateCookieName()), Templates.GetValidTemplateIDList()))
                            {
                                templateid = Utils.StrToInt(Utils.GetCookie(Utils.GetTemplateCookieName()), GeneralConfigs.GetConfig().Templateid);
                            }

                            //使用系统默认模板
                            if (templateid == 0)
                            {
                                templateid = GeneralConfigs.GetConfig().Templateid;
                            }
                        }
                        strTemplateid = templateid.ToString();
                        break;
                    }
                }
            }

            return(strTemplateid);
        }
Beispiel #13
0
        /// <summary>
        /// 分割主题
        /// </summary>
        /// <param name="postidlist">帖子id列表</param>
        /// <param name="subject">主题</param>
        /// <param name="topicId">主题id列表</param>
        /// <returns>更新记录数</returns>
        public static int SplitTopics(string postidlist, string subject, string topicId)
        {
            //验证要分割的帖子是否为有效PID号
            string[] postIdArray = postidlist.Split(',');
            if (Utils.StrIsNullOrEmpty(postidlist) || !Utils.IsNumericArray(postIdArray))
            {
                return(-1);
            }

            int tid        = 0;
            int lastPostId = TypeConverter.StrToInt(postIdArray[postIdArray.Length - 1]);

            //将要被分割主题的tid
            TopicInfo originalTopicInfo = Topics.GetTopicInfo(TypeConverter.StrToInt(topicId)); //原主题信息
            TopicInfo newTopicInfo      = new TopicInfo();                                      //新主题信息
            PostInfo  lastPostInfo      = Posts.GetPostInfo(originalTopicInfo.Tid, lastPostId);
            PostInfo  firstPostInfo     = Posts.GetPostInfo(originalTopicInfo.Tid, TypeConverter.StrToInt(postIdArray[0]));

            newTopicInfo.Poster       = firstPostInfo.Poster;
            newTopicInfo.Posterid     = firstPostInfo.Posterid;
            newTopicInfo.Postdatetime = Utils.GetDateTime();
            newTopicInfo.Displayorder = 0;
            newTopicInfo.Highlight    = "";
            newTopicInfo.Digest       = 0;
            newTopicInfo.Rate         = 0;
            newTopicInfo.Hide         = 0;
            newTopicInfo.Special      = 0;
            newTopicInfo.Attachment   = 0;
            newTopicInfo.Moderated    = 0;
            newTopicInfo.Closed       = 0;
            newTopicInfo.Views        = 0;
            newTopicInfo.Fid          = originalTopicInfo.Fid;
            newTopicInfo.Forumname    = originalTopicInfo.Forumname;
            newTopicInfo.Iconid       = originalTopicInfo.Iconid;
            newTopicInfo.Typeid       = originalTopicInfo.Typeid;
            newTopicInfo.Replies      = postIdArray.Length - 1;
            newTopicInfo.Title        = Utils.HtmlEncode(subject);
            newTopicInfo.Lastposterid = lastPostInfo.Posterid;
            newTopicInfo.Lastpost     = lastPostInfo.Postdatetime;
            newTopicInfo.Lastposter   = lastPostInfo.Poster;

            tid = Topics.CreateTopic(newTopicInfo);
            DatabaseProvider.GetInstance().UpdatePostTid(postidlist, tid, Data.PostTables.GetPostTableId(tid));
            DatabaseProvider.GetInstance().SetPrimaryPost(subject, tid, postIdArray, Discuz.Data.PostTables.GetPostTableId(tid));

            newTopicInfo.Tid        = tid;
            newTopicInfo.Lastpostid = lastPostId;
            if (originalTopicInfo.Lastpostid == lastPostId)//当需要将原主题的最后一个发帖分割走时(即分割列表中有和原主题Lastpostid相同的值)
            {
                newTopicInfo.Lastposterid = originalTopicInfo.Posterid;
                newTopicInfo.Lastpost     = originalTopicInfo.Lastpost;
                newTopicInfo.Lastposter   = originalTopicInfo.Poster;
                DataTable dt = DatabaseProvider.GetInstance().GetLastPostNotInPidList(postidlist, originalTopicInfo.Tid, int.Parse(Posts.GetPostTableId()));
                originalTopicInfo.Lastpostid   = TypeConverter.ObjectToInt(dt.Rows[0]["pid"]);
                originalTopicInfo.Lastposterid = TypeConverter.ObjectToInt(dt.Rows[0]["Posterid"].ToString());
                originalTopicInfo.Lastpost     = dt.Rows[0]["Postdatetime"].ToString();
                originalTopicInfo.Lastposter   = dt.Rows[0]["Poster"].ToString();
            }
            originalTopicInfo.Replies = originalTopicInfo.Replies - postIdArray.Length;

            Topics.UpdateTopic(originalTopicInfo);//更新原主题的信息
            Topics.UpdateTopicReplyCount(originalTopicInfo.Tid);

            Topics.UpdateTopic(newTopicInfo);//由于数据库中对lastpostid有list约束,所以不能有重复值,则必须在原主题的lastpostid修改之后再次修改才能将数据最终修正完毕
            Topics.UpdateTopicReplyCount(tid);

            return(tid);
        }