public void Return_OnClick(object sender, EventArgs e) { PageUtils.Redirect(PageTemplateJs.GetRedirectUrl(SiteId)); }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { if (fileName != null) { var isChanged = false; if (PathUtils.RemoveExtension(fileName) != PathUtils.RemoveExtension(RelatedFileName.Text))//文件名改变 { var fileNames = DirectoryUtils.GetFileNames(directoryPath); foreach (var theFileName in fileNames) { var fileNameWithoutExtension = PathUtils.RemoveExtension(theFileName); if (fileNameWithoutExtension == RelatedFileName.Text.ToLower()) { FailMessage("脚本文件修改失败,脚本文件已存在!"); return; } } isChanged = true; } if (PathUtils.GetExtension(fileName) != ltlCreatedFileExtName.Text)//文件后缀改变 { isChanged = true; } var previousFileName = string.Empty; if (isChanged) { previousFileName = fileName; } var currentFileName = RelatedFileName.Text + ltlCreatedFileExtName.Text; var charset = ECharsetUtils.GetEnumType(Charset.SelectedValue); try { FileUtils.WriteText(PathUtils.Combine(directoryPath, currentFileName), charset, Content.Text); if (!string.IsNullOrEmpty(previousFileName)) { FileUtils.DeleteFileIfExists(PathUtils.Combine(directoryPath, previousFileName)); } Body.AddSiteLog(PublishmentSystemId, "修改脚本文件", $"脚本文件:{currentFileName}"); SuccessMessage("脚本文件修改成功!"); AddWaitAndRedirectScript(PageTemplateJs.GetRedirectUrl(PublishmentSystemId)); } catch (Exception ex) { FailMessage(ex, "脚本文件修改失败," + ex.Message); } } else { var currentFileName = RelatedFileName.Text + ltlCreatedFileExtName.Text; var fileNames = DirectoryUtils.GetFileNames(directoryPath); foreach (var theFileName in fileNames) { if (StringUtils.EqualsIgnoreCase(theFileName, currentFileName)) { FailMessage("脚本文件添加失败,脚本文件文件已存在!"); return; } } var charset = ECharsetUtils.GetEnumType(Charset.SelectedValue); try { FileUtils.WriteText(PathUtils.Combine(directoryPath, currentFileName), charset, Content.Text); Body.AddSiteLog(PublishmentSystemId, "添加脚本文件", $"脚本文件:{currentFileName}"); SuccessMessage("脚本文件添加成功!"); AddWaitAndRedirectScript(PageTemplateJs.GetRedirectUrl(PublishmentSystemId)); } catch (Exception ex) { FailMessage(ex, "脚本文件添加失败," + ex.Message); } } } }
public override void Submit_OnClick(object sender, EventArgs e) { if (!Page.IsPostBack || !Page.IsValid) { return; } if (_fileName != null) { var isChanged = false; if (PathUtils.RemoveExtension(_fileName) != PathUtils.RemoveExtension(TbRelatedFileName.Text))//文件名改变 { var fileNames = DirectoryUtils.GetFileNames(_directoryPath); foreach (var theFileName in fileNames) { var fileNameWithoutExtension = PathUtils.RemoveExtension(theFileName); if (fileNameWithoutExtension == TbRelatedFileName.Text.ToLower()) { FailMessage("脚本文件修改失败,脚本文件已存在!"); return; } } isChanged = true; } var previousFileName = string.Empty; if (isChanged) { previousFileName = _fileName; } var currentFileName = TbRelatedFileName.Text + ".js"; var charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue); FileUtils.WriteText(PathUtils.Combine(_directoryPath, currentFileName), charset, TbContent.Text); if (!string.IsNullOrEmpty(previousFileName)) { FileUtils.DeleteFileIfExists(PathUtils.Combine(_directoryPath, previousFileName)); } Body.AddSiteLog(SiteId, "修改脚本文件", $"脚本文件:{currentFileName}"); SuccessMessage("脚本文件修改成功!"); AddWaitAndRedirectScript(PageTemplateJs.GetRedirectUrl(SiteId)); } else { var currentFileName = TbRelatedFileName.Text + ".js"; var fileNames = DirectoryUtils.GetFileNames(_directoryPath); foreach (var theFileName in fileNames) { if (StringUtils.EqualsIgnoreCase(theFileName, currentFileName)) { FailMessage("脚本文件添加失败,脚本文件文件已存在!"); return; } } var charset = ECharsetUtils.GetEnumType(DdlCharset.SelectedValue); FileUtils.WriteText(PathUtils.Combine(_directoryPath, currentFileName), charset, TbContent.Text); Body.AddSiteLog(SiteId, "添加脚本文件", $"脚本文件:{currentFileName}"); SuccessMessage("脚本文件添加成功!"); AddWaitAndRedirectScript(PageTemplateJs.GetRedirectUrl(SiteId)); } }