protected void saveinfo_Click(object sender, EventArgs e) { string configPath = Page.Server.MapPath("../xml/user_" + this.userid + ".config"); XmlDocumentExtender doc = new XmlDocumentExtender(); if (System.IO.File.Exists(configPath)) { if (doc.SelectSingleNode("/UserConfig/ShowInfo") == null) { XmlNode userconfig = doc.CreateElement("UserConfig"); doc.AppendChild(userconfig); XmlNode showinfo = doc.CreateElement("ShowInfo"); showinfo.InnerText = showhelp.SelectedValue.ToString(); userconfig.AppendChild(showinfo); } else { XmlNode showinfo = doc.SelectSingleNode("/UserConfig/ShowInfo"); showinfo.InnerText = showhelp.SelectedValue.ToString(); } } else { XmlElement userconfig = doc.CreateElement("UserConfig"); XmlElement showinfo = doc.CreateElement("ShowInfo"); showinfo.InnerText = showhelp.SelectedValue.ToString(); userconfig.AppendChild(showinfo); doc.AppendChild(userconfig); } doc.Save(configPath); this.RegisterStartupScript("PAGE", "window.location='likesetting.aspx'"); }
//public static bool DownSubMenu(int submenuid, int mainmenuid) //{ // return true; //} //public static bool DeleteSubMenu(string mainMenuTitle, string subMenuTitle) //{ // int num = FindMenuID(mainMenuTitle); // int num2 = FindMenuID(mainMenuTitle, subMenuTitle); // return num != -1 && num2 != -1 && DeleteSubMenu(num2, num); //} public static bool NewMenuItem(int menuparentid, string title, string link) { XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(configPath); XmlNodeList xmlNodeList = xmlDocumentExtender.SelectNodes("/dataset/submain"); foreach (XmlNode xmlNode in xmlNodeList) { if (xmlNode["link"].InnerText == link) { return(false); } } XmlElement xmlElement = xmlDocumentExtender.CreateElement("submain"); XmlElement xmlElement2 = xmlDocumentExtender.CreateElement("menuparentid"); xmlElement2.InnerText = menuparentid.ToString(); xmlElement.AppendChild(xmlElement2); xmlElement2 = xmlDocumentExtender.CreateElement("menutitle"); xmlElement2.InnerText = title; xmlElement.AppendChild(xmlElement2); xmlElement2 = xmlDocumentExtender.CreateElement("link"); xmlElement2.InnerText = link; xmlElement.AppendChild(xmlElement2); xmlElement2 = xmlDocumentExtender.CreateElement("frameid"); xmlElement2.InnerText = "main"; xmlElement.AppendChild(xmlElement2); xmlDocumentExtender.SelectSingleNode("/dataset").AppendChild(xmlElement); xmlDocumentExtender.Save(configPath); return(true); }
private void addrota_Click(Object sender, EventArgs e) { #region 插入聚合页图版轮换广告 if ((rotaimg.Text.Trim() != "") && (url.Text.Trim() != "") && (titlecontent.Text.Trim() != "")) { if ((!Utils.IsURL(rotaimg.Text.Trim()) || (!Utils.IsURL(url.Text.Trim())))) { base.RegisterStartupScript("", "<script>alert('图片路径或点击链接可能是非法URL');</script>"); BindData(); ResetForm(); return; } XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); int lastRotatepicid = 0; if (doc.SelectSingleNode(targetNode) != null) { if (doc.SelectSingleNode(targetNode).InnerText != "") { lastRotatepicid = int.Parse(doc.SelectSingleNode(targetNode).LastChild["rotatepicid"].InnerText); } } lastRotatepicid++; XmlElement rotatepicNode = doc.CreateElement(nodeName); doc.AppendChildElementByNameValue(ref rotatepicNode, "rotatepicid", lastRotatepicid.ToString()); doc.AppendChildElementByNameValue(ref rotatepicNode, "pagetype", "1"); doc.AppendChildElementByNameValue(ref rotatepicNode, "img", rotaimg.Text.Trim()); doc.AppendChildElementByNameValue(ref rotatepicNode, "url", url.Text.Trim()); doc.AppendChildElementByNameValue(ref rotatepicNode, "titlecontent", titlecontent.Text.Trim()); doc.CreateNode(targetNode).AppendChild(rotatepicNode); doc.Save(configPath); AggregationFacade.BaseAggregation.ClearAllDataBind(); AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "添加聚合页图版轮换广告", "添加聚合页图版轮换广告,名称为: " + titlecontent.Text.Trim()); try { BindData(); Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/ForumLinkList"); ResetForm(); base.RegisterStartupScript("PAGE", "window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';"); return; } catch { base.RegisterStartupScript("", "<script>alert('无法更新XML文件');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>"); return; } } else { base.RegisterStartupScript("", "<script>alert('图片或链接地址以及标题不能为空.');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>"); return; } #endregion }
private void Btn_SaveInfo_Click(object sender, EventArgs e) { #region 保存自动提取数据 XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); int rowid = 0; XmlNode topiclist = doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Website_forumrecomendtopiclist"); foreach (object o in DataGrid1.GetKeyIDArray()) { string fid = o.ToString(); string tid = DataGrid1.GetControlValue(rowid, "tid"); string title = DataGrid1.GetControlValue(rowid, "title"); string img = DataGrid1.GetControlValue(rowid, "img"); XmlElement topicNode = doc.CreateElement("Website_forumrecomendtopic"); doc.AppendChildElementByNameValue(ref topicNode, "fid", fid); doc.AppendChildElementByNameValue(ref topicNode, "tid", tid); doc.AppendChildElementByNameValue(ref topicNode, "img", img); doc.AppendChildElementByNameValue(ref topicNode, "title", title); topiclist.AppendChild(topicNode); rowid++; } /* * XmlNode fidlist = doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Website_forumrecomend/fidlist"); * fidlist.InnerText = DNTRequest.GetString("rst");*/ doc.Save(configPath); Response.Redirect("aggregation_recommendtopic.aspx"); #endregion }
/// <summary> /// 保存主题显示 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SaveTopicDisplay_Click(object sender, EventArgs e) { #region 保存主题显示 //if (!Utils.IsNumeric(topnumber.Text)) //{ // base.RegisterStartupScript("", "<script>alert('显示主题条数必须为数字!');</script>"); // return; //} //if (Convert.ToInt32(topnumber.Text) <= 0) //{ // base.RegisterStartupScript("", "<script>alert('显示主题条数至少是1条!');</script>"); // return; //} XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationpage/Website/Forum/Bbs"); //doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum"); if (doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Forum") == null) { doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum"); } XmlElement BBS = doc.CreateElement("Bbs"); doc.AppendChildElementByNameValue(ref BBS, "Topnumber", topnumber.Text, false); doc.AppendChildElementByNameValue(ref BBS, "Showtype", showtype.SelectedValue, false); doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Forum").AppendChild(BBS); doc.Save(configPath); AggregationConfig.ResetConfig(); AggregationFacade.ForumAggregation.ClearAllDataBind(); #endregion }
private void Btn_SaveInfo_Click(object sender, EventArgs e) { XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(this.configPath); int num = 0; XmlNode xmlNode = xmlDocumentExtender.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Website_forumrecomendtopiclist"); foreach (object current in this.DataGrid1.GetKeyIDArray()) { string childElementValue = current.ToString(); string controlValue = this.DataGrid1.GetControlValue(num, "tid"); string controlValue2 = this.DataGrid1.GetControlValue(num, "title"); string controlValue3 = this.DataGrid1.GetControlValue(num, "img"); XmlElement newChild = xmlDocumentExtender.CreateElement("Website_forumrecomendtopic"); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "fid", childElementValue); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "tid", controlValue); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "img", controlValue3); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "title", controlValue2); xmlNode.AppendChild(newChild); num++; } xmlDocumentExtender.Save(this.configPath); base.Response.Redirect("aggregation_recommendtopic.aspx"); }
protected void SaveMyMenu_Click(object sender, EventArgs e) { #region 保存“我的”菜单 int menuid = 0; bool error = false; XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList __xmlnodelist = doc.SelectSingleNode("/menuset").ChildNodes; if ((__xmlnodelist != null) && (__xmlnodelist.Count > 0)) { doc.InitializeNode("/menuset"); } foreach (object o in DataGrid1.GetKeyIDArray()) { string menuorder = DataGrid1.GetControlValue(menuid, "menuorder"); string text = DataGrid1.GetControlValue(menuid, "text"); string href = DataGrid1.GetControlValue(menuid, "href"); string onclick = DataGrid1.GetControlValue(menuid, "onclick"); string target = DataGrid1.GetControlValue(menuid, "target"); if ((text.Trim() == "") && (href.Trim() == "")) { error = true; continue; } bool insert = false; XmlElement __newxmlnode = doc.CreateElement("menuitem"); doc.AppendChildElementByNameValue(ref __newxmlnode, "menuorder", menuorder); doc.AppendChildElementByNameValue(ref __newxmlnode, "text", text); doc.AppendChildElementByNameValue(ref __newxmlnode, "href", href); doc.AppendChildElementByNameValue(ref __newxmlnode, "onclick", onclick, true); doc.AppendChildElementByNameValue(ref __newxmlnode, "target", target); foreach (XmlNode __node in __xmlnodelist) { if (int.Parse(__node["menuorder"].InnerText) > int.Parse(menuorder)) { doc.SelectSingleNode("/menuset").InsertBefore(__newxmlnode, __node); insert = true; break; } } if (!insert) { doc.SelectSingleNode("/menuset").AppendChild(__newxmlnode); } menuid++; } doc.Save(configPath); CreateJsFile(); if (error) { base.RegisterStartupScript("", "<script>alert('链接文字和链接地址是必须输入的,如果无链接地址请输入\"#\".');window.location.href='forum_mymenumanage.aspx';</script>"); } else { base.RegisterStartupScript("", "<script>window.location.href='forum_mymenumanage.aspx';</script>"); } #endregion }
protected void SaveMyMenu_Click(object sender, EventArgs e) { int num = 0; bool flag = false; XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(this.configPath); XmlNodeList childNodes = xmlDocumentExtender.SelectSingleNode("/menuset").ChildNodes; if (childNodes != null && childNodes.Count > 0) { xmlDocumentExtender.InitializeNode("/menuset"); } foreach (object arg_5D_0 in this.DataGrid1.GetKeyIDArray()) { string controlValue = this.DataGrid1.GetControlValue(num, "menuorder"); string controlValue2 = this.DataGrid1.GetControlValue(num, "text"); string controlValue3 = this.DataGrid1.GetControlValue(num, "href"); string controlValue4 = this.DataGrid1.GetControlValue(num, "onclick"); string controlValue5 = this.DataGrid1.GetControlValue(num, "target"); if (String.IsNullOrEmpty(controlValue2.Trim()) && String.IsNullOrEmpty(controlValue3.Trim())) { flag = true; } else { bool flag2 = false; XmlElement newChild = xmlDocumentExtender.CreateElement("menuitem"); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "menuorder", controlValue); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "text", controlValue2); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "href", controlValue3); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "onclick", controlValue4, true); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "target", controlValue5); foreach (XmlNode xmlNode in childNodes) { if (int.Parse(xmlNode["menuorder"].InnerText) > int.Parse(controlValue)) { xmlDocumentExtender.SelectSingleNode("/menuset").InsertBefore(newChild, xmlNode); flag2 = true; break; } } if (!flag2) { xmlDocumentExtender.SelectSingleNode("/menuset").AppendChild(newChild); } num++; } } xmlDocumentExtender.Save(this.configPath); this.CreateJsFile(); if (flag) { base.RegisterStartupScript("", "<script>alert('链接文字和链接地址是必须输入的,如果无链接地址请输入\"#\".');window.location.href='forum_mymenumanage.aspx';</script>"); return; } base.RegisterStartupScript("", "<script>window.location.href='forum_mymenumanage.aspx';</script>"); }
public static int NewMainMenu(string title, string defaulturl) { var xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(configPath); var xmlNodeList = xmlDocumentExtender.SelectNodes("/dataset/toptabmenu"); int result = xmlNodeList.Count + 1; XmlElement xmlElement = xmlDocumentExtender.CreateElement("toptabmenu"); XmlElement xmlElement2 = xmlDocumentExtender.CreateElement("id"); xmlElement2.InnerText = result.ToString(); xmlElement.AppendChild(xmlElement2); xmlElement2 = xmlDocumentExtender.CreateElement("title"); xmlElement2.InnerText = title; xmlElement.AppendChild(xmlElement2); xmlElement2 = xmlDocumentExtender.CreateElement("mainmenulist"); xmlElement2.InnerText = ""; xmlElement.AppendChild(xmlElement2); xmlElement2 = xmlDocumentExtender.CreateElement("mainmenuidlist"); xmlElement2.InnerText = ""; xmlElement.AppendChild(xmlElement2); xmlElement2 = xmlDocumentExtender.CreateElement("defaulturl"); xmlElement2.InnerText = defaulturl; xmlElement.AppendChild(xmlElement2); xmlElement2 = xmlDocumentExtender.CreateElement("system"); xmlElement2.InnerText = "0"; xmlElement.AppendChild(xmlElement2); xmlDocumentExtender.SelectSingleNode("/dataset").AppendChild(xmlElement); xmlDocumentExtender.Save(configPath); return(result); }
private void SaveRotatepic_Click(object sender, EventArgs e) { int num = 0; bool flag = false; var doc = new XmlDocumentExtender(); doc.Load(this.configPath); var childNodes = doc.SelectSingleNode(this.targetNode).ChildNodes; if (childNodes != null && childNodes.Count > 0) { doc.InitializeNode(this.targetNode); } foreach (object arg_5F_0 in this.DataGrid1.GetKeyIDArray()) { string controlValue = this.DataGrid1.GetControlValue(num, "rotatepicid"); string controlValue2 = this.DataGrid1.GetControlValue(num, "img"); string controlValue3 = this.DataGrid1.GetControlValue(num, "url"); string text = this.DataGrid1.GetControlValue(num, "titlecontent").Trim(); if (!Utils.IsNumeric(controlValue) || !Utils.IsURL(controlValue2) || !Utils.IsURL(controlValue3) || String.IsNullOrEmpty(text)) { flag = true; break; } bool flag2 = false; XmlElement newChild = doc.CreateElement(this.nodeName); doc.AppendChildElementByNameValue(ref newChild, "rotatepicid", controlValue); doc.AppendChildElementByNameValue(ref newChild, "pagetype", "1"); doc.AppendChildElementByNameValue(ref newChild, "img", controlValue2); doc.AppendChildElementByNameValue(ref newChild, "url", controlValue3); doc.AppendChildElementByNameValue(ref newChild, "titlecontent", text); foreach (XmlNode xmlNode in childNodes) { if (int.Parse(xmlNode["rotatepicid"].InnerText) > int.Parse(controlValue)) { doc.SelectSingleNode(this.targetNode).InsertBefore(newChild, xmlNode); flag2 = true; break; } } if (!flag2) { doc.SelectSingleNode(this.targetNode).AppendChild(newChild); } num++; } AggregationFacade.BaseAggregation.ClearAllDataBind(); if (!flag) { SiteUrls.Current = null; AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "聚合页面论坛广告编辑", ""); doc.Save(this.configPath); base.RegisterStartupScript("PAGE", "window.location.href='aggregation_rotatepic.aspx?pagename=" + Request["pagename"] + "';"); return; } base.RegisterStartupScript("", "<script>alert('某行序号、图片路径或点击链接可能是非法URL或说明文字为空,不能进行更新.');window.location.href='aggregation_rotatepic.aspx?pagename=" + Request["pagename"] + "';</script>"); }
private void AddNewRec_Click(object sender, EventArgs e) { #region 添加附件分类 if (typename.Text == "") { base.RegisterStartupScript("", "<script>alert('附件分类名称不能为空!');window.location.href='forum_attchemnttypes.aspx';</script>"); return; } XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(Server.MapPath(BaseConfigs.GetForumPath + "config/myattachment.config")); if (DNTRequest.GetString("atttypeid") == "") //增加附件分类 { XmlNode attachtypes = doc.SelectSingleNode("/MyAttachmentsTypeConfigInfo/attachtypes"); XmlElement attachtype = doc.CreateElement("AttachmentType"); XmlElement node = doc.CreateElement("TypeId"); int maxTypeid = GetMaxTypeid(); node.InnerText = (++maxTypeid).ToString(); attachtype.AppendChild(node); node = doc.CreateElement("TypeName"); node.InnerText = typename.Text; attachtype.AppendChild(node); node = doc.CreateElement("ExtName"); node.InnerText = GetAttTypeList(); attachtype.AppendChild(node); attachtypes.AppendChild(attachtype); } else { XmlNodeList xnl = doc.SelectNodes("/MyAttachmentsTypeConfigInfo/attachtypes/AttachmentType"); foreach (XmlNode xn in xnl) { if (xn["TypeId"].InnerText == DNTRequest.GetString("atttypeid")) { xn["TypeName"].InnerText = typename.Text; xn["ExtName"].InnerText = GetAttTypeList(); } } } doc.Save(Server.MapPath(BaseConfigs.GetForumPath + "config/myattachment.config")); UpdateAttchmentTypes(); base.RegisterStartupScript("", "<script>window.location.href='forum_attchemnttypes.aspx';</script>"); #endregion }
private void savetopic_Click(object sender, EventArgs e) { #region 保存相册 string aid = DNTRequest.GetString("aid"); string aidlist = Utils.ClearLastChar(recommendalbum.Value); string dataNode = ""; string indexNode = ""; string pagename = DNTRequest.GetString("pagename").ToLower(); if (pagename == "albumindex") { dataNode = "/Aggregationinfo/Aggregationdata/Albumindexaggregationdata/Albumindex_albumlist"; indexNode = "/Aggregationinfo/Aggregationpage/Albumindex/Albumindex_albumlist"; } else if (pagename == "website") { dataNode = "/Aggregationinfo/Aggregationdata/Websiteaggregationdata/Website_albumlist"; indexNode = "/Aggregationinfo/Aggregationpage/Website/Website_albumlist"; } else { dataNode = "/Aggregationinfo/Aggregationdata/Spaceindexaggregationdata/Spaceindex_albumlist"; indexNode = "/Aggregationinfo/Aggregationpage/Spaceindex/Spaceindex_albumlist"; } if (aidlist == "") { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); doc.RemoveNodeAndChildNode(dataNode); doc.RemoveNodeAndChildNode(indexNode); doc.Save(configPath); Response.Redirect("aggregation_commendalbums.aspx?pagename=" + DNTRequest.GetString("pagename")); return; } else { DataTable dt = DbProvider.GetInstance().GetAlbumLitByAlbumidList(aidlist); XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNode data_albumslistnode = doc.InitializeNode(dataNode); XmlNode index_albumslistnode = doc.InitializeNode(indexNode); foreach (DataRow dr in dt.Rows) { XmlElement album = doc.CreateElement("Album"); doc.AppendChildElementByDataRow(ref album, dt.Columns, dr, "description"); data_albumslistnode.AppendChild(album); if (("," + aid + ",").IndexOf("," + dr["albumid"].ToString() + ",") >= 0) { index_albumslistnode.AppendChild(album.Clone()); } } doc.Save(configPath); AggregationFacade.BaseAggregation.ClearAllDataBind(); Response.Redirect("aggregation_commendalbums.aspx?pagename=" + DNTRequest.GetString("pagename")); } #endregion }
/// <summary> /// 增加子菜单 /// </summary> /// <param name="mainmenuid">主菜单ID</param> /// <param name="menutitle">子菜单标题</param> /// <returns>新建子菜单ID</returns> public static int NewSubMenu(int mainmenuid, string menutitle) { int newid = 1; int newmenuid = 100; XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList submains = doc.SelectNodes("/dataset/mainmenu"); newid += int.Parse(submains.Item(submains.Count - 1)["id"].InnerText); newmenuid += int.Parse(submains.Item(submains.Count - 1)["menuid"].InnerText); XmlElement mainmenu = doc.CreateElement("mainmenu"); XmlElement node = doc.CreateElement("id"); node.InnerText = newid.ToString(); mainmenu.AppendChild(node); node = doc.CreateElement("menuid"); node.InnerText = newmenuid.ToString(); mainmenu.AppendChild(node); node = doc.CreateElement("menutitle"); node.InnerText = menutitle; mainmenu.AppendChild(node); doc.SelectSingleNode("/dataset").AppendChild(mainmenu); XmlNodeList mainMenus = doc.SelectNodes("/dataset/toptabmenu"); foreach (XmlNode menuItem in mainMenus) //查找主菜单信息 { if (menuItem["id"].InnerText == mainmenuid.ToString()) { menuItem["mainmenulist"].InnerText += "," + newid; menuItem["mainmenuidlist"].InnerText += "," + newmenuid; menuItem["mainmenulist"].InnerText = menuItem["mainmenulist"].InnerText.TrimStart(','); menuItem["mainmenuidlist"].InnerText = menuItem["mainmenuidlist"].InnerText.TrimStart(','); break; } } doc.Save(configPath); return(newmenuid); }
/// <summary> /// 保存信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveTopic_Click(object sender, EventArgs e) { #region 保存信息 string tidlist = DNTRequest.GetString("forumtopicstatus"); //当未选择主题时,则清除所有选择 if (tidlist == "") { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationdata/Websiteaggregationdata/Topiclist"); doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationpage/Website/Forum/Topiclist"); doc.Save(configPath); Response.Redirect("aggregation_editforumaggset.aspx"); return; } else { //得到所选择帖子信息 DataTable dt = DatabaseProvider.GetInstance().GetTopicListByTidlist(tablelist.SelectedValue, tidlist); XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); //清除以前选择 XmlNode topiclistnode = doc.InitializeNode("/Aggregationinfo/Aggregationdata/Websiteaggregationdata/Topiclist"); XmlNode websitetopiclistnode = doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum/Topiclist"); tidlist = DNTRequest.GetString("tid"); foreach (DataRow dr in dt.Rows) { //创建Topic节点 XmlElement topic = doc.CreateElement("Topic"); doc.AppendChildElementByDataRow(ref topic, dt.Columns, dr, "tid,message"); doc.AppendChildElementByNameValue(ref topic, "topicid", dr["tid"].ToString()); string tempubbstr = UBB.ClearUBB(dr["message"].ToString()); if (tempubbstr.Length > 200) { tempubbstr = tempubbstr.Substring(0, 200) + "..."; } doc.AppendChildElementByNameValue(ref topic, "shortdescription", tempubbstr, true); doc.AppendChildElementByNameValue(ref topic, "fulldescription", UBB.ClearUBB(dr["message"].ToString()), true); topiclistnode.AppendChild(topic); if (("," + tidlist + ",").IndexOf("," + dr["tid"].ToString() + ",") >= 0) { websitetopiclistnode.AppendChild(topic.Clone()); } } doc.Save(configPath); AggregationFacade.BaseAggregation.ClearAllDataBind(); Response.Redirect("aggregation_editforumaggset.aspx"); } #endregion }
private void AddNewRec_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(this.typename.Text)) { base.RegisterStartupScript("", "<script>alert('附件分类名称不能为空!');window.location.href='forum_attchemnttypes.aspx';</script>"); return; } XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(base.Server.MapPath(BaseConfigs.GetForumPath + "config/myattachment.config")); if (String.IsNullOrEmpty(Request["atttypeid"])) { XmlNode xmlNode = xmlDocumentExtender.SelectSingleNode("/MyAttachmentsTypeConfigInfo/attachtypes"); XmlElement xmlElement = xmlDocumentExtender.CreateElement("AttachmentType"); XmlElement xmlElement2 = xmlDocumentExtender.CreateElement("TypeId"); int maxTypeid = this.GetMaxTypeid(); xmlElement2.InnerText = (maxTypeid + 1).ToString(); xmlElement.AppendChild(xmlElement2); xmlElement2 = xmlDocumentExtender.CreateElement("TypeName"); xmlElement2.InnerText = this.typename.Text; xmlElement.AppendChild(xmlElement2); xmlElement2 = xmlDocumentExtender.CreateElement("ExtName"); xmlElement2.InnerText = this.GetAttTypeList(); xmlElement.AppendChild(xmlElement2); xmlNode.AppendChild(xmlElement); } else { XmlNodeList xmlNodeList = xmlDocumentExtender.SelectNodes("/MyAttachmentsTypeConfigInfo/attachtypes/AttachmentType"); foreach (XmlNode xmlNode2 in xmlNodeList) { if (xmlNode2["TypeId"].InnerText == Request["atttypeid"]) { xmlNode2["TypeName"].InnerText = this.typename.Text; xmlNode2["ExtName"].InnerText = this.GetAttTypeList(); } } } xmlDocumentExtender.Save(base.Server.MapPath(BaseConfigs.GetForumPath + "config/myattachment.config")); this.UpdateAttchmentTypes(); base.RegisterStartupScript("", "<script>window.location.href='forum_attchemnttypes.aspx';</script>"); }
//public static bool EditSubMenu(string mainMenuTitle, string oldSubMenuTitle, string newSubMenuTitle) //{ // int num = FindMenuID(mainMenuTitle, oldSubMenuTitle); // return num != -1 && EditSubMenu(num, newSubMenuTitle); //} public static int NewSubMenu(int mainmenuid, string menutitle) { int num = 1; int num2 = 100; XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(configPath); XmlNodeList xmlNodeList = xmlDocumentExtender.SelectNodes("/dataset/mainmenu"); num += int.Parse(xmlNodeList.Item(xmlNodeList.Count - 1)["id"].InnerText); num2 += int.Parse(xmlNodeList.Item(xmlNodeList.Count - 1)["menuid"].InnerText); XmlElement xmlElement = xmlDocumentExtender.CreateElement("mainmenu"); XmlElement xmlElement2 = xmlDocumentExtender.CreateElement("id"); xmlElement2.InnerText = num.ToString(); xmlElement.AppendChild(xmlElement2); xmlElement2 = xmlDocumentExtender.CreateElement("menuid"); xmlElement2.InnerText = num2.ToString(); xmlElement.AppendChild(xmlElement2); xmlElement2 = xmlDocumentExtender.CreateElement("menutitle"); xmlElement2.InnerText = menutitle; xmlElement.AppendChild(xmlElement2); xmlDocumentExtender.SelectSingleNode("/dataset").AppendChild(xmlElement); XmlNodeList xmlNodeList2 = xmlDocumentExtender.SelectNodes("/dataset/toptabmenu"); foreach (XmlNode xmlNode in xmlNodeList2) { if (xmlNode["id"].InnerText == mainmenuid.ToString()) { XmlElement expr_14C = xmlNode["mainmenulist"]; expr_14C.InnerText = expr_14C.InnerText + "," + num; XmlElement expr_173 = xmlNode["mainmenuidlist"]; expr_173.InnerText = expr_173.InnerText + "," + num2; xmlNode["mainmenulist"].InnerText = xmlNode["mainmenulist"].InnerText.TrimStart(','); xmlNode["mainmenuidlist"].InnerText = xmlNode["mainmenuidlist"].InnerText.TrimStart(','); break; } } xmlDocumentExtender.Save(configPath); return(num2); }
protected void saveinfo_Click(object sender, EventArgs e) { string configPath = Page.Server.MapPath("../xml/user_" + this.userid + ".config"); if (File.Exists(configPath)) { File.Delete(configPath); } XmlDocumentExtender doc = new XmlDocumentExtender(); XmlElement userconfig = doc.CreateElement("UserConfig"); XmlElement showinfo = doc.CreateElement("ShowInfo"); showinfo.InnerText = showhelp.SelectedValue.ToString(); userconfig.AppendChild(showinfo); doc.AppendChild(userconfig); XmlElement showupgradenode = doc.CreateElement("ShowUpgrade"); showupgradenode.InnerText = showupgrade.SelectedValue.ToString(); userconfig.AppendChild(showupgradenode); doc.Save(configPath); this.RegisterStartupScript("PAGE", "window.location='likesetting.aspx'"); }
protected void saveinfo_Click(object sender, EventArgs e) { string text = this.Page.Server.MapPath("../xml/user_" + this.userid + ".config"); if (File.Exists(text)) { File.Delete(text); } XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); XmlElement xmlElement = xmlDocumentExtender.CreateElement("UserConfig"); XmlElement xmlElement2 = xmlDocumentExtender.CreateElement("ShowInfo"); xmlElement2.InnerText = this.showhelp.SelectedValue.ToString(); xmlElement.AppendChild(xmlElement2); xmlDocumentExtender.AppendChild(xmlElement); XmlElement xmlElement3 = xmlDocumentExtender.CreateElement("ShowUpgrade"); xmlElement3.InnerText = this.showupgrade.SelectedValue.ToString(); xmlElement.AppendChild(xmlElement3); xmlDocumentExtender.Save(text); base.RegisterStartupScript("PAGE", "window.location='likesetting.aspx'"); }
protected void Page_Load(object sender, EventArgs e) { //加入快捷操作菜单 resultmessage = "<img src='../images/existmenu.gif' style='vertical-align:middle'/> 已经收藏"; string configPath = Page.Server.MapPath("xml/navmenu.config"); string title = ""; string menuparentid = ""; string url = DNTRequest.GetString("url").ToLower(); XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); //读到快捷操作菜单 XmlNodeList shortcuts = doc.SelectNodes("/dataset/shortcut"); foreach (XmlNode singleshortcut in shortcuts) { //如果当前链接在快捷菜单内,则返回 if (singleshortcut.SelectSingleNode("link").InnerText == url.ToLower().Trim()) { return; } } XmlNodeList submains = doc.SelectNodes("/dataset/submain"); XmlNodeInnerTextVisitor submainsvisitor = new XmlNodeInnerTextVisitor(); foreach (XmlNode submain in submains) { submainsvisitor.SetNode(submain); if (submainsvisitor["link"].ToLower() == url) { title = submainsvisitor["menutitle"]; menuparentid = submainsvisitor["menuparentid"]; } } string[] parm = GetParm(doc, menuparentid); XmlElement shortcut = doc.CreateElement("shortcut"); //将当前页面存入快捷操作菜单内 doc.AppendChildElementByNameValue(ref shortcut, "link", url); doc.AppendChildElementByNameValue(ref shortcut, "menutitle", title); doc.AppendChildElementByNameValue(ref shortcut, "frameid", "main"); doc.AppendChildElementByNameValue(ref shortcut, "custommenu", "true"); doc.AppendChildElementByNameValue(ref shortcut, "showmenuid", parm[0]); doc.AppendChildElementByNameValue(ref shortcut, "toptabmenuid", parm[1]); doc.AppendChildElementByNameValue(ref shortcut, "mainmenulist", parm[2]); doc.SelectSingleNode("/dataset").AppendChild(shortcut); doc.Save(configPath); //managemainmenu.CreateMenu(Utils.GetMapPath("xml/navmenu.config"), Utils.GetMapPath("framepage") + "/navmenu.js"); MenuManage.CreateMenuJson(); }
/// <summary> /// 保存主题显示 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SaveTopicDisplay_Click(object sender, EventArgs e) { #region 保存主题显示 XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); //doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationpage/Website/Forum/Bbs"); doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum"); XmlElement BBS = doc.CreateElement("Bbs"); doc.AppendChildElementByNameValue(ref BBS, "Topnumber", topnumber.Text, false); doc.AppendChildElementByNameValue(ref BBS, "Showtype", showtype.SelectedValue, false); doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Forum").AppendChild(BBS); doc.Save(configPath); #endregion }
/// <summary> /// 新建菜单项 /// </summary> /// <param name="menuparentid">父菜单ID</param> /// <param name="title">菜单标题</param> /// <param name="link">菜单链接</param> /// <returns>操作成功否</returns> public static bool NewMenuItem(int menuparentid, string title, string link) { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList submains = doc.SelectNodes("/dataset/submain"); foreach (XmlNode sub in submains) { if (sub["link"].InnerText == link) { return(false); } } XmlElement submain = doc.CreateElement("submain"); XmlElement node = doc.CreateElement("menuparentid"); node.InnerText = menuparentid.ToString(); submain.AppendChild(node); node = doc.CreateElement("menutitle"); node.InnerText = title; submain.AppendChild(node); node = doc.CreateElement("link"); node.InnerText = link; submain.AppendChild(node); node = doc.CreateElement("frameid"); node.InnerText = "main"; submain.AppendChild(node); doc.SelectSingleNode("/dataset").AppendChild(submain); doc.Save(configPath); return(true); }
private void SaveTopic_Click(object sender, EventArgs e) { #region 保存个人空间信息 string sidlist = DNTRequest.GetString("spacestatus"); if (sidlist == "") { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationdata/" + pagename + "aggregationdata/" + pagename + "_spacelist"); doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationpage/" + pagename + "/" + pagename + "_spacelist"); doc.Save(configPath); Response.Redirect("aggregation_spaceaggset.aspx"); return; } else { DataTable dt = DbProvider.GetInstance().GetSpaceLitByTidlist(sidlist); XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNode data_spacelistnode = doc.InitializeNode("/Aggregationinfo/Aggregationdata/" + pagename + "aggregationdata/" + pagename + "_spacelist"); XmlNode pagelistnode = doc.InitializeNode("/Aggregationinfo/Aggregationpage/" + pagename + "/" + pagename + "_spacelist"); sidlist = DNTRequest.GetString("sid"); foreach (DataRow dr in dt.Rows) { XmlElement space = doc.CreateElement("Space"); doc.AppendChildElementByDataRow(ref space, dt.Columns, dr, "title,avatar,description"); doc.AppendChildElementByNameValue(ref space, "title", dr["spacetitle"].ToString().Trim()); doc.AppendChildElementByNameValue(ref space, "pic", dr["avatar"].ToString().Trim()); doc.AppendChildElementByNameValue(ref space, "description", Utils.RemoveHtml(dr["description"].ToString().Trim()), true); string[] postinfo = DbProvider.GetInstance().GetSpaceLastPostInfo(int.Parse(dr["userid"].ToString())); doc.AppendChildElementByNameValue(ref space, "postid", postinfo[0]); doc.AppendChildElementByNameValue(ref space, "posttitle", postinfo[1]); data_spacelistnode.AppendChild(space); if (("," + sidlist + ",").IndexOf("," + dr["spaceid"].ToString() + ",") >= 0) { pagelistnode.AppendChild(space.Clone()); } } doc.Save(configPath); AggregationFacade.BaseAggregation.ClearAllDataBind(); Response.Redirect("aggregation_spaceaggset.aspx?pagename=" + pagename); } #endregion }
protected void Page_Load(object sender, EventArgs e) { this.resultmessage = "<img src='../images/existmenu.gif' style='vertical-align:middle'/> 已经收藏"; string mapPath = Utils.GetMapPath(BaseConfigs.GetForumPath.ToLower() + "admin/xml/navmenu.config"); string childElementValue = ""; string menuparentid = ""; string text = Request["url"].ToLower(); XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(mapPath); XmlNodeList xmlNodeList = xmlDocumentExtender.SelectNodes("/dataset/shortcut"); foreach (XmlNode xmlNode in xmlNodeList) { if (xmlNode.SelectSingleNode("link").InnerText == text.ToLower().Trim()) { return; } } XmlNodeList xmlNodeList2 = xmlDocumentExtender.SelectNodes("/dataset/submain"); XmlNodeInnerTextVisitor xmlNodeInnerTextVisitor = new XmlNodeInnerTextVisitor(); foreach (XmlNode node in xmlNodeList2) { xmlNodeInnerTextVisitor.SetNode(node); if (xmlNodeInnerTextVisitor["link"].ToLower() == text) { childElementValue = xmlNodeInnerTextVisitor["menutitle"]; menuparentid = xmlNodeInnerTextVisitor["menuparentid"]; } } string[] parm = this.GetParm(xmlDocumentExtender, menuparentid); XmlElement newChild = xmlDocumentExtender.CreateElement("shortcut"); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "link", text); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "menutitle", childElementValue); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "frameid", "main"); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "custommenu", "true"); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "showmenuid", parm[0]); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "toptabmenuid", parm[1]); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "mainmenulist", parm[2]); xmlDocumentExtender.SelectSingleNode("/dataset").AppendChild(newChild); xmlDocumentExtender.Save(mapPath); MenuManage.CreateMenuJson(); }
private void addmenu_Click(Object sender, EventArgs e) { #region 插入菜单 if ((atext.Text.Trim() != "") && (ahref.Text.Trim() != "")) { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); int lastmenuorder = 0; if (doc.SelectSingleNode("/menuset").ChildNodes.Count != 0) { lastmenuorder = int.Parse(doc.SelectSingleNode("/menuset").LastChild["menuorder"].InnerText); } lastmenuorder++; XmlElement menunode = doc.CreateElement("menuitem"); doc.AppendChildElementByNameValue(ref menunode, "menuorder", lastmenuorder.ToString()); doc.AppendChildElementByNameValue(ref menunode, "text", atext.Text.Trim()); doc.AppendChildElementByNameValue(ref menunode, "href", ahref.Text.Trim()); doc.AppendChildElementByNameValue(ref menunode, "onclick", aonclick.Text.Trim(), true); doc.AppendChildElementByNameValue(ref menunode, "target", atarget.Text.Trim()); doc.CreateNode("/menuset").AppendChild(menunode); doc.Save(configPath); CreateJsFile(); try { BindData(); ResetForm(); base.RegisterStartupScript("PAGE", "window.location.href='forum_mymenumanage.aspx';"); return; } catch { base.RegisterStartupScript("", "<script>alert('无法更新XML文件');window.location.href='forum_mymenumanage.aspx';</script>"); return; } } else { base.RegisterStartupScript("", "<script>alert('链接文字和链接地址是必须输入的,如果无链接地址请输入\"#\".');window.location.href='forum_mymenumanage.aspx';</script>"); return; } #endregion }
private void addrota_Click(object sender, EventArgs e) { if (this.rotaimg.Text.Trim() != "" && this.url.Text.Trim() != "" && this.titlecontent.Text.Trim() != "") { if (!Utils.IsURL(this.rotaimg.Text.Trim()) || !Utils.IsURL(this.url.Text.Trim())) { base.RegisterStartupScript("", "<script>alert('图片路径或点击链接可能是非法URL');</script>"); this.BindData(); this.ResetForm(); return; } XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(this.configPath); int num = 0; if (xmlDocumentExtender.SelectSingleNode(this.targetNode) != null && xmlDocumentExtender.SelectSingleNode(this.targetNode).InnerText != "") { num = int.Parse(xmlDocumentExtender.SelectSingleNode(this.targetNode).LastChild["rotatepicid"].InnerText); } num++; XmlElement newChild = xmlDocumentExtender.CreateElement(this.nodeName); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "rotatepicid", num.ToString()); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "pagetype", "1"); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "img", this.rotaimg.Text.Trim()); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "url", this.url.Text.Trim()); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "titlecontent", this.titlecontent.Text.Trim()); xmlDocumentExtender.CreateNode(this.targetNode).AppendChild(newChild); xmlDocumentExtender.Save(this.configPath); AggregationFacade.BaseAggregation.ClearAllDataBind(); AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "添加聚合页图版轮换广告", "添加聚合页图版轮换广告,名称为: " + this.titlecontent.Text.Trim()); try { this.BindData(); XCache.Remove(CacheKeys.FORUM_FORUM_LINK_LIST); this.ResetForm(); base.RegisterStartupScript("PAGE", "window.location.href='aggregation_rotatepic.aspx?pagename=" + Request["pagename"] + "';"); return; } catch { base.RegisterStartupScript("", "<script>alert('无法更新XML文件');window.location.href='aggregation_rotatepic.aspx?pagename=" + Request["pagename"] + "';</script>"); return; } } base.RegisterStartupScript("", "<script>alert('图片或链接地址以及标题不能为空.');window.location.href='aggregation_rotatepic.aspx?pagename=" + Request["pagename"] + "';</script>"); }
protected void SaveTopicDisplay_Click(object sender, EventArgs e) { XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(this.configPath); xmlDocumentExtender.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationpage/Website/Forum/Bbs"); if (xmlDocumentExtender.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Forum") == null) { xmlDocumentExtender.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum"); } XmlElement newChild = xmlDocumentExtender.CreateElement("Bbs"); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "Topnumber", this.topnumber.Text, false); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "Showtype", this.showtype.SelectedValue, false); xmlDocumentExtender.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Forum").AppendChild(newChild); xmlDocumentExtender.Save(this.configPath); //AggregationConfig.ResetConfig(); AggregationConfigInfo.Current = null; AggregationFacade.ForumAggregation.ClearAllDataBind(); }
private void SaveTopic_Click(object sender, EventArgs e) { #region 装载修改信息 string pid = DNTRequest.GetString("pid"); string pidlist = Utils.ClearLastChar(poststatus.Value); if (pidlist == "") { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationdata/" + pagename + "aggregationdata/" + pagename + "_spacearticlelist"); doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationpage/" + pagename + "/" + pagename + "_spacearticlelist"); doc.Save(configPath); Response.Redirect("aggregation_postaggset.aspx"); return; } else { DataTable dt = DbProvider.GetInstance().GetSpacepostLitByTidlist(pidlist); XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNode data_spacearticlelistnode = doc.InitializeNode("/Aggregationinfo/Aggregationdata/" + pagename + "aggregationdata/" + pagename + "_spacearticlelist"); XmlNode pagearticlelistnode = doc.InitializeNode("/Aggregationinfo/Aggregationpage/" + pagename + "/" + pagename + "_spacearticlelist"); foreach (DataRow dr in dt.Rows) { XmlElement article = doc.CreateElement("Article"); doc.AppendChildElementByDataRow(ref article, dt.Columns, dr); data_spacearticlelistnode.AppendChild(article); if (("," + pid + ",").IndexOf("," + dr["postid"].ToString() + ",") >= 0) { pagearticlelistnode.AppendChild(article.Clone()); } } doc.Save(configPath); AggregationFacade.BaseAggregation.ClearAllDataBind(); Response.Redirect("aggregation_postaggset.aspx?pagename=" + pagename); } #endregion }
private void addmenu_Click(object sender, EventArgs e) { if (!this.atext.Text.IsNullOrEmpty() && !this.ahref.Text.IsNullOrEmpty()) { XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(this.configPath); int num = 0; if (xmlDocumentExtender.SelectSingleNode("/menuset").ChildNodes.Count != 0) { num = int.Parse(xmlDocumentExtender.SelectSingleNode("/menuset").LastChild["menuorder"].InnerText); } num++; XmlElement newChild = xmlDocumentExtender.CreateElement("menuitem"); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "menuorder", num.ToString()); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "text", this.atext.Text.Trim()); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "href", this.ahref.Text.Trim()); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "onclick", this.aonclick.Text.Trim(), true); xmlDocumentExtender.AppendChildElementByNameValue(ref newChild, "target", this.atarget.Text.Trim()); xmlDocumentExtender.CreateNode("/menuset").AppendChild(newChild); xmlDocumentExtender.Save(this.configPath); this.CreateJsFile(); try { this.BindData(); this.ResetForm(); base.RegisterStartupScript("PAGE", "window.location.href='forum_mymenumanage.aspx';"); return; } catch { base.RegisterStartupScript("", "<script>alert('无法更新XML文件');window.location.href='forum_mymenumanage.aspx';</script>"); return; } } base.RegisterStartupScript("", "<script>alert('链接文字和链接地址是必须输入的,如果无链接地址请输入\"#\".');window.location.href='forum_mymenumanage.aspx';</script>"); }
/// <summary> /// 增加主菜单 /// </summary> /// <param name="title">主菜单标题</param> /// <param name="defaulturl">主菜单默认展开的页面</param> /// <returns>新主菜单项ID</returns> public static int NewMainMenu(string title, string defaulturl) { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu"); int newMenuId = mainmenus.Count + 1; XmlElement newMainMenuItem = doc.CreateElement("toptabmenu"); XmlElement node = doc.CreateElement("id"); node.InnerText = newMenuId.ToString(); newMainMenuItem.AppendChild(node); node = doc.CreateElement("title"); node.InnerText = title; newMainMenuItem.AppendChild(node); node = doc.CreateElement("mainmenulist"); node.InnerText = ""; newMainMenuItem.AppendChild(node); node = doc.CreateElement("mainmenuidlist"); node.InnerText = ""; newMainMenuItem.AppendChild(node); node = doc.CreateElement("defaulturl"); node.InnerText = defaulturl; newMainMenuItem.AppendChild(node); node = doc.CreateElement("system"); node.InnerText = "0"; newMainMenuItem.AppendChild(node); doc.SelectSingleNode("/dataset").AppendChild(newMainMenuItem); doc.Save(configPath); return(newMenuId); }
private void savetopic_Click(object sender, EventArgs e) { #region 绑定自动推荐相册修改 //验证值是否正确 if (!ValidateValue(focusphotodays.Text)) { return; } if (!ValidateValue(focusphotocount.Text)) { return; } if (!ValidateValue(focusalbumdays.Text)) { return; } if (!ValidateValue(focusalbumcount.Text)) { return; } if (!ValidateValue(weekhot.Text)) { return; } string strfocusphotoshowtype = focusphotoshowtype.SelectedIndex.ToString(); string strfocusphotodays = focusphotodays.Text; string strfocusphotocount = focusphotocount.Text; string strfocusalbumshowtype = recommendalbumtype.SelectedIndex.ToString(); string strfocusalbumdays = focusalbumdays.Text; string strfocusalbumcount = focusalbumcount.Text; string strweekhot = weekhot.Text; //保存信息 XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationpage/Albumindex/Albumconfig"); XmlNode albumconfig = doc.InitializeNode("/Aggregationinfo/Aggregationpage/Albumindex/Albumconfig"); XmlElement node = doc.CreateElement("Focusphotoshowtype"); node.InnerText = strfocusphotoshowtype; albumconfig.AppendChild(node); node = doc.CreateElement("Focusphotodays"); node.InnerText = strfocusphotodays; albumconfig.AppendChild(node); node = doc.CreateElement("Focusphotocount"); node.InnerText = strfocusphotocount; albumconfig.AppendChild(node); node = doc.CreateElement("Focusalbumshowtype"); node.InnerText = strfocusalbumshowtype; albumconfig.AppendChild(node); node = doc.CreateElement("Focusalbumdays"); node.InnerText = strfocusalbumdays; albumconfig.AppendChild(node); node = doc.CreateElement("Focusalbumcount"); node.InnerText = strfocusalbumcount; albumconfig.AppendChild(node); node = doc.CreateElement("Weekhot"); node.InnerText = strweekhot; albumconfig.AppendChild(node); doc.Save(configPath); AggregationFacade.BaseAggregation.ClearAllDataBind(); Response.Redirect("aggregation_autoalbums.aspx"); #endregion }