📄 templatemanage.aspx.cs
字号:
else
{
string str6 = str + this.TxtFileName.Text;
if (oldFile == str6)
{
AdminPage.WriteErrMsg("重命名文件名不能和原来文件名一样!", this.m_UrlReferrer);
}
if (!FileSystemObject.IsExist(str6, FsoMethod.File))
{
FileSystemObject.Move(oldFile, str6, FsoMethod.File);
successMessage = "重命名文件成功!";
if (this.ChkUpdateFileContactinformation.Checked)
{
DirectoryInfo info4 = new DirectoryInfo(base.Request.PhysicalApplicationPath + SiteConfig.SiteOption.TemplateDir);
FileInfo info5 = new FileInfo(oldFile);
FileInfo info6 = new FileInfo(str6);
oldFile = info5.FullName.Replace(info4.FullName, "");
str6 = info6.FullName.Replace(info4.FullName, "");
oldFile = oldFile.Replace(@"\", "/");
str6 = str6.Replace(@"\", "/");
Template.UpdateFileName(oldFile, str6);
successMessage = successMessage + "相关联该文件的模版引用已改变!";
}
}
else
{
AdminPage.WriteErrMsg("<li>重命目标文件名已经存在。</li>", this.m_UrlReferrer);
}
}
AdminPage.WriteSuccessMsg(successMessage, this.m_UrlReferrer);
}
catch (FileNotFoundException)
{
AdminPage.WriteErrMsg("文件未找到", this.m_UrlReferrer);
}
catch (UnauthorizedAccessException)
{
AdminPage.WriteErrMsg("<li>重命名文件夹或文件失败!检查您的服务器是否给模板文件夹写入权限。</li>", this.m_UrlReferrer);
}
}
}
protected void EBtnNewDir_Click(object sender, EventArgs e)
{
if (this.Page.IsValid)
{
try
{
DirectoryInfo info = new DirectoryInfo(this.currentDirectory + @"\" + this.TxtNewDir.Text);
if (info.Exists)
{
AdminPage.WriteErrMsg("新建的目录已经存在", this.m_UrlReferrer);
}
FileSystemObject.Create(this.currentDirectory + @"\" + this.TxtNewDir.Text, FsoMethod.Folder);
base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
AdminPage.WriteSuccessMsg("新建目录成功", this.m_UrlReferrer);
}
catch (FileNotFoundException)
{
AdminPage.WriteErrMsg("文件未找到", this.m_UrlReferrer);
}
catch (UnauthorizedAccessException)
{
AdminPage.WriteErrMsg("<li>新建目录失败!检查您的服务器是否给模板文件夹写入权限。</li>", this.m_UrlReferrer);
}
}
}
protected void EBtnTemplateManage_Click(object sender, EventArgs e)
{
BasePage.ResponseRedirect("TemplateReplace.aspx?Dir=" + base.Server.UrlEncode(base.Request.QueryString["Dir"]));
}
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);
}
}
protected void EgvFiles_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int num = DataConverter.CLng(DataBinder.Eval(e.Row.DataItem, "type"));
string str = "";
if (num == 1)
{
str = "TemplateManage.aspx?Dir=" + base.Server.UrlEncode(base.Request.QueryString["Dir"] + "/" + DataBinder.Eval(e.Row.DataItem, "name").ToString());
}
else
{
str = "Template.aspx?Action=Modify&Dir=" + base.Server.UrlEncode(base.Request.QueryString["Dir"] + "/" + DataBinder.Eval(e.Row.DataItem, "name").ToString());
}
e.Row.Attributes.Add("ondblclick", "RowDblclick('" + str + "');");
}
}
protected string GetSize(string size)
{
return FileSystemObject.ConvertSizeToShow(DataConverter.CLng(size));
}
protected void InitPage()
{
this.ValeTxtNewDir.ValidationExpression = "^[^\\/ :*?\"<>|.]+";
this.ValeTxtFileName.ValidationExpression = "^[^\\/ :*?\"<>|.]+\\.html$";
this.ValeTxtDirName.ValidationExpression = "^[^\\/ :*?\"<>|.]+";
this.ValeTxtCopyDir.ValidationExpression = "^[^\\/ :*?\"<>|.]+";
this.ValeTxtCopyFile.ValidationExpression = "^[^\\/ :*?\"<>|.]+\\.html$";
string templateDir = SiteConfig.SiteOption.TemplateDir;
if (!string.IsNullOrEmpty(templateDir))
{
string str2 = BasePage.RequestString("Dir");
if (!string.IsNullOrEmpty(str2))
{
this.LblCurrentDir.Text = str2;
if (str2.LastIndexOf("/") > 0)
{
this.parentDir = str2.Remove(str2.LastIndexOf("/"), str2.Length - str2.LastIndexOf("/"));
}
}
else
{
this.LblCurrentDir.Text = "/" + str2;
}
this.currentDirectory = base.Request.PhysicalApplicationPath + templateDir + str2 + "/";
this.currentDirectory = this.currentDirectory.Replace("/", @"\");
this.currentDirectory = this.currentDirectory.Replace(@"\\", @"\");
if (!this.Page.IsPostBack)
{
string str5;
DirectoryInfo info = new DirectoryInfo(base.Request.PhysicalApplicationPath + templateDir);
if (info.Exists)
{
foreach (DirectoryInfo info2 in info.GetDirectories("*", SearchOption.AllDirectories))
{
if (!info2.FullName.Contains("标签库") && !info2.FullName.Contains("分页标签库"))
{
string text = (info2.FullName.Remove(0, info.FullName.Length) + "/").Replace(@"\", "/");
this.DrpMove.Items.Add(new ListItem(text, text));
}
}
}
if (((str5 = BasePage.RequestString("Action")) != null) && (str5 == "TemplateSearch"))
{
this.TemplateSearch();
this.BindData();
}
else
{
DirectoryInfo info3 = new DirectoryInfo(this.currentDirectory);
if (info3.Exists)
{
this.BindData();
}
}
}
}
else
{
this.PanButton.Visible = false;
this.LitMessageText.Text = "请到网站配置中配置模板方案文件夹!";
this.LitMessageText.Visible = true;
}
if (!string.IsNullOrEmpty(BasePage.RequestString("Dir")))
{
this.LitParentDirLink.Text = "<a href=\"TemplateManage.aspx?Dir=" + this.parentDir + "\">返回上一级</a>";
this.LitParentDirButton.Text = " <input id=\"Button1\" type=\"button\" class=\"inputbutton\" value=\"返回上一级\" onclick=\"javascript:location.href='TemplateManage.aspx?Dir=" + this.parentDir + "';\" />";
}
else
{
this.LitParentDirLink.Text = "<a disabled='disabled'>返回上一级</a>";
this.LitParentDirButton.Text = " <input id=\"Button1\" type=\"button\" class=\"inputbutton\" value=\"返回上一级\" disabled='disabled' />";
}
}
protected void Page_Load(object sender, EventArgs e)
{
this.m_UrlReferrer = "TemplateManage.aspx?Dir=" + base.Server.UrlEncode(BasePage.RequestString("Dir"));
this.SmpNavigator.CurrentNode = "<a href=\"TemplateManage.aspx\">模板管理</a>";
string str = BasePage.RequestString("Dir");
if (!string.IsNullOrEmpty(str))
{
StringBuilder builder = new StringBuilder();
string[] strArray = str.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < strArray.Length; i++)
{
StringBuilder builder2 = new StringBuilder();
for (int j = 0; j <= i; j++)
{
builder2.Append("/" + strArray[j]);
}
if (builder.Length > 0)
{
builder.Append(" >> ");
}
builder.Append("<a href=\"TemplateManage.aspx?Dir=" + base.Server.UrlEncode(builder2.ToString()) + "\">" + strArray[i] + "</a>");
}
this.SmpNavigator.AdditionalNode = builder.ToString();
}
this.InitPage();
}
protected void Pager_PageChanged(object src, PageChangedEventArgs e)
{
this.Pager.CurrentPageIndex = e.NewPageIndex;
this.BindData();
}
protected void TemplateSearch()
{
int num = BasePage.RequestInt32("DropSearch");
string str = "";
string str2 = BasePage.RequestString("TxtSearch");
if (num == 0)
{
str = "模板文件名";
}
else
{
str = "模板内容";
}
this.LblCurrentDir.Visible = false;
this.LblNavigation.Text = "搜索" + str + " <span style='color:blue;'> " + DataSecurity.HtmlEncode(str2) + " </span> 关键字<br/>";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -