📄 stylemanage.aspx.cs
字号:
namespace PowerEasy.WebSite.Admin.Template
{
using AjaxControlToolkit;
using PowerEasy.Common;
using PowerEasy.Controls;
using PowerEasy.ExtendedControls;
using PowerEasy.Web.UI;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
public class StyleManage : AdminPage
{
protected Button BtnHiddenCopyDir;
protected Button BtnHiddenCopyFile;
protected Button BtnHiddenCreateDir;
protected Button BtnHiddenDirRename;
protected Button BtnHiddenFileRename;
protected Button BtnMove;
protected string currentDirectory;
protected DropDownList DrpMove;
protected ExtendedButton EBtnBatchDel;
protected ExtendedButton EBtnCopyDir;
protected ExtendedButton EBtnCopyFile;
protected ExtendedButton EBtnCreateTemplate;
protected ExtendedButton EBtnDirReName;
protected ExtendedButton EBtnFileReName;
protected ExtendedButton EBtnNewDir;
protected ExtendedGridView EgvFiles;
protected HiddenField HdnCopyDir;
protected HiddenField HdnCopyFile;
protected HiddenField HdnName;
protected HiddenField HdnStyleManage;
protected HiddenField HdnType;
protected Label LblCopyDir;
protected Label LblCopyFile;
protected Label LblCurrentDir;
protected Literal LitMessageText;
protected Literal LitParentDirButton;
protected Literal LitParentDirLink;
protected string m_UrlReferrer;
protected ModalPopupExtender MpeCopyDir;
protected ModalPopupExtender MpeCopyFile;
protected ModalPopupExtender MpeCreateDir;
protected ModalPopupExtender MpeDirRename;
protected ModalPopupExtender MpeFileRename;
protected AspNetPager Pager;
protected Panel PanButton;
protected string parentDir;
protected Panel PnlCopyDir;
protected Panel PnlCopyFile;
protected Panel PnlCreateDir;
protected Panel PnlDirRename;
protected Panel PnlFileRename;
protected StringBuilder replaceData = new StringBuilder();
protected StringBuilder replaceResult = new StringBuilder();
protected StringBuilder searchResult = new StringBuilder();
protected string skinStyleDir;
protected ExtendedSiteMapPath SmpNavigator;
protected ScriptManager SmStyleManage;
protected TextBox TxtCopyDir;
protected TextBox TxtCopyFile;
protected TextBox TxtDirName;
protected TextBox TxtFileName;
protected TextBox TxtNewDir;
protected RegularExpressionValidator ValeTxtCopyDir;
protected RegularExpressionValidator ValeTxtCopyFile;
protected RegularExpressionValidator ValeTxtDirName;
protected RegularExpressionValidator ValeTxtFileName;
protected RegularExpressionValidator ValeTxtNewDir;
protected PowerEasy.Controls.RequiredFieldValidator ValrTxtCopyDir;
protected PowerEasy.Controls.RequiredFieldValidator ValrTxtCopyFile;
protected PowerEasy.Controls.RequiredFieldValidator ValrTxtDirName;
protected PowerEasy.Controls.RequiredFieldValidator ValrTxtFileName;
protected PowerEasy.Controls.RequiredFieldValidator ValrTxtNewDir;
protected void BindData()
{
DataView defaultView = FileSystemObject.GetDirectoryInfos(this.currentDirectory, FsoMethod.All).DefaultView;
this.Pager.RecordCount = defaultView.Count;
int num = (this.Pager.CurrentPageIndex - 1) * this.Pager.PageSize;
int num2 = num + this.Pager.PageSize;
List<DataRowView> list = new List<DataRowView>();
for (int i = num; i < num2; i++)
{
if (i < defaultView.Count)
{
list.Add(defaultView[i]);
}
}
this.EgvFiles.DataSource = list;
this.EgvFiles.DataBind();
}
protected void BtnMove_Click(object sender, EventArgs e)
{
if (this.EgvFiles.SelectList.Length == 0)
{
AdminPage.WriteErrMsg("未选中文件或文件夹", this.m_UrlReferrer);
}
else
{
string[] strArray = this.EgvFiles.SelectList.ToString().Split(new char[] { ',' });
string path = base.Request.PhysicalApplicationPath + this.skinStyleDir;
if (string.IsNullOrEmpty(this.DrpMove.SelectedValue))
{
AdminPage.WriteErrMsg("<li>请选择目标文件夹</li>", this.m_UrlReferrer);
}
try
{
DirectoryInfo info = new DirectoryInfo(path);
if (info.Exists)
{
foreach (string str2 in strArray)
{
if (!string.IsNullOrEmpty(str2))
{
string str3 = info.FullName + this.DrpMove.SelectedValue + str2;
DirectoryInfo info2 = new DirectoryInfo(this.currentDirectory + str2 + "/");
DirectoryInfo info3 = new DirectoryInfo(info.FullName + this.DrpMove.SelectedValue);
DirectoryInfo info4 = new DirectoryInfo(str3);
if (info2.Exists)
{
if (info3.FullName == info2.FullName)
{
AdminPage.WriteErrMsg("<li>不能移动到自己目录下</li>", this.m_UrlReferrer);
}
if (info2.FullName == info4.FullName)
{
AdminPage.WriteErrMsg("<li>不能移动到相同目录下</li>", this.m_UrlReferrer);
}
if (info4.Exists)
{
AdminPage.WriteErrMsg("<li>目标目录已经存在</li>", this.m_UrlReferrer);
}
FileSystemObject.Move(info2.FullName, str3, FsoMethod.Folder);
}
FileInfo info5 = new FileInfo(this.currentDirectory + str2);
FileInfo info6 = new FileInfo(str3);
if (info5.Exists)
{
if (info5.FullName == info6.FullName)
{
AdminPage.WriteErrMsg("<li>目标路径与源路径相同</li>", this.m_UrlReferrer);
}
if (info6.Exists)
{
AdminPage.WriteErrMsg("<li>目标文件已经存在</li>", this.m_UrlReferrer);
}
FileSystemObject.Move(info5.FullName, str3, FsoMethod.File);
}
}
}
base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
AdminPage.WriteSuccessMsg("移动成功", this.m_UrlReferrer);
}
}
catch (FileNotFoundException)
{
AdminPage.WriteErrMsg("<li>文件未找到</li>", this.m_UrlReferrer);
}
catch (UnauthorizedAccessException)
{
AdminPage.WriteErrMsg("<li>移动文件夹或文件时失败!检查您的服务器是否给风格文件夹写入权限。</li>", this.m_UrlReferrer);
}
}
}
protected void EBtnBatchDel_Click(object sender, EventArgs e)
{
if (this.EgvFiles.SelectList.Length == 0)
{
AdminPage.WriteErrMsg("未选中文件或文件夹", this.m_UrlReferrer);
}
else
{
string[] strArray = this.EgvFiles.SelectList.ToString().Split(new char[] { ',' });
try
{
foreach (string str in strArray)
{
if (!string.IsNullOrEmpty(str))
{
if (string.IsNullOrEmpty(Path.GetExtension(str)))
{
FileSystemObject.Delete(this.currentDirectory + str, FsoMethod.Folder);
}
else
{
FileSystemObject.Delete(this.currentDirectory + str, FsoMethod.File);
}
}
}
base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
AdminPage.WriteSuccessMsg("删除成功", this.m_UrlReferrer);
}
catch (FileNotFoundException)
{
AdminPage.WriteErrMsg("<li>文件未找到</li>", this.m_UrlReferrer);
}
catch (UnauthorizedAccessException)
{
AdminPage.WriteErrMsg("<li>删除文件夹或文件时失败!检查您的服务器是否给风格文件夹写入权限。</li>", this.m_UrlReferrer);
}
}
}
protected void EBtnCopyDir_Click(object sender, EventArgs e)
{
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);
}
protected void EBtnCopyFile_Click(object sender, EventArgs e)
{
base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
FileSystemObject.CopyFile(this.currentDirectory + this.HdnCopyFile.Value, this.currentDirectory + this.TxtCopyFile.Text);
AdminPage.WriteSuccessMsg("<li>复制文件成功。</li>", this.m_UrlReferrer);
}
protected void EBtnCreateTemplate_Click(object sender, EventArgs e)
{
BasePage.ResponseRedirect("StyleSheets.aspx?Dir=" + base.Server.UrlEncode(base.Request.QueryString["Dir"]));
}
protected void EBtnModifyName_Click(object sender, EventArgs e)
{
if (this.Page.IsValid)
{
string str = this.currentDirectory + @"\";
string oldFile = str + this.HdnName.Value;
try
{
if (this.HdnType.Value == "1")
{
string file = str + this.TxtDirName.Text;
if (oldFile == file)
{
AdminPage.WriteErrMsg("重命名目录名不能和原来目录名一样!", this.m_UrlReferrer);
}
if (!FileSystemObject.IsExist(file, FsoMethod.Folder))
{
FileSystemObject.Move(oldFile, file, FsoMethod.Folder);
base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
AdminPage.WriteSuccessMsg("重命名目录成功", this.m_UrlReferrer);
}
else
{
AdminPage.WriteErrMsg("<li>重命目标目录名已经存在。</li>", this.m_UrlReferrer);
}
}
else
{
string str4 = str + this.TxtFileName.Text;
if (oldFile == str4)
{
AdminPage.WriteErrMsg("重命名文件名不能和原来文件名一样!", this.m_UrlReferrer);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -