public static void ImportPluginMenu(string menuConfigFile) { //备份菜单 BackupMenuFile(); XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(menuConfigFile); XmlNodeList menuitems = doc.SelectNodes("/pluginmenu/menuitem"); int pluginMainId = FindPluginMainMenu(); foreach (XmlNode menuitem in menuitems) { int newsubmenuid = NewSubMenu(pluginMainId, menuitem.Attributes["title"].InnerText); XmlNodeList items = menuitem.ChildNodes; foreach (XmlNode item in items) { NewMenuItem(newsubmenuid, item["title"].InnerText, item["link"].InnerText); } } CreateMenuJson(); }
private void BindEditData(string tid) { this.panel1.Visible = true; XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(this.configPath); XmlNodeList xmlNodeList = xmlDocumentExtender.SelectNodes("/Aggregationinfo/Forum/Hottopiclist/Topic"); XmlNodeInnerTextVisitor xmlNodeInnerTextVisitor = new XmlNodeInnerTextVisitor(); foreach (XmlNode node in xmlNodeList) { xmlNodeInnerTextVisitor.SetNode(node); if (xmlNodeInnerTextVisitor["tid"] == tid) { this.topicid.Value = xmlNodeInnerTextVisitor["tid"]; this.title.Text = xmlNodeInnerTextVisitor["title"]; this.poster.Text = xmlNodeInnerTextVisitor["poster"]; this.postdatetime.Text = xmlNodeInnerTextVisitor["postdatetime"]; } } }
//public static bool EditMenuItem(string mainMenuTitle, string subMenuTitle, string oldItemTitle, string newItemTitle, string link) //{ // int num = FindMenuID(mainMenuTitle, subMenuTitle, oldItemTitle); // return num != -1 && EditMenuItem(num, newItemTitle, link); //} public static void DeleteMenuItem(int id) { XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(configPath); XmlNodeList xmlNodeList = xmlDocumentExtender.SelectNodes("/dataset/submain"); string innerText = xmlNodeList.Item(id)["link"].InnerText; xmlNodeList.Item(id).ParentNode.RemoveChild(xmlNodeList.Item(id)); XmlNodeList xmlNodeList2 = xmlDocumentExtender.SelectNodes("/dataset/shortcut"); foreach (XmlNode xmlNode in xmlNodeList2) { if (xmlNode["link"].InnerText == innerText) { xmlNode.ParentNode.RemoveChild(xmlNode); break; } } xmlDocumentExtender.Save(configPath); }
/// <summary> /// 删除菜单项 /// </summary> /// <param name="id">菜单项的序号</param> public static void DeleteMenuItem(int id) { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList submains = doc.SelectNodes("/dataset/submain"); string link = submains.Item(id)["link"].InnerText; submains.Item(id).ParentNode.RemoveChild(submains.Item(id)); XmlNodeList shortcuts = doc.SelectNodes("/dataset/shortcut"); foreach (XmlNode shortmenuitem in shortcuts) { if (shortmenuitem["link"].InnerText == link) { shortmenuitem.ParentNode.RemoveChild(shortmenuitem); break; } } doc.Save(configPath); }
protected void Page_Load(object sender, EventArgs e) { string configPath = Page.Server.MapPath("../xml/user_" + this.userid + ".config"); if (!IsPostBack) { if (File.Exists(configPath)) { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); showhelp.SelectedValue = doc.SelectSingleNode("/UserConfig/ShowInfo") != null?doc.SelectSingleNode("/UserConfig/ShowInfo").InnerText : "1"; showupgrade.SelectedValue = doc.SelectSingleNode("/UserConfig/ShowUpgrade") != null?doc.SelectSingleNode("/UserConfig/ShowUpgrade").InnerText : "1"; } else { showhelp.SelectedValue = "1"; showupgrade.SelectedValue = "1"; } } }
private void BindEditData(string tid) { #region 装载主题编辑 panel1.Visible = true; XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList topiclistNode = doc.SelectNodes("/Aggregationinfo/Forum/Hottopiclist/Topic"); XmlNodeInnerTextVisitor topicvisitor = new XmlNodeInnerTextVisitor(); foreach (XmlNode topic in topiclistNode) { topicvisitor.SetNode(topic); if (topicvisitor["tid"] == tid) { topicid.Value = topicvisitor["tid"]; title.Text = topicvisitor["title"]; poster.Text = topicvisitor["poster"]; postdatetime.Text = topicvisitor["postdatetime"]; } } #endregion }
private void SaveTopic_Click(object sender, EventArgs e) { string @string = Request["forumtopicstatus"]; if (String.IsNullOrEmpty(@string)) { if (File.Exists(this.configPath)) { XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(this.configPath); xmlDocumentExtender.RemoveNodeAndChildNode("/Aggregationinfo/Data/Hottopiclist"); xmlDocumentExtender.RemoveNodeAndChildNode("/Aggregationinfo/Forum/Hottopiclist"); xmlDocumentExtender.Save(this.configPath); XCache.Remove("/Aggregation/Hottopiclist"); } base.Response.Redirect("aggregation_forumhottopic.aspx"); return; } Posts.WriteAggregationHotTopicsData(@string, this.configPath, "/Aggregationinfo/Data/Hottopiclist", "/Aggregationinfo/Forum/Hottopiclist"); XCache.Remove("/Aggregation/Hottopiclist"); base.Response.Redirect("aggregation_edithottopic.aspx"); }
protected void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { int row = e.Item.ItemIndex; XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList shortcutmenus = doc.SelectNodes("/dataset/shortcut"); int i = 0; foreach (XmlNode xn in shortcutmenus) { if (i == row) { xn.ParentNode.RemoveChild(xn); } i++; } doc.Save(configPath); MenuManage.CreateMenuJson(); base.RegisterStartupScript("delete", "<script type='text/javascript'>window.parent.LoadShortcutMenu();</script>"); BindDataGrid(); }
protected void DataGrid1_DeleteCommand(object source, DataGridCommandEventArgs e) { int itemIndex = e.Item.ItemIndex; XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(this.configPath); XmlNodeList xmlNodeList = xmlDocumentExtender.SelectNodes("/dataset/shortcut"); int num = 0; foreach (XmlNode xmlNode in xmlNodeList) { if (num == itemIndex) { xmlNode.ParentNode.RemoveChild(xmlNode); } num++; } xmlDocumentExtender.Save(this.configPath); MenuManage.CreateMenuJson(); base.RegisterStartupScript("delete", "<script type='text/javascript'>window.parent.LoadShortcutMenu();</script>"); this.BindDataGrid(); }
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 }
//public static bool EditMainMenu(string oldMainMenuTitle, string newMainMenuTitle, string defaulturl) //{ // int num = FindMenuID(oldMainMenuTitle); // return num != -1 && EditMainMenu(num, newMainMenuTitle, defaulturl); //} public static bool DeleteMainMenu(int menuid) { var xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(configPath); XmlNodeList xmlNodeList = xmlDocumentExtender.SelectNodes("/dataset/toptabmenu"); XmlNode xmlNode = null; int num = menuid; bool flag = false; foreach (XmlNode xmlNode2 in xmlNodeList) { if (xmlNode2["id"].InnerText == menuid.ToString()) { if (!xmlNode2["mainmenulist"].InnerText.IsNullOrEmpty()) { return(false); } xmlNode = xmlNode2; flag = true; break; } else { if (xmlNode != null) { xmlNode2["id"].InnerText = num.ToString(); num++; } } } if (flag) { xmlNode.ParentNode.RemoveChild(xmlNode); xmlDocumentExtender.Save(configPath); } return(flag); }
/// <summary> /// 删除一级菜单,其下子菜单必须为空 /// </summary> /// <param name="menuid">要删除的一级菜单ID</param> /// <returns>操作成功否</returns> public static bool DeleteMainMenu(int menuid) { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu"); XmlNode delMenu = null; int newid = menuid; bool result = false; foreach (XmlNode menuitem in mainmenus) { if (menuitem["id"].InnerText == menuid.ToString()) { if (menuitem["mainmenulist"].InnerText.Trim() != "") { return(false); } delMenu = menuitem; result = true; break; } else { if (delMenu != null) { menuitem["id"].InnerText = newid.ToString(); newid++; } } } if (result) { delMenu.ParentNode.RemoveChild(delMenu); doc.Save(configPath); } return(result); }
//public static bool DeleteMainMenu(string menuTitle) //{ // int num = FindMenuID(menuTitle); // return num != -1 && DeleteMainMenu(num); //} public static bool EditSubMenu(int submenuid, string menutitle) { var xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(configPath); XmlNodeList xmlNodeList = xmlDocumentExtender.SelectNodes("/dataset/mainmenu"); bool flag = false; foreach (XmlNode xmlNode in xmlNodeList) { if (xmlNode["id"].InnerText == submenuid.ToString()) { xmlNode["menutitle"].InnerText = menutitle; flag = true; break; } } if (flag) { xmlDocumentExtender.Save(configPath); } return(flag); }
/// <summary> /// 编辑子菜单 /// </summary> /// <param name="submenuid">子菜单ID</param> /// <param name="menutitle">子菜单标题</param> /// <returns>操作成功否</returns> public static bool EditSubMenu(int submenuid, string menutitle) { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList submains = doc.SelectNodes("/dataset/mainmenu"); bool result = false; foreach (XmlNode menuItem in submains) { if (menuItem["id"].InnerText == submenuid.ToString()) { menuItem["menutitle"].InnerText = menutitle; result = true; break; } } if (result) { doc.Save(configPath); } return(result); }
protected void Page_Load(object sender, EventArgs e) { // 在此处放置用户代码以初始化页面 allowUserGroup.Attributes.Add("onclick", "ChanageUserGroupStatus(this.checked)"); if (!IsPostBack) { EnableSpace.SelectedValue = config.Enablespace.ToString(); EnableSpace.Items[0].Attributes.Add("onclick", "ShowHiddenOption(true);"); EnableSpace.Items[1].Attributes.Add("onclick", "ShowHiddenOption(false);"); ShowSpaceOption.Attributes.Add("style", config.Enablespace == 1 ? "display:block" : "display:none"); ShowUserGroup.Attributes.Add("style", config.Enablespace == 1 ? "display:block" : "display:none"); LoadUserGroup(); XmlDocumentExtender xmlDoc = new XmlDocumentExtender(); xmlDoc.Load(Server.MapPath("../../config/space.config")); XmlNode root = xmlDoc.SelectSingleNode("SpaceActiveConfigInfo"); XmlNodeInnerTextVisitor rootvisitor = new XmlNodeInnerTextVisitor(); rootvisitor.SetNode(root); allowPostcount.Checked = rootvisitor["AllowPostcount"] == "1" ? true : false; Postcount.Text = rootvisitor["Postcount"]; allowDigestcount.Checked = rootvisitor["AllowDigestcount"] == "1" ? true : false; Digestcount.Text = rootvisitor["Digestcount"]; allowScore.Checked = rootvisitor["AllowScore"] == "1" ? true : false; Score.Text = rootvisitor["Score"]; allowUserGroup.Checked = rootvisitor["AllowUsergroups"] == "1" ? true : false; string groupList = rootvisitor["Usergroups"]; if (!allowUserGroup.Checked || groupList == "") { return; } else { BindUserGroup(groupList); } ActiveType.SelectedValue = rootvisitor["ActiveType"]; BindUserGorupMaxspaceattachsize(); } }
private DataTable GetWebsiteConfig() { DataTable dataTable = new DataTable(); dataTable.Columns.Add("tid"); dataTable.Columns.Add("title"); dataTable.Columns.Add("poster"); dataTable.Columns.Add("postdatetime"); dataTable.Columns.Add("showtype"); XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); if (!File.Exists(this.configPath)) { return(new DataTable()); } xmlDocumentExtender.Load(this.configPath); string xpath = "/Aggregationinfo/Aggregationpage/Website/Forum/Topiclist/Topic"; if (this.fid != "") { xpath = "/Aggregationinfo/Forum/Topiclist/Topic"; } XmlNodeList xmlNodeList = xmlDocumentExtender.SelectNodes(xpath); XmlNodeInnerTextVisitor xmlNodeInnerTextVisitor = new XmlNodeInnerTextVisitor(); foreach (XmlNode node in xmlNodeList) { xmlNodeInnerTextVisitor.SetNode(node); DataRow dataRow = dataTable.NewRow(); dataRow["tid"] = xmlNodeInnerTextVisitor["topicid"]; dataRow["title"] = xmlNodeInnerTextVisitor["title"]; dataRow["poster"] = xmlNodeInnerTextVisitor["poster"]; dataRow["postdatetime"] = xmlNodeInnerTextVisitor["postdatetime"]; dataTable.Rows.Add(dataRow); } return(dataTable); }
/// <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 DataTable GetWebsiteConfig() { #region 装载主题 DataTable dt = new DataTable(); dt.Columns.Add("tid"); dt.Columns.Add("title"); dt.Columns.Add("poster"); dt.Columns.Add("postdatetime"); dt.Columns.Add("showtype"); XmlDocumentExtender doc = new XmlDocumentExtender(); if (!File.Exists(configPath)) { return(new DataTable()); } doc.Load(configPath); string topicPath = "/Aggregationinfo/Aggregationpage/Website/Forum/Topiclist/Topic"; if (fid != "") { topicPath = "/Aggregationinfo/Forum/Topiclist/Topic"; } XmlNodeList topiclistNode = doc.SelectNodes(topicPath); XmlNodeInnerTextVisitor topicvisitor = new XmlNodeInnerTextVisitor(); foreach (XmlNode topic in topiclistNode) { topicvisitor.SetNode(topic); DataRow dr = dt.NewRow(); dr["tid"] = topicvisitor["topicid"]; dr["title"] = topicvisitor["title"]; dr["poster"] = topicvisitor["poster"]; dr["postdatetime"] = topicvisitor["postdatetime"]; dt.Rows.Add(dr); } return(dt); #endregion }
private void SaveTopic_Click(object sender, EventArgs e) { string @string = Request["forumtopicstatus"]; if (String.IsNullOrEmpty(@string)) { if (File.Exists(this.configPath)) { XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(this.configPath); xmlDocumentExtender.RemoveNodeAndChildNode("/Aggregationinfo/Data/Topiclist"); xmlDocumentExtender.RemoveNodeAndChildNode("/Aggregationinfo/Forum/Topiclist"); xmlDocumentExtender.Save(this.configPath); XCache.Remove("/Aggregation/TopicByForumId_" + this.fid); } base.Response.Redirect("aggregation_editforumaggset.aspx?fid=" + this.fid); return; } var postListFromFile = new ForumAggregationData().GetPostListFromFile("Website"); Posts.WriteAggregationPostData(postListFromFile, this.tablelist.SelectedValue, @string, this.configPath, "/Aggregationinfo/Data/Topiclist", "/Aggregationinfo/Forum/Topiclist"); XCache.Remove("/Aggregation/TopicByForumId_" + this.fid); base.Response.Redirect("aggregation_editforumaggset.aspx?fid=" + this.fid); }
private void DelRec_Click(object sender, EventArgs e) { #region 除附件分类 if (this.CheckCookie()) { if (DNTRequest.GetString("typeid") != "") { string idlist = DNTRequest.GetString("typeid"); XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(Server.MapPath(BaseConfigs.GetForumPath + "config/myattachment.config")); XmlNodeList xnl = doc.SelectNodes("/MyAttachmentsTypeConfigInfo/attachtypes/AttachmentType"); foreach (string id in idlist.Split(',')) { foreach (XmlNode xn in xnl) { if (id == xn["TypeId"].InnerText) { xn.ParentNode.RemoveChild(xn); break; } } } doc.Save(Server.MapPath(BaseConfigs.GetForumPath + "config/myattachment.config")); UpdateAttchmentTypes(); Response.Redirect("forum_attchemnttypes.aspx"); } else { base.RegisterStartupScript("", "<script>alert('您未选中任何选项');window.location.href='forum_attchemnttypes.aspx';</script>"); } } #endregion }
protected void Page_Load(object sender, EventArgs e) { string text = this.Page.Server.MapPath("../xml/user_" + this.userid + ".config"); bool flag; if (File.Exists(text)) { XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(text); flag = (xmlDocumentExtender.SelectSingleNode("/UserConfig/ShowUpgrade") != null && xmlDocumentExtender.SelectSingleNode("/UserConfig/ShowUpgrade").InnerText == "1"); } else { flag = true; } if (flag) { this.LoadUpgradeInfo(); } this.LoadTemplateInfo(); this.GetStatInfo(); this.forumid.BuildTree(Forums.GetForumListForDataTable(), "name", "fid"); this.LinkDiscuzVersionPage(); }
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>"); }
private void LoadInfo() { XmlDocumentExtender xmlDocumentExtender = new XmlDocumentExtender(); xmlDocumentExtender.Load(this.configPath); XmlNode xmlNode = xmlDocumentExtender.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Website_forumrecomend/fidlist"); if (xmlNode == null) { return; } string innerText = xmlNode.InnerText; string text = ""; List <IXForum> forumList = Forums.GetForumList(); string[] array = innerText.Split(','); for (int i = 0; i < array.Length; i++) { string b = array[i]; foreach (var current in forumList) { if (current.Fid.ToString() == b) { object obj = text; text = obj + "{'fid':'" + current.Fid + "','forumtitle':'" + current.Name + "'},"; break; } } } if (!String.IsNullOrEmpty(text)) { text = text.TrimEnd(','); } text = "<script type='text/javascript'>\r\nvar fidlist = [" + text + "];\r\nfor(var i = 0 ; i < fidlist.length ; i++)\r\n{\r\nvar no = new Option();\r\nno.value = fidlist[i]['fid'];\r\nno.text = fidlist[i]['forumtitle'];\r\nForm1.list2.options[Form1.list2.options.length] = no;\r\n}\r\n</script>"; base.RegisterStartupScript("", text); }
/// <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); }
/// <summary> /// 编辑一级主菜单 /// </summary> /// <param name="menuid">一级主菜单的ID</param> /// <param name="title">一级主菜单标题</param> /// <param name="defaulturl">一级主菜单默认展开的页面</param> /// <returns>操作成功否</returns> public static bool EditMainMenu(int menuid, string title, string defaulturl) { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu"); bool result = false; foreach (XmlNode menuitem in mainmenus) { if (menuitem["id"].InnerText == menuid.ToString()) { menuitem["title"].InnerText = title; menuitem["defaulturl"].InnerText = defaulturl; result = true; break; } } if (result) { doc.Save(configPath); } return(result); }
static AggregationData() { xmlDoc.Load(filepath); }
/// <summary> /// 读取聚合页面数据信息 /// </summary> public static void ReadAggregationConfig() { xmlDoc = new XmlDocumentExtender(); xmlDoc.Load(filepath); }
private void SaveTopic_Click(object sender, EventArgs e) { #region 保存相册修改 string pid = DNTRequest.GetString("pid"); string pidlist = Utils.ClearLastChar(recommendphoto.Value); string dataNode = ""; string indexNode = ""; if (pagename == "Website") { dataNode = "/Aggregationinfo/Aggregationdata/Websiteaggregationdata/Website_photolist"; indexNode = "/Aggregationinfo/Aggregationpage/Website/Website_photolist"; } else { dataNode = "/Aggregationinfo/Aggregationdata/Albumaggregationdata/Albumindex_photolist"; indexNode = "/Aggregationinfo/Aggregationpage/Albumindex/Albumindex_photolist"; } if (pidlist == "") { XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); doc.RemoveNodeAndChildNode(dataNode); doc.RemoveNodeAndChildNode(indexNode); doc.Save(configPath); Response.Redirect("aggregation_photoaggset.aspx?pagename=" + DNTRequest.GetString("pagename")); return; } else { IDataReader dr = DbProvider.GetInstance().GetRecommendPhotoList(pidlist); XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNode data_photolistnode = doc.InitializeNode(dataNode); XmlNode index_photolistnode = doc.InitializeNode(indexNode); string[] colName = { "photoid", "filename", "attachment", "filesize", "title", "description", "postdate", "albumid", "userid", "username", "views", "commentstatus", "tagstatus", "comments", "isattachment" }; while (dr.Read()) { XmlElement photo = doc.CreateElement("Photo"); foreach (string col in colName) { XmlElement node = doc.CreateElement(col); if (col == "filename") { node.InnerText = dr[col].ToString().Trim().Replace(".", "_thumbnail."); } else { node.InnerText = dr[col].ToString().Trim(); } photo.AppendChild(node); } data_photolistnode.AppendChild(photo); if (("," + pid + ",").IndexOf("," + dr["photoid"].ToString() + ",") >= 0) { index_photolistnode.AppendChild(photo.Clone()); } } dr.Close(); doc.Save(configPath); AggregationFacade.BaseAggregation.ClearAllDataBind(); AggregationFacade.AlbumAggregation.ClearDataBind(); Response.Redirect("aggregation_photoaggset.aspx?pagename=" + DNTRequest.GetString("pagename")); } #endregion }
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 }
private void SaveRotatepic_Click(object sender, EventArgs e) { #region 保存轮换图片修改 int rowid = 0; bool error = false; XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList __xmlnodelist = doc.SelectSingleNode(targetNode).ChildNodes; if ((__xmlnodelist != null) && (__xmlnodelist.Count > 0)) { doc.InitializeNode(targetNode); } foreach (object o in DataGrid1.GetKeyIDArray()) { #region 轮换图片 string rotatepicid = DataGrid1.GetControlValue(rowid, "rotatepicid"); //string name = ((TextBox)E.Item.FindControl("rotatepicid")).Text; string img = DataGrid1.GetControlValue(rowid, "img"); string url = DataGrid1.GetControlValue(rowid, "url"); string titlecontent = DataGrid1.GetControlValue(rowid, "titlecontent").Trim(); if (!Utils.IsNumeric(rotatepicid) || !Utils.IsURL(img) || !Utils.IsURL(url) || titlecontent == "") { //base.RegisterStartupScript("", "<script>alert('序号、图片路径或点击链接可能是非法URL或说明文字为空');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>"); //return; error = true; //continue; break;//如果用continue,则导致正确的设置可以被保存,有错误的设置却被删除,即使被修改之前是正确的。会丢失数据 } bool insert = false; XmlElement rotatepicNode = doc.CreateElement(nodeName); doc.AppendChildElementByNameValue(ref rotatepicNode, "rotatepicid", rotatepicid); doc.AppendChildElementByNameValue(ref rotatepicNode, "pagetype", "1"); doc.AppendChildElementByNameValue(ref rotatepicNode, "img", img); doc.AppendChildElementByNameValue(ref rotatepicNode, "url", url); doc.AppendChildElementByNameValue(ref rotatepicNode, "titlecontent", titlecontent); foreach (XmlNode __node in __xmlnodelist) { if (int.Parse(__node["rotatepicid"].InnerText) > int.Parse(rotatepicid)) { doc.SelectSingleNode(targetNode).InsertBefore(rotatepicNode, __node); insert = true; break; } } if (!insert) { doc.SelectSingleNode(targetNode).AppendChild(rotatepicNode); } rowid++; #endregion } AggregationFacade.BaseAggregation.ClearAllDataBind(); if (!error) { SiteUrls.SetInstance(); AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "聚合页面论坛广告编辑", ""); doc.Save(configPath); base.RegisterStartupScript("PAGE", "window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';"); return; } else { base.RegisterStartupScript("", "<script>alert('某行序号、图片路径或点击链接可能是非法URL或说明文字为空,不能进行更新.');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>"); return; } #endregion }