Esempio n. 1
0
        protected void repFileReName_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            string pdir  = function.VToP(CurDirPath);
            string ppath = pdir + e.CommandArgument.ToString();
            string fname = Path.GetFileNameWithoutExtension(e.CommandArgument.ToString());
            string ext   = Path.GetExtension(e.CommandArgument.ToString());

            if (e.CommandName == "DelFiles")
            {
                FileSystemObject.Delete(ppath, FsoMethod.File);
                Response.Redirect(Request.RawUrl);
            }
            if (e.CommandName == "DelDir")
            {
                FileSystemObject.Delete(ppath, FsoMethod.Folder);
                Response.Redirect(Request.RawUrl);
            }
            if (e.CommandName == "CopyDir")
            {
                FileSystemObject.CopyDirectory(ppath, pdir + fname + "_" + Resources.L.制 + ext); //"复制_" + ppath
                Response.Redirect(Request.RawUrl);
            }
            if (e.CommandName == "CopyFiles")
            {
                FileSystemObject.CopyFile(ppath, pdir + fname + "_" + Resources.L.制 + ext);
                Response.Redirect(Request.RawUrl);
            }
            if (e.CommandName == "DownFiles")
            {
                SafeSC.DownFile(CurDirPath + e.CommandArgument.ToString(), e.CommandArgument.ToString());
            }
        }
        protected void repFileReName_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            string fname = Path.GetFileNameWithoutExtension(e.CommandArgument.ToString());
            string ext   = Path.GetExtension(e.CommandArgument.ToString());

            if (e.CommandName == "DelFiles")
            {
                FileSystemObject.Delete(PPathDir + e.CommandArgument.ToString(), FsoMethod.File);
            }
            if (e.CommandName == "DelDir")
            {
                FileSystemObject.Delete(PPathDir + e.CommandArgument.ToString(), FsoMethod.Folder);
            }
            if (e.CommandName == "CopyFiles")
            {
                FileSystemObject.CopyFile(PPathDir + e.CommandArgument.ToString(), PPathDir + fname + "_复制" + ext);
            }
            if (e.CommandName == "CopyDir")
            {
                FileSystemObject.CopyDirectory(PPathDir + e.CommandArgument.ToString(), PPathDir + fname + "_复制" + ext);
            }
            if (e.CommandName == "DownFiles")
            {
                string filePath = function.PToV(PPathDir) + e.CommandArgument.ToString();

                SafeSC.DownFile(filePath, HttpUtility.UrlEncode(e.CommandArgument.ToString(), System.Text.Encoding.UTF8));
            }
            Response.Redirect(Request.RawUrl);
        }
 protected void EBtnCopyDir_Click(object sender, EventArgs e)
 {
     if (!FileSystemObject.IsExist(this.currentDirectory + this.TxtCopyDir.Text, FsoMethod.Folder))
     {
         base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
         FileSystemObject.CopyDirectory(this.currentDirectory + this.HdnCopyDir.Value, this.currentDirectory + this.TxtCopyDir.Text);
         AdminPage.WriteSuccessMsg("<li>复制目录成功。</li>", this.m_UrlReferrer);
     }
     else
     {
         AdminPage.WriteErrMsg("<li>重命名的目录已经存在了。</li>", this.m_UrlReferrer);
     }
 }
        protected void EgvFiles_RowCommand(object sender, CommandEventArgs e)
        {
            try
            {
                string str;
                string commandName = e.CommandName;
                if (commandName != null)
                {
                    if (!(commandName == "DelFiles"))
                    {
                        if (commandName == "DelDir")
                        {
                            goto Label_0082;
                        }
                        if (commandName == "CopyDir")
                        {
                            goto Label_00C3;
                        }
                        if (commandName == "CopyFiles")
                        {
                            goto Label_01A7;
                        }
                    }
                    else
                    {
                        FileSystemObject.Delete(this.currentDirectory + e.CommandArgument.ToString(), FsoMethod.File);
                        AdminPage.WriteSuccessMsg("<li>删除文件成功。</li>", this.m_UrlReferrer);
                    }
                }
                return;

Label_0082:
                base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
                FileSystemObject.Delete(this.currentDirectory + e.CommandArgument.ToString(), FsoMethod.Folder);
                AdminPage.WriteSuccessMsg("<li>删除目录成功。</li>", this.m_UrlReferrer);
                return;

Label_00C3:
                if (!FileSystemObject.IsExist(this.currentDirectory + "复件" + e.CommandArgument.ToString(), FsoMethod.Folder))
                {
                    base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
                    FileSystemObject.CopyDirectory(this.currentDirectory + e.CommandArgument.ToString(), this.currentDirectory + "复件" + e.CommandArgument.ToString());
                    AdminPage.WriteSuccessMsg("<li>复制目录成功。</li>", this.m_UrlReferrer);
                }
                else
                {
                    this.HdnCopyDir.Value = e.CommandArgument.ToString();
                    this.LblCopyDir.Text  = "复件" + e.CommandArgument.ToString();
                    this.TxtCopyDir.Text  = "复件" + e.CommandArgument.ToString();
                    this.MpeCopyDir.Show();
                }
                return;

Label_01A7:
                str = e.CommandArgument.ToString();
                if (!string.IsNullOrEmpty(str))
                {
                    string[] strArray = str.Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
                    string   newValue = "复件" + strArray[strArray.Length - 1];
                    string   str3     = str.Replace(strArray[strArray.Length - 1], newValue);
                    if (!FileSystemObject.IsExist(this.currentDirectory + str3, FsoMethod.File))
                    {
                        FileSystemObject.CopyFile(this.currentDirectory + e.CommandArgument.ToString(), this.currentDirectory + str3);
                        AdminPage.WriteSuccessMsg("<li>复制文件成功。</li>", this.m_UrlReferrer);
                    }
                    else
                    {
                        this.HdnCopyFile.Value = e.CommandArgument.ToString();
                        this.LblCopyFile.Text  = str3;
                        this.TxtCopyFile.Text  = str3;
                        this.MpeCopyFile.Show();
                    }
                }
            }
            catch (FileNotFoundException)
            {
                AdminPage.WriteErrMsg("<li>文件未找到!</li>", this.m_UrlReferrer);
            }
            catch (UnauthorizedAccessException)
            {
                AdminPage.WriteErrMsg("<li>访问文件夹或文件时失败!检查您的服务器是否给模板文件夹写入权限。</li>", this.m_UrlReferrer);
            }
        }
Esempio n. 5
0
        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);
            }
        }