Example #1
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);
        }