public static Discuz.Common.Generic.SortedList <int, object> GetTopicTypeArray() #endif { Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService(); #if NET1 System.Collections.SortedList topictypeList; #else Discuz.Common.Generic.SortedList <int, object> topictypeList; #endif topictypeList = cache.RetrieveObject("/TopicTypes") as Discuz.Common.Generic.SortedList <int, object>; if (topictypeList == null) { #if NET1 topictypeList = new System.Collections.SortedList(); #else topictypeList = new Discuz.Common.Generic.SortedList <int, object>(); #endif DataTable dt = DatabaseProvider.GetInstance().GetTopicTypeList(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { if ((dr["typeid"].ToString() != "") && (dr["name"].ToString() != "")) { topictypeList.Add(Int32.Parse(dr["typeid"].ToString()), dr["name"]); } } } cache.AddObject("/TopicTypes", topictypeList); } return(topictypeList); }
public virtual void AddObject(string xpath, Discuz.Common.Generic.SortedList <int, object> __sortedlist) #endif { lock (lockHelper) { if (__sortedlist.Count > 0) { AddObject(xpath + "flag", CacheFlag.CacheHaveData); } else { AddObject(xpath + "flag", CacheFlag.CacheNoData); } AddObject(xpath, (object)__sortedlist); } }
/// <summary> /// 删除版块中的主题分类 /// </summary> /// <param name="idlist">要删除主题分类的ID列表</param> private void DeleteForumTypes(string idlist) { #region 除所选的主题分类 //取得ID的数组 string[] ids = idlist.Split(','); //取得主题分类的缓存 #if NET1 System.Collections.SortedList __topictypearray = new SortedList(); #else Discuz.Common.Generic.SortedList <int, object> __topictypearray = new Discuz.Common.Generic.SortedList <int, object>(); #endif __topictypearray = Caches.GetTopicTypeArray(); //取得版块的fid,topictypes字段 DataTable dt = DatabaseProvider.GetInstance().GetForumTopicType(); //处理每一个版块 foreach (DataRow dr in dt.Rows) { //如果版块的主题分类字段为空(topictypes==""),则处理下一个 if (dr["topictypes"].ToString() == "") { continue; } string topictypes = dr["topictypes"].ToString(); //处理每一个要删除的ID foreach (string id in ids) { //将删除的ID拼成相应的格式串后,将原来的剔除掉,形成一个新的主题分类的字段 topictypes = topictypes.Replace(id + "," + __topictypearray[Int32.Parse(id)].ToString() + ",0|", ""); topictypes = topictypes.Replace(id + "," + __topictypearray[Int32.Parse(id)].ToString() + ",1|", ""); //将帖子列表(dnt_topics)中typeid为当前要删除的Id更新为0 DatabaseProvider.GetInstance().ClearTopicTopicType(int.Parse(id)); } //用剔除了要删除的主题ID的主题列表值更新数据库 DatabaseProvider.GetInstance().UpdateTopicTypeForForum(topictypes, int.Parse(dr["fid"].ToString())); } #endregion }
/// <summary> /// 删除所选的主题分类 /// </summary> /// <param name="typeidlist"></param> public static void DeleteForumTopicTypes(string typeidlist) { //取得ID的数组 string[] ids = typeidlist.Split(','); //取得主题分类的缓存 Discuz.Common.Generic.SortedList <int, string> topictypearray = new Discuz.Common.Generic.SortedList <int, string>(); topictypearray = Caches.GetTopicTypeArray(); //取得版块的fid,topictypes字段 DataTable dt = Forums.GetForumListForDataTable(); //处理每一个版块 foreach (DataRow dr in dt.Rows) { //如果版块的主题分类字段为空(topictypes==""),则处理下一个 if (dr["topictypes"].ToString() == "") { continue; } string topictypes = dr["topictypes"].ToString(); //处理每一个要删除的ID foreach (string id in ids) { //将删除的ID拼成相应的格式串后,将原来的剔除掉,形成一个新的主题分类的字段 topictypes = topictypes.Replace(id + "," + topictypearray[Int32.Parse(id)].ToString() + ",0|", ""); topictypes = topictypes.Replace(id + "," + topictypearray[Int32.Parse(id)].ToString() + ",1|", ""); //将帖子列表(dnt_topics)中typeid为当前要删除的Id更新为0 Data.Topics.ClearTopicType(int.Parse(id)); } //用剔除了要删除的主题ID的主题列表值更新数据库 ForumInfo forumInfo = Forums.GetForumInfo(int.Parse(dr["fid"].ToString())); forumInfo.Topictypes = topictypes; AdminForums.UpdateForumInfo(forumInfo); } }
private void SaveTopicType_Click(object sender, EventArgs e) { #region 保存主题分类编辑 //下四行取编辑行的更新值 int rowid = 0; bool error = false; foreach (object o in DataGrid1.GetKeyIDArray()) { string id = o.ToString(); string name = DataGrid1.GetControlValue(rowid, "name"); string displayorder = DataGrid1.GetControlValue(rowid, "displayorder"); string description = DataGrid1.GetControlValue(rowid, "description"); //判断主题分类表中是否有与要更新的重名 if (!CheckValue(name, displayorder, description) || TopicTypes.IsExistTopicType(name, int.Parse(id))) { error = true; continue; } //取得主题分类的缓存 Discuz.Common.Generic.SortedList<int, string> topictypearray = new Discuz.Common.Generic.SortedList<int, string>(); topictypearray = Caches.GetTopicTypeArray(); DataTable dt = Forums.GetExistTopicTypeOfForum(); DataTable topicTypes = TopicTypes.GetTopicTypes(); foreach (DataRow dr in dt.Rows) { //用新名更新dnt_forumfields表的topictypes字段 string topictypes = dr["topictypes"].ToString(); if (topictypes.Trim() == "") //如果主题列表为空则不处理 continue; string oldTopicType = GetTopicTypeString(topictypes, topictypearray[Int32.Parse(id)].ToString().Trim()); //获取修改名字前的旧主题列表 if (oldTopicType == "") //如果主题列表中不包含当前要修改的主题,则不处理 continue; string newTopicType = oldTopicType.Replace("," + topictypearray[Int32.Parse(id)].ToString().Trim() + ",", "," + name + ","); topictypes = topictypes.Replace(oldTopicType + "|", ""); //将旧的主题列表从论坛主题列表中删除 ArrayList topictypesal = new ArrayList(); foreach (string topictype in topictypes.Split('|')) { if (topictype != "") topictypesal.Add(topictype); } bool isInsert = false; for (int i = 0; i < topictypesal.Count; i++) { int curDisplayOrder = GetDisplayOrder(topictypesal[i].ToString().Split(',')[1], topicTypes); if (curDisplayOrder > int.Parse(displayorder)) { topictypesal.Insert(i, newTopicType); isInsert = true; break; } } if (!isInsert) { topictypesal.Add(newTopicType); } topictypes = ""; foreach (object t in topictypesal) { topictypes += t.ToString() + "|"; } TopicTypes.UpdateForumTopicType(topictypes, int.Parse(dr["fid"].ToString())); Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/TopicTypesOption" + dr["fid"].ToString()); Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/TopicTypesLink" + dr["fid"].ToString()); } //更新主题分类表(dnt_topictypes) TopicTypes.UpdateTopicTypes(name, int.Parse(displayorder), description, int.Parse(id)); rowid++; } //更新缓存 DNTCache cache = DNTCache.GetCacheService(); cache.RemoveObject("/Forum/TopicTypes"); cache.RemoveObject("/Forum/ForumList"); if(error) base.RegisterStartupScript("", "<script>alert('数据库中已存在相同的主题分类名称或为空,该记录不能被更新!');window.location.href='forum_topictypesgrid.aspx';</script>"); else base.RegisterStartupScript("PAGE", "window.location.href='forum_topictypesgrid.aspx';"); return; #endregion }
public static Discuz.Common.Generic.SortedList<int, object> GetTopicTypeArray() #endif { Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService(); #if NET1 System.Collections.SortedList topictypeList; #else Discuz.Common.Generic.SortedList<int, object> topictypeList; #endif topictypeList = cache.RetrieveObject("/TopicTypes") as Discuz.Common.Generic.SortedList<int, object>; if (topictypeList == null) { #if NET1 topictypeList = new System.Collections.SortedList(); #else topictypeList = new Discuz.Common.Generic.SortedList<int, object>(); #endif DataTable dt = DatabaseProvider.GetInstance().GetTopicTypeList(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { if ((dr["typeid"].ToString() != "") && (dr["name"].ToString() != "")) { topictypeList.Add(Int32.Parse(dr["typeid"].ToString()), dr["name"]); } } } cache.AddObject("/TopicTypes", topictypeList); } return topictypeList; }
private void SaveTopicType_Click(object sender, EventArgs e) { #region 保存主题分类编辑 //下四行取编辑行的更新值 int rowid = 0; bool error = false; foreach (object o in DataGrid1.GetKeyIDArray()) { string id = o.ToString(); string name = DataGrid1.GetControlValue(rowid, "name"); string displayorder = DataGrid1.GetControlValue(rowid, "displayorder"); string description = DataGrid1.GetControlValue(rowid, "description"); //判断主题分类表中是否有与要更新的重名 if (!CheckValue(name, displayorder, description) || TopicTypes.IsExistTopicType(name, int.Parse(id))) { error = true; continue; } //取得主题分类的缓存 Discuz.Common.Generic.SortedList <int, string> topictypearray = new Discuz.Common.Generic.SortedList <int, string>(); topictypearray = Caches.GetTopicTypeArray(); DataTable dt = Forums.GetExistTopicTypeOfForum(); DataTable topicTypes = TopicTypes.GetTopicTypes(); foreach (DataRow dr in dt.Rows) { //用新名更新dnt_forumfields表的topictypes字段 string topictypes = dr["topictypes"].ToString(); if (topictypes.Trim() == "") //如果主题列表为空则不处理 { continue; } string oldTopicType = GetTopicTypeString(topictypes, topictypearray[Int32.Parse(id)].ToString().Trim()); //获取修改名字前的旧主题列表 if (oldTopicType == "") //如果主题列表中不包含当前要修改的主题,则不处理 { continue; } string newTopicType = oldTopicType.Replace("," + topictypearray[Int32.Parse(id)].ToString().Trim() + ",", "," + name + ","); topictypes = topictypes.Replace(oldTopicType + "|", ""); //将旧的主题列表从论坛主题列表中删除 ArrayList topictypesal = new ArrayList(); foreach (string topictype in topictypes.Split('|')) { if (topictype != "") { topictypesal.Add(topictype); } } bool isInsert = false; for (int i = 0; i < topictypesal.Count; i++) { int curDisplayOrder = GetDisplayOrder(topictypesal[i].ToString().Split(',')[1], topicTypes); if (curDisplayOrder > int.Parse(displayorder)) { topictypesal.Insert(i, newTopicType); isInsert = true; break; } } if (!isInsert) { topictypesal.Add(newTopicType); } topictypes = ""; foreach (object t in topictypesal) { topictypes += t.ToString() + "|"; } TopicTypes.UpdateForumTopicType(topictypes, int.Parse(dr["fid"].ToString())); Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/TopicTypesOption" + dr["fid"].ToString()); Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/TopicTypesLink" + dr["fid"].ToString()); } //更新主题分类表(dnt_topictypes) TopicTypes.UpdateTopicTypes(name, int.Parse(displayorder), description, int.Parse(id)); rowid++; } //更新缓存 DNTCache cache = DNTCache.GetCacheService(); cache.RemoveObject("/Forum/TopicTypes"); if (error) { base.RegisterStartupScript("", "<script>alert('数据库中已存在相同的主题分类名称或为空,该记录不能被更新!');window.location.href='forum_topictypesgrid.aspx';</script>"); } else { base.RegisterStartupScript("PAGE", "window.location.href='forum_topictypesgrid.aspx';"); } return; #endregion }
/// <summary> /// 删除所选的主题分类 /// </summary> /// <param name="typeidlist"></param> public static void DeleteForumTopicTypes(string typeidlist) { //取得ID的数组 string[] ids = typeidlist.Split(','); //取得主题分类的缓存 Discuz.Common.Generic.SortedList<int, string> topictypearray = new Discuz.Common.Generic.SortedList<int, string>(); topictypearray = Caches.GetTopicTypeArray(); //取得版块的fid,topictypes字段 DataTable dt = Forums.GetForumListForDataTable(); //处理每一个版块 foreach (DataRow dr in dt.Rows) { //如果版块的主题分类字段为空(topictypes==""),则处理下一个 if (dr["topictypes"].ToString() == "") continue; string topictypes = dr["topictypes"].ToString(); //处理每一个要删除的ID foreach (string id in ids) { //将删除的ID拼成相应的格式串后,将原来的剔除掉,形成一个新的主题分类的字段 topictypes = topictypes.Replace(id + "," + topictypearray[Int32.Parse(id)].ToString() + ",0|", ""); topictypes = topictypes.Replace(id + "," + topictypearray[Int32.Parse(id)].ToString() + ",1|", ""); //将帖子列表(dnt_topics)中typeid为当前要删除的Id更新为0 Data.Topics.ClearTopicType(int.Parse(id)); } //用剔除了要删除的主题ID的主题列表值更新数据库 ForumInfo forumInfo = Forums.GetForumInfo(int.Parse(dr["fid"].ToString())); forumInfo.Topictypes = topictypes; AdminForums.UpdateForumInfo(forumInfo); } }
/// <summary> /// 删除版块中的主题分类 /// </summary> /// <param name="idlist">要删除主题分类的ID列表</param> private void DeleteForumTypes(string idlist) { #region 删除所选的主题分类 //取得ID的数组 string[] ids = idlist.Split(','); //取得主题分类的缓存 #if NET1 System.Collections.SortedList __topictypearray = new SortedList(); #else Discuz.Common.Generic.SortedList<int, object> __topictypearray = new Discuz.Common.Generic.SortedList<int, object>(); #endif __topictypearray = Caches.GetTopicTypeArray(); //取得版块的fid,topictypes字段 DataTable dt = DatabaseProvider.GetInstance().GetForumTopicType(); //处理每一个版块 foreach (DataRow dr in dt.Rows) { //如果版块的主题分类字段为空(topictypes==""),则处理下一个 if (dr["topictypes"].ToString() == "") continue; string topictypes = dr["topictypes"].ToString(); //处理每一个要删除的ID foreach (string id in ids) { //将删除的ID拼成相应的格式串后,将原来的剔除掉,形成一个新的主题分类的字段 topictypes = topictypes.Replace(id + "," + __topictypearray[Int32.Parse(id)].ToString() + ",0|", ""); topictypes = topictypes.Replace(id + "," + __topictypearray[Int32.Parse(id)].ToString() + ",1|", ""); //将帖子列表(dnt_topics)中typeid为当前要删除的Id更新为0 DatabaseProvider.GetInstance().ClearTopicTopicType(int.Parse(id)); } //用剔除了要删除的主题ID的主题列表值更新数据库 DatabaseProvider.GetInstance().UpdateTopicTypeForForum(topictypes, int.Parse(dr["fid"].ToString())); } #endregion }