protected void Page_Load(object sender, EventArgs e)
        {
            B_User.CheckIsLogged(Request.RawUrl);
            M_UserInfo   mu     = buser.GetLogin(false);
            M_Design_Tlp tlpMod = null;

            if (TlpID == -1)
            {
                tlpMod = tlpBll.SelModelByDef(0);
            }
            else
            {
                tlpBll.SelReturnModel(TlpID);
            }
            if (tlpMod == null)
            {
                function.WriteErrMsg("模板不存在");
            }
            //为其注册二级域名
            string           domain    = domainBll.GetNewDomain(mu.UserID.ToString());
            M_IDC_DomainList domainMod = new M_IDC_DomainList();

            domainMod.SType    = 2;
            domainMod.MyStatus = 1;
            domainMod.UserID   = mu.UserID.ToString();
            domainMod.DomName  = domain;
            domainMod.ID       = domainBll.Insert(domainMod);
            //else if (domainMod.UserID == mu.UserID.ToString()) { }//以前注册过,不需要做特殊处理
            //else if (domainMod.UserID != mu.UserID.ToString()) { function.WriteErrMsg("该域名已被占用"); }
            //生成站点信息(用户只能拥有一个站点)
            M_Design_SiteInfo sfMod = sfBll.SelModelByUid(mu.UserID);

            if (sfMod != null)
            {
                mu.SiteID = sfMod.ID;
                if (mu.SiteID < 1)
                {
                    DBCenter.UpdateSQL("ZL_User", "SiteID=" + mu.SiteID, "UserID=" + mu.UserID);
                }
                //function.WriteSuccessMsg("你已经创建站点了,将自动转至用户中心", "/design/user/default.aspx");
            }
            else
            {
                sfMod = new M_Design_SiteInfo();
            }
            //M_Design_SiteInfo sfMod = new M_Design_SiteInfo();
            sfMod.SiteFlag = function.GetRandomString(8).ToLower();
            sfMod.UserID   = mu.UserID.ToString();
            sfMod.UserName = mu.UserName;
            sfMod.ZStatus  = 1;
            sfMod.SiteName = mu.UserName + "的站点";
            sfMod.DomainID = domainMod.ID;
            sfMod.ID       = sfBll.Insert(sfMod);
            //拷贝站点文件
            string tlpdir  = Server.MapPath("/Design/Tlp/" + tlpMod.TlpName + "/");
            string userdir = Server.MapPath("/Site/" + sfMod.ID + "/");

            if (Directory.Exists(userdir))
            {
                Directory.CreateDirectory(userdir);
            }
            if (Directory.Exists(tlpdir))
            {
                FileSystemObject.CopyDirectory(tlpdir, userdir);
            }
            //创建用户节点,先检测是否通过其他途径创建了根节点
            M_Node nodeMod = desNodeBll.GetUserRootNode(mu);

            if (nodeMod.IsNull)
            {
                nodeMod = desNodeBll.CreateUserRootNode(mu);
            }
            nodeMod.NodeBySite = sfMod.ID;
            nodeBll.UpdateByID(nodeMod);
            //导入节点和内容数据(从公用数据区)
            string commonDir = Server.MapPath("/design/tlp/common/init/");
            //DataTable nodeDT = XmlToDT(function.VToP(commonDir + "Node.xml"));
            DataTable nodeDT = DBCenter.Sel("ZL_Node", "ParentID=797");//1站点,非根节点信息
            DataTable conDT  = XmlToDT(function.VToP(commonDir + "CommonModel.xml"));
            DataTable artDT  = XmlToDT(function.VToP(commonDir + "Article.xml"));

            for (int i = 0; i < nodeDT.Rows.Count; i++)
            {
                DataRow dr = nodeDT.Rows[i];
                dr["NodeBySite"] = sfMod.ID;
                dr["ParentID"]   = nodeMod.NodeID;
                dr["CUser"]      = sfMod.UserID;
            }
            //修改逻辑,支持来源拷贝,将站点数据拷贝后-->修改-->写入,即nodedt不再来自XML
            desHelper.ImportContentFromDT(nodeDT, conDT, artDT);
            //根据所选模板,拷贝内容
            string guid = tlpBll.CopyTlp(tlpMod.ID, sfMod);

            if (string.IsNullOrEmpty(guid))
            {
                function.WriteErrMsg("站点创建失败");
            }
            RouteHelper.RouteDT = domainBll.Sel();
            mu.SiteID           = sfMod.ID;
            DBCenter.UpdateSQL("ZL_User", "SiteID=" + mu.SiteID, "UserID=" + mu.UserID);
            if (string.IsNullOrEmpty(RUrl))
            {
                Response.Redirect("/Design/Default.aspx?ID=" + guid);
            }
            else
            {
                Response.Redirect(RUrl);
            }
        }
        protected void Restore_Btn_Click(object sender, EventArgs e)
        {
            string path = TlpFile_T.Text.Trim();
            string tdir = function.VToP("/Site/NoName/");

            if (!File.Exists(path))
            {
                function.WriteErrMsg("站点文件不存在");
            }
            if (!Path.GetExtension(path).ToLower().Equals(".zip"))
            {
                function.WriteErrMsg("文件格式不正确");
            }
            if (Directory.Exists(tdir))
            {
                Directory.Delete(tdir, true);
            }
            //----------------------
            ZipClass zip = new ZipClass();

            zip.UnZipFiles(path, tdir);
            //还原信息(尽量少或不清除)
            DataSet siteDS = new DataSet();

            siteDS.ReadXml(tdir + "Init/Site.xml");
            //-------------站点信息(仍建立资源文件夹,但不用于建site信息了)
            DataTable         siteDT = siteDS.Tables["ZL_Design_SiteInfo"];
            M_Design_SiteInfo sfMod  = new M_Design_SiteInfo().GetModelFromReader(siteDT.Rows[0]);

            SiteConfig.SiteInfo.SiteName = sfMod.SiteName;
            //-------------导入页面
            B_CodeModel pageBll = new B_CodeModel("ZL_Design_Page");

            SqlHelper.ExecuteSql("TRUNCATE TABLE ZL_Design_Page");
            DataSet pageDS = new DataSet();

            pageDS.ReadXml(tdir + "Init/Page.xml");
            DataTable pageDT = pageDS.Tables[0];

            for (int i = 0; i < pageDT.Rows.Count; i++)
            {
                pageDT.Rows[i]["SiteID"] = 0;
                pageDT.Rows[i]["CDate"]  = DateTime.Now;
                pageDT.Rows[i]["UPDate"] = DateTime.Now;
                pageBll.Insert(pageDT.Rows[i]);
            }
            //-------------导入节点|内容(新建一个节点)
            SqlHelper.ExecuteSql("TRUNCATE TABLE ZL_Node");
            SqlHelper.ExecuteSql("TRUNCATE TABLE ZL_CommonModel"); //可注释
            SqlHelper.ExecuteSql("TRUNCATE TABLE ZL_C_Article");
            DataTable nodeDT = siteDS.Tables["ZL_Node"];           //与站点绑定,其他内容与节点绑定
            DataTable conDT  = siteDS.Tables["ZL_CommonModel"];
            DataTable artDT  = siteDS.Tables["ZL_C_Article"];

            for (int i = 0; i < nodeDT.Rows.Count; i++)
            {
                DataRow dr = nodeDT.Rows[i];
                dr["NodeBySite"] = 0;
                dr["ParentID"]   = 0;
                dr["CUser"]      = 0;
            }
            desHelper.ImportContentFromDT(nodeDT, conDT, artDT);
            //移动文件
            string siteDir = function.VToP(sfMod.SiteDir);

            if (!Directory.Exists(tdir))
            {
                function.WriteErrMsg("来源目录不存在");
            }
            if (Directory.Exists(siteDir))
            {
                Directory.Delete(siteDir, true);
            }
            Directory.Move(tdir, siteDir);
            function.WriteSuccessMsg("恢复站点成功,即将跳转首页", "/");
        }