public string GetEditUrl(string tp) { string url = ""; Template t = TemplateHelper.GetTemplate(tp + ".xml", Path.GetFileNameWithoutExtension(FileName)); if (t != null) { string fileName = We7Helper.Base64Encode(t.FileName); string path = We7Helper.Base64Encode(Path.GetFileNameWithoutExtension(FileName)); if (t.IsSubTemplate) { url = String.Format("/admin/DataControlUI/Compose.aspx?file={0}&folder={1}&templateSub=sub", fileName, path); } else if (t.TemplateType == "9") { url = String.Format("/admin/DataControlUI/Compose.aspx?file={0}&folder={1}&templateSub=master", fileName, path); } else { url = String.Format("/admin/DataControlUI/Compose.aspx?file={0}&folder={1}", fileName, path); } } return(url); }
/// <summary> /// 页面加载xml数据 /// </summary> void LoadAdvices() { List <AdviceReply> adviceReply = new List <AdviceReply>();//借用此对象属性便于绑定前台数据 string root = Server.MapPath("/_Data/SendEmail/"); if (Directory.Exists(root)) { DirectoryInfo dir = new DirectoryInfo(root); FileInfo[] files = dir.GetFiles("*.xml"); foreach (FileInfo file in files) { AdviceReply ar = new AdviceReply(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(file.FullName); XmlNode node = xmlDoc.SelectSingleNode("/root/infoSubject"); ar.Title = We7Helper.Base64Decode(node.InnerText); node = xmlDoc.SelectSingleNode("/root/infoBody"); ar.Content = We7Helper.Base64Decode(node.InnerText); node = xmlDoc.SelectSingleNode("/root/infoUser"); ar.UserEmail = We7Helper.Base64Decode(node.InnerText); node = xmlDoc.SelectSingleNode("/root/infoTime"); ar.CreateDate = Convert.ToDateTime(node.InnerText); node = xmlDoc.SelectSingleNode("/root/infoFormUser"); ar.FormEmail = We7Helper.Base64Decode(node.InnerText); ar.MailFile = We7Helper.Base64Encode(file.Name); adviceReply.Add(ar); } } if (adviceReply != null) { Pager.RecorderCount = adviceReply.Count; } else { Pager.RecorderCount = 0; } if (Pager.Count < 0) { Pager.PageIndex = 0; } Pager.FreshMyself(); if (Pager.Count <= 0) { DataGridView.DataSource = null; DataGridView.DataBind(); return; } DataGridView.DataSource = adviceReply.GetRange(Pager.Begin, Pager.Count); DataGridView.DataBind(); }
/// <summary> /// 未能正确发送的邮件将以XML形式转存至/_Data/SendEmail/目录下 /// </summary> /// <param name="mailMessage"></param> public void SendMailMessageToXml(MailMessage mailMessage) { try { string subject = mailMessage.Subject.ToString(); //邮件标题 string body = (string)mailMessage.Body; //邮件正文 string replyTime = DateTime.Now.ToString(); //邮件 string user = mailMessage.To[0].Address; //收件人地址 string formUser = mailMessage.From.Address; //发件人地址 if (subject != "") { string filePath = HttpContext.Current.Server.MapPath("/_Data/SendEmail/"); DateTime time = Convert.ToDateTime(replyTime); string fileName = subject + DateTime.Now.ToString(".yyyy_MM_dd_HH_mm_ss") + ".xml"; string path = Path.Combine(filePath, fileName); //检查是否XML文件存放临时路径存在,如果不存在则进行处理 if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } //检查XMLSchema文件是否存在,如果不存在则进行处理 if (!File.Exists(subject)) { XmlDocument doc = new XmlDocument(); //转换字符 subject = We7Helper.Base64Encode(subject); user = We7Helper.Base64Encode(user); body = We7Helper.Base64Encode(body); formUser = We7Helper.Base64Encode(formUser); string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n" + "<root><infoSubject>" + subject + "</infoSubject><infoUser>" + user + "</infoUser><infoFormUser>" + formUser + "</infoFormUser><infoBody>" + body + "</infoBody><infoTime>" + replyTime + "</infoTime></root>"; doc.LoadXml(xml); doc.Save(path); } } } catch (Exception) { } }
/// <summary> /// 保存模板 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SaveButton_Click(object sender, EventArgs e) { try { SaveTemplateInfo(); if (CDHelper.Config.SiteBuildState == "run") //处于运行状态,启用副本 { SaveTemplate("~" + CurrentTemplate.SkinFolder, CurrentTemplate.EditFileFullPath); //保相模版到副本 } else { SaveTemplate(CurrentTemplate.SkinFolder, Server.MapPath(CurrentTemplate.FilePath));//保存到正本 } OriginalInput = TemplateContentTextBox.Value; if (BindConfig.Enough) { TemplateHelper.SaveTemplateBind(BindConfig, CurrentTemplate.SkinFolder, CurrentTemplate.FileName); } //记录日志 string content = string.Format("编辑{0}的内容", NameLabel.Text.Replace("编辑" + CurrentTemplate.Name + "", "")); AddLog("编辑" + CurrentTemplate.Name + "内容", content); if (CurrentTemplate.IsNew) { string fileName = We7Helper.Base64Encode(CurrentTemplate.FileName); string path = We7Helper.Base64Encode(CurrentTemplate.SkinFolder); string url = String.Format("/admin/DataControlUI/Compose.aspx?file={0}&folder={1}&create=success", fileName, path); Response.Redirect(url, false); } else { Messages.ShowMessage("" + CurrentTemplate.FileName + "文件成功保存!" + DateTime.Now.ToLongTimeString()); } } catch (Exception ex) { Messages.ShowError("无法保存模板,错误为:" + ex.Message); } }
/// <summary> /// 错误邮件转存到_data下(*.xml) /// </summary> /// <param name="subject"></param> /// <param name="rawManage"></param> void ErrorEmail(string subject, string rawManage, string user, string replyTime, string body) { try { if (subject != "") { string filePath = HttpContext.Current.Server.MapPath("/_Data/ErrorEmail/"); DateTime time = Convert.ToDateTime(replyTime); string fileName = user + time.ToString(".yyyy_MM_dd_HH_mm") + ".xml"; string path = Path.Combine(filePath, fileName); //检查是否XML文件存放临时路径存在,如果不存在则进行处理 if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } //检查XMLSchema文件是否存在,如果不存在则进行处理 if (!File.Exists(subject)) { XmlDocument doc = new XmlDocument(); //转换字符 subject = We7Helper.Base64Encode(subject); rawManage = We7Helper.Base64Encode(rawManage); user = We7Helper.Base64Encode(user); body = We7Helper.Base64Encode(body); string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n" + "<root><infoSubject>" + subject + "</infoSubject><infoBody>" + body + "</infoBody><infoRawManage>" + rawManage + "</infoRawManage><infoUser>" + user + "</infoUser><infoTime>" + replyTime + "</infoTime></root>"; doc.LoadXml(xml); doc.Save(path); } } } catch (Exception) { } }
protected void Page_Load(object sender, EventArgs e) { if (FileName != null && FileName.Trim() != "" && File.Exists(Path.Combine(TemplateHelper.TemplateGroupPath, FileName))) { TemplateConfigLiteral.Text = LoadTemplateDictionary("/admin/DataControlUI/Compose.aspx"); VisualTemplateConfigLiteral.Text = LoadTemplateDictionary("/admin/VisualTemplate/TemplateCreate.aspx"); Control ctl = this.LoadControl("../Template/controls/TemplateGroup_File.ascx"); ContentHolder.Controls.Add(ctl); EditHyperLink.NavigateUrl = string.Format("TemplateGroupInfo.aspx?file={0}", FileName); path = string.Format("{0}/{1}", Constants.TemplateBasePath, Path.GetFileNameWithoutExtension(FileName)); NewSubHyperLink.NavigateUrl = string.Format("/admin/DataControlUI/Compose.aspx?folder={0}", We7Helper.Base64Encode(Path.GetFileNameWithoutExtension(FileName))) + "&templatesub=sub"; NewSubHyperLink.Target = "_blank"; NewMasterPageHyperLink.NavigateUrl = string.Format("/admin/DataControlUI/Compose.aspx?folder={0}", We7Helper.Base64Encode(Path.GetFileNameWithoutExtension(FileName))) + "&templatesub=master"; NewMasterPageHyperLink.Target = "_blank";; ToolbarVisible = ""; LoadSkininfo(); RefreshHyperLink.NavigateUrl = this.Page.Request.RawUrl; } else { Response.Redirect("/admin/TemplateGroups.aspx"); } }