예제 #1
0
파일: Convert.cs 프로젝트: wenysky/reimu
        /// <summary>
        /// 转换论坛版块
        /// </summary>
        public static void ConvertForums()
        {
            DBHelper dbhConvertForums = new DBHelper(MainForm.targetDbConn, "System.Data.SqlClient");
            dbhConvertForums.Open();
            MainForm.MessageForm.SetMessage("开始转换版块\r\n");
            MainForm.SuccessedRecordCount = 0;
            MainForm.FailedRecordCount = 0;

            MainForm.RecordCount = Provider.Provider.GetInstance().GetForumsRecordCount();

            MainForm.MessageForm.InitTotalProgressBar(1);
            MainForm.MessageForm.InitCurrentProgressBar(MainForm.RecordCount);

            //清理数据库
            dbhConvertForums.TruncateTable(string.Format("{0}forums", MainForm.cic.TargetDbTablePrefix));
            dbhConvertForums.TruncateTable(string.Format("{0}forumfields", MainForm.cic.TargetDbTablePrefix));

            //try
            //{
            dbhConvertForums.SetIdentityInsertON(string.Format("{0}forums", MainForm.cic.TargetDbTablePrefix));
            //}
            //catch (Exception ex)
            //{
            //    MainForm.MessageForm.SetMessage(string.Format("{0}\r\n", ex.Message));
            //}
            #region sql语句
            string sqlForum = string.Format(@"INSERT INTO {0}forums
            (
            fid,
            layer,
            parentid,
            pathlist,
            parentidlist,
            subforumcount,
            name,
            status,
            colcount,
            displayorder,
            templateid,
            topics,
            curtopics,
            posts,
            todayposts,
            lasttid,
            lasttitle,
            lastpost,
            lastposterid,
            lastposter,
            allowsmilies,
            allowrss,
            allowhtml,
            allowbbcode,
            allowimgcode,
            allowblog,
            istrade,
            allowpostspecial,
            allowspecialonly,
            alloweditrules,
            allowthumbnail,
            allowtag,
            recyclebin,
            modnewposts,
            jammer,
            disablewatermark,
            inheritedmod,
            autoclose
            )
            VALUES
            (
            @fid,
            @layer,
            @parentid,
            @pathlist,
            @parentidlist,
            @subforumcount,
            @name,
            @status,
            @colcount,
            @displayorder,
            @templateid,
            @topics,
            @curtopics,
            @posts,
            @todayposts,
            @lasttid,
            @lasttitle,
            @lastpost,
            @lastposterid,
            @lastposter,
            @allowsmilies,
            @allowrss,
            @allowhtml,
            @allowbbcode,
            @allowimgcode,
            @allowblog,
            @istrade,
            @allowpostspecial,
            @allowspecialonly,
            @alloweditrules,
            @allowthumbnail,
            @allowtag,
            @recyclebin,
            @modnewposts,
            @jammer,
            @disablewatermark,
            @inheritedmod,
            @autoclose
            )", MainForm.cic.TargetDbTablePrefix);
            string sqlForumfields = string.Format(@"INSERT INTO {0}forumfields
            (
            fid,
            password,
            icon,
            postcredits,
            replycredits,
            redirect,
            attachextensions,
            rules,
            topictypes,
            viewperm,
            postperm,
            replyperm,
            getattachperm,
            postattachperm,
            moderators,
            description,
            applytopictype,
            postbytopictype,
            viewbytopictype,
            topictypeprefix,
            permuserlist
            )
            VALUES
            (
            @fid,
            @password,
            @icon,
            @postcredits,
            @replycredits,
            @redirect,
            @attachextensions,
            @rules,
            @topictypes,
            @viewperm,
            @postperm,
            @replyperm,
            @getattachperm,
            @postattachperm,
            @moderators,
            @description,
            @applytopictype,
            @postbytopictype,
            @viewbytopictype,
            @topictypeprefix,
            @permuserlist
            )
            ", MainForm.cic.TargetDbTablePrefix);
            #endregion

            List<Forums> forumList = Provider.Provider.GetInstance().GetForumList();
            foreach (Forums objForum in forumList)
            {
                try
                {
                    //清理上次执行的参数
                    dbhConvertForums.ParametersClear();
                    #region dnt_forums表参数
                    dbhConvertForums.ParameterAdd("@fid", objForum.fid, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@layer", objForum.layer, DbType.Int16, 2);
                    dbhConvertForums.ParameterAdd("@parentid", objForum.parentid, DbType.Int16, 2);
                    dbhConvertForums.ParameterAdd("@pathlist", objForum.pathlist, DbType.String, 3000);
                    dbhConvertForums.ParameterAdd("@parentidlist", objForum.parentidlist, DbType.String, 300);
                    dbhConvertForums.ParameterAdd("@subforumcount", objForum.subforumcount, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@name", objForum.name, DbType.String, 50);
                    dbhConvertForums.ParameterAdd("@status", objForum.status, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@colcount", objForum.colcount, DbType.Int16, 2);
                    dbhConvertForums.ParameterAdd("@displayorder", objForum.displayorder, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@templateid", objForum.templateid, DbType.Int16, 2);
                    dbhConvertForums.ParameterAdd("@topics", objForum.topics, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@curtopics", objForum.curtopics, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@posts", objForum.posts, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@todayposts", objForum.todayposts, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@lasttid", objForum.lasttid, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@lasttitle", objForum.lasttitle, DbType.String, 60);
                    dbhConvertForums.ParameterAdd("@lastpost", objForum.lastpost, DbType.DateTime, 8);
                    dbhConvertForums.ParameterAdd("@lastposterid", objForum.lastposterid, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@lastposter", objForum.lastposter, DbType.String, 20);
                    dbhConvertForums.ParameterAdd("@allowsmilies", objForum.allowsmilies, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@allowrss", objForum.allowrss, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@allowhtml", objForum.allowhtml, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@allowbbcode", objForum.allowbbcode, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@allowimgcode", objForum.allowimgcode, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@allowblog", objForum.allowblog, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@istrade", objForum.istrade, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@allowpostspecial", objForum.allowpostspecial, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@allowspecialonly", objForum.allowspecialonly, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@alloweditrules", objForum.alloweditrules, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@allowthumbnail", objForum.allowthumbnail, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@allowtag", objForum.allowtag, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@recyclebin", objForum.recyclebin, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@modnewposts", objForum.modnewposts, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@jammer", objForum.jammer, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@disablewatermark", objForum.disablewatermark, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@inheritedmod", objForum.inheritedmod, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@autoclose", objForum.autoclose, DbType.Int32, 2);
                    #endregion
                    dbhConvertForums.ExecuteNonQuery(sqlForum);//插入dnt_forums表

                    //清理上次执行的参数
                    dbhConvertForums.ParametersClear();
                    #region dnt_forumfields表参数
                    dbhConvertForums.ParameterAdd("@fid", objForum.fid, DbType.Int32, 4);
                    dbhConvertForums.ParameterAdd("@password", objForum.password, DbType.String, 16);
                    dbhConvertForums.ParameterAdd("@icon", objForum.icon, DbType.String, 255);
                    dbhConvertForums.ParameterAdd("@postcredits", objForum.postcredits, DbType.String, 255);
                    dbhConvertForums.ParameterAdd("@replycredits", objForum.replycredits, DbType.String, 255);
                    dbhConvertForums.ParameterAdd("@redirect", objForum.redirect, DbType.String, 255);
                    dbhConvertForums.ParameterAdd("@attachextensions", objForum.attachextensions, DbType.String, 255);
                    dbhConvertForums.ParameterAdd("@rules", objForum.rules, DbType.String, 4000);
                    dbhConvertForums.ParameterAdd("@topictypes", objForum.topictypes, DbType.String, 4000);
                    dbhConvertForums.ParameterAdd("@viewperm", objForum.viewperm, DbType.String, 4000);
                    dbhConvertForums.ParameterAdd("@postperm", objForum.postperm, DbType.String, 4000);
                    dbhConvertForums.ParameterAdd("@replyperm", objForum.replyperm, DbType.String, 4000);
                    dbhConvertForums.ParameterAdd("@getattachperm", objForum.getattachperm, DbType.String, 4000);
                    dbhConvertForums.ParameterAdd("@postattachperm", objForum.postattachperm, DbType.String, 4000);
                    dbhConvertForums.ParameterAdd("@moderators", objForum.moderators, DbType.String, 4000);
                    dbhConvertForums.ParameterAdd("@description", objForum.description, DbType.String, 4000);
                    dbhConvertForums.ParameterAdd("@applytopictype", objForum.applytopictype, DbType.Byte, 1);
                    dbhConvertForums.ParameterAdd("@postbytopictype", objForum.postbytopictype, DbType.Byte, 1);
                    dbhConvertForums.ParameterAdd("@viewbytopictype", objForum.viewbytopictype, DbType.Byte, 1);
                    dbhConvertForums.ParameterAdd("@topictypeprefix", objForum.topictypeprefix, DbType.Byte, 1);
                    dbhConvertForums.ParameterAdd("@permuserlist", objForum.permuserlist, DbType.String, 4000);
                    //MainForm.targetDBH.ParameterAdd("@", objForum, DbType);
                    #endregion
                    dbhConvertForums.ExecuteNonQuery(sqlForumfields);//插入dnt_forumfields表
                    MainForm.SuccessedRecordCount++;
                }
                catch (Exception ex)
                {
                    MainForm.MessageForm.SetMessage(string.Format("错误:{0}.fid={1}\r\n", ex.Message, objForum.fid));
                    MainForm.FailedRecordCount++;
                }
                MainForm.MessageForm.CurrentProgressBarNumAdd();
            }
            MainForm.MessageForm.TotalProgressBarNumAdd();

            //dbh.ExecuteNonQuery(string.Format("SET IDENTITY_INSERT {0}forums OFF", MainForm.cic.TargetDbTablePrefix));
            dbhConvertForums.SetIdentityInsertOFF(string.Format("{0}forums", MainForm.cic.TargetDbTablePrefix));
            dbhConvertForums.Close();
            dbhConvertForums.Dispose();
            MainForm.RecordCount = -1;
            MainForm.MessageForm.SetMessage(string.Format("完成转换版块。成功{0},失败{1}\r\n", MainForm.SuccessedRecordCount, MainForm.FailedRecordCount));
            //整理版块
            Utils.Forums.ResetForums();
            MainForm.MessageForm.SetMessage("完成整理版块\r\n");
        }
예제 #2
0
파일: Convert.cs 프로젝트: wenysky/reimu
        /// <summary>
        /// 转换主题分类
        /// </summary>
        public static void ConvertTopicTypes()
        {
            DBHelper dbhConvertTopicTypes = new DBHelper(MainForm.targetDbConn, "System.Data.SqlClient");
            dbhConvertTopicTypes.Open();
            MainForm.MessageForm.SetMessage("开始转换主题分类\r\n");
            MainForm.SuccessedRecordCount = 0;
            MainForm.FailedRecordCount = 0;

            MainForm.RecordCount = Provider.Provider.GetInstance().GetTopicTypesRecordCount();

            MainForm.MessageForm.InitTotalProgressBar(1);
            MainForm.MessageForm.InitCurrentProgressBar(MainForm.RecordCount);

            //清理数据库
            dbhConvertTopicTypes.TruncateTable(string.Format("{0}topictypes", MainForm.cic.TargetDbTablePrefix));
            dbhConvertTopicTypes.SetIdentityInsertON(string.Format("{0}topictypes", MainForm.cic.TargetDbTablePrefix));

            //得到主题列表
            List<TopicTypes> topictypeList = Provider.Provider.GetInstance().GetTopicTypeList();
            foreach (TopicTypes objTopicType in topictypeList)
            {
                #region sql语句
                string sqlTopicType = string.Format(@"INSERT INTO {0}topictypes
            (
            typeid,
            displayorder,
            name,
            description
            )
            VALUES
            (
            @typeid,
            @displayorder,
            @name,
            @description
            )", MainForm.cic.TargetDbTablePrefix);
                #endregion
                //清理上次执行的参数
                dbhConvertTopicTypes.ParametersClear();
                #region dnt_topictypes表参数
                dbhConvertTopicTypes.ParameterAdd("@typeid", objTopicType.typeid, DbType.Int32, 4);
                dbhConvertTopicTypes.ParameterAdd("@displayorder", objTopicType.displayorder, DbType.Int32, 4);
                dbhConvertTopicTypes.ParameterAdd("@name", objTopicType.name, DbType.String, 30);
                dbhConvertTopicTypes.ParameterAdd("@description", objTopicType.description, DbType.String, 500);
                #endregion

                try
                {
                    dbhConvertTopicTypes.ExecuteNonQuery(sqlTopicType);//插入dnt_topictypes表
                    MainForm.SuccessedRecordCount++;
                }
                catch (Exception ex)
                {
                    MainForm.MessageForm.SetMessage(string.Format("错误:{0}。typeid={1}\r\n", ex.Message, objTopicType.typeid));
                    MainForm.FailedRecordCount++;
                }
                MainForm.MessageForm.CurrentProgressBarNumAdd();
            }
            //一次分页完毕
            MainForm.MessageForm.TotalProgressBarNumAdd();

            dbhConvertTopicTypes.SetIdentityInsertOFF(string.Format("{0}topictypes", MainForm.cic.TargetDbTablePrefix));
            dbhConvertTopicTypes.Dispose();
            MainForm.RecordCount = -1;
            MainForm.MessageForm.SetMessage(string.Format("完成转换主题分类。成功{0},失败{1}\r\n", MainForm.SuccessedRecordCount, MainForm.FailedRecordCount));
        }