/// <summary> /// 装载模板副本内容 /// </summary> /// <param name="tp"></param> void LoadTemplateCopy(Template tp) { string copyFile = TemplateCopies.GetThisTemplateCopy(tp, FilenameTextBox.Text); FileInfo cfi = new FileInfo(copyFile); FileInfo fi = new FileInfo(tp.FileName); if (fi.Exists && (!cfi.Exists || cfi.LastWriteTime < fi.LastWriteTime)) { TemplateCopies.MergeToTemplateCopy(tp.FileName, tp); } LoadTemplateFromFile(copyFile); }
/// <summary> /// 页面初始化 /// </summary> protected override void Initialize() { string currentTemplateGroupName = TemplateHelper.GetCurrentExistTemplateGroup(); if (string.IsNullOrEmpty(currentTemplateGroupName)) { TemplateHelper.CreateDefaultTemplateGroup(); } try { We7Helper.Assert(CurrentTemplate.FileName != null, " 非法的参数。"); if (!CurrentTemplate.IsNew) { CurrentTemplate.FromFile(Server.MapPath(String.Format("\\{0}\\{1}", Constants.TemplateBasePath, CurrentTemplate.SkinFolder)), CurrentTemplate.FileName + ".xml"); } CurrentTemplate.FilePath = TemplateHelper.GetTemplatePath(String.Format("{0}/{1}", CurrentTemplate.SkinFolder, CurrentTemplate.FileName)); FilenameTextBox.Text = CurrentTemplate.FileName; if (CurrentTemplate.IsNew) { ActionLiteral.Text = "新建"; } else { ActionLiteral.Text = "编辑"; } ActionLiteral.Text += CurrentTemplate.TemplateTypeText; NameTextbox.Text = CurrentTemplate.Name; this.Page.Title = ActionLiteral.Text + NameLabel.Text; if (CurrentTemplate.IsNew) { FilenameTextBox.Text = String.Format("{0}", CurrentTemplate.FileName); FilenameTextBox.Visible = true; } else { SummaryLabel.Text = String.Format("{0}", CurrentTemplate.FileName); FilenameTextBox.Visible = false; } string fn = Server.MapPath(CurrentTemplate.FilePath); if (CDHelper.Config.SiteBuildState == "run") //处于运行状态,启用副本 { PublishSpan.Visible = true; CurrentTemplate.EditFileFullPath = TemplateCopies.GetThisTemplateCopy(CurrentTemplate, FilenameTextBox.Text); if (File.Exists(fn) || File.Exists(CurrentTemplate.EditFileFullPath)) { LoadTemplateCopy(CurrentTemplate); } InitCopyControls(CurrentTemplate.EditFileFullPath); SummaryLabel.Text += "编辑后的内容将保存到副本中,发布后才会正式启用。"; } else { PublishSpan.Visible = false; if (File.Exists(fn)) { LoadTemplateFromFile(fn); } else { //SummaryLabel.Text = String.Format("文件将保存到{0},", CurrentTemplate.FileName); TemplateContentTextBox.Value = @"<html> <head> <title></title> </head> <body> </body> </html>"; } InitCopyControls(fn); } TemplatePathTextBox.Text = Constants.TemplateUrlPath; string path = string.Format("/{0}/{1}", Constants.TemplateBasePath, CurrentTemplate.SkinFolder); PrevewDropDownList.Visible = !CurrentTemplate.IsMasterPage; } catch (Exception ex) { Messages.ShowError(ex.Message); } }