예제 #1
0
        public override bool AddThreadCatalogToForum(int forumID, ForumThreadCatalogCollection forumThreadCatalogs)
        {
            List <int> threadCatalogIDs = new List <int>();
            List <int> sortOrders       = new List <int>();

            foreach (ForumThreadCatalog catalog in forumThreadCatalogs)
            {
                threadCatalogIDs.Add(catalog.ThreadCatalogID);
                sortOrders.Add(catalog.SortOrder);
            }

            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_AddThreadCatalogToForum";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter <int>("@ForumID", forumID, SqlDbType.Int);
                query.CreateParameter <string>("@ThreadCatalogIDs", StringUtil.Join(threadCatalogIDs), SqlDbType.VarChar, 8000);
                query.CreateParameter <string>("@SortOrders", StringUtil.Join(sortOrders), SqlDbType.VarChar, 8000);
                query.CreateParameter <int>("@ErrorCode", SqlDbType.Int, ParameterDirection.ReturnValue);

                query.ExecuteNonQuery();

                return((int)query.Parameters["@ErrorCode"].Value == 0);
            }
        }
예제 #2
0
파일: ForumBO.cs 프로젝트: zhangbo27/bbsmax
        public bool AddThreadCatalogToForum(int forumID, ForumThreadCatalogCollection forumThreadCatalogs)
        {
            bool success = ForumDaoV5.Instance.AddThreadCatalogToForum(forumID, forumThreadCatalogs);

            if (success)
            {
                ClearForumThreadCatalogsCache();
            }

            return(success);
        }
예제 #3
0
파일: ForumBO.cs 프로젝트: zhangbo27/bbsmax
        public ForumThreadCatalogCollection GetThreadCatalogsInForums(int forumID)
        {
            ForumThreadCatalogCollection allForumThreadCatalogs = ForumDaoV5.Instance.GetThreadCatalogsInForums();
            ForumThreadCatalogCollection forumThreadCatalogs    = new ForumThreadCatalogCollection();

            foreach (ForumThreadCatalog catalog in allForumThreadCatalogs)
            {
                if (catalog.ForumID == forumID)
                {
                    forumThreadCatalogs.Add(catalog);
                }
            }

            return(forumThreadCatalogs);
        }
예제 #4
0
파일: ForumBO.cs 프로젝트: zhangbo27/bbsmax
        /// <summary>
        /// 获得某个论坛下的所有主题分类
        /// </summary>
        /// <param name="forumID"></param>
        /// <returns></returns>
        public ThreadCatalogCollection GetThreadCatalogs(int forumID)
        {
            Dictionary <int, ThreadCatalogCollection> allForumThreadCatalogs = s_AllForumThreadCatalogs;

            if (allForumThreadCatalogs == null)
            {
                allForumThreadCatalogs = new Dictionary <int, ThreadCatalogCollection>();

                ForumThreadCatalogCollection forumThreadCatalogs = ForumDaoV5.Instance.GetThreadCatalogsInForums();

                foreach (ForumThreadCatalog forumThreadCatalog in forumThreadCatalogs)
                {
                    ThreadCatalog tempThreadCatalog = GetThreadCatalog(forumThreadCatalog.ThreadCatalogID);
                    if (tempThreadCatalog == null)
                    {
                        continue;
                    }

                    ThreadCatalog catalog = tempThreadCatalog.Clone();
                    catalog.ThreadCount = forumThreadCatalog.TotalThreads;

                    if (allForumThreadCatalogs.ContainsKey(forumThreadCatalog.ForumID) == false)
                    {
                        allForumThreadCatalogs.Add(forumThreadCatalog.ForumID, new ThreadCatalogCollection());
                    }
                    allForumThreadCatalogs[forumThreadCatalog.ForumID].Add(catalog);
                }

                s_AllForumThreadCatalogs = allForumThreadCatalogs;
            }

            ThreadCatalogCollection threadCatalogs;

            if (!allForumThreadCatalogs.TryGetValue(forumID, out threadCatalogs))
            {
                return(new ThreadCatalogCollection());
            }

            return(threadCatalogs);
        }
예제 #5
0
        private void SaveThreadCatalogs()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("sortOrder", "threadcatalogname");

            ThreadCatalogStatus threadCatalogStatus = _Request.Get <ThreadCatalogStatus>("threadCategorySet", Method.Post, ThreadCatalogStatus.Enable);

            if (threadCatalogStatus == ThreadCatalogStatus.DisEnable)
            {
                if (Forum.ThreadCatalogStatus != threadCatalogStatus)
                {
                    try
                    {
                        bool success = ForumBO.Instance.UpdateForumThreadCatalogStatus(Forum.ForumID, threadCatalogStatus);
                        if (!success)
                        {
                            CatchError <ErrorInfo>(delegate(ErrorInfo error)
                            {
                                msgDisplay.AddError(error);
                            });
                        }
                        else
                        {
                            forum = null;
                            _Request.Clear(Method.Post);
                        }
                    }
                    catch (Exception ex)
                    {
                        msgDisplay.AddError(ex.Message);
                    }

                    return;
                }
            }


            int[] indexs = _Request.GetList <int>("catagories", Method.Post, new int[0]);

            //names = new Dictionary<int, string>();


            //List<ForumThreadCatalog> forumThreadCatalogs = new List<ForumThreadCatalog>();

            forumThreadCatalogs = new ForumThreadCatalogCollection();

            Dictionary <int, string> indexAndNames = new Dictionary <int, string>();

            List <int> sortOrders = new List <int>();

            List <string> newCatalogNames = new List <string>();

            foreach (int i in indexs)
            {
                ForumThreadCatalog catalog = new ForumThreadCatalog();
                catalog.ForumID         = Forum.ForumID;
                catalog.ThreadCatalogID = _Request.Get <int>("threadCatagories_" + i, Method.Post, 0);
                catalog.SortOrder       = _Request.Get <int>("sortorder_" + i, Method.Post, 0);
                string name = _Request.Get("threadCatalogName_" + i, Method.Post, string.Empty, false).Trim();
                catalog.ThreadCatalog = new ThreadCatalog();
                catalog.ThreadCatalog.ThreadCatalogName = name;


                if (name == string.Empty)
                {
                    msgDisplay.AddError("threadcatalogname", i, "分类名称不能为空");
                }
                else
                {
                    if (indexAndNames.ContainsValue(name))
                    {
                        msgDisplay.AddError("threadcatalogname", i, "重复的分类名称");
                    }
                    indexAndNames.Add(i, name);
                }


                if (sortOrders.Contains(catalog.SortOrder))
                {
                    msgDisplay.AddError("SortOrder", i, "重复的排序数字");
                }

                if (catalog.ThreadCatalogID == 0)
                {
                    newCatalogNames.Add(name);
                }

                sortOrders.Add(catalog.SortOrder);

                if (forumThreadCatalogs.GetValue(catalog.ForumID, catalog.ThreadCatalogID) == null)
                {
                    forumThreadCatalogs.Add(catalog);
                }
            }


            int[] newIndexs = _Request.GetList <int>("newcatagories", Method.Post, new int[0]);


            List <ForumThreadCatalog> newForumThreadCatalogs = new List <ForumThreadCatalog>();
            int j = 0;

            foreach (int i in newIndexs)
            {
                int tempI = j + indexs.Length;
                ForumThreadCatalog catalog = new ForumThreadCatalog();
                catalog.ForumID         = Forum.ForumID;
                catalog.ThreadCatalogID = _Request.Get <int>("new_threadCatagories_" + i, Method.Post, 0);
                catalog.SortOrder       = _Request.Get <int>("new_sortorder_" + i, Method.Post, 0);
                string name = _Request.Get("new_threadCatalogName_" + i, Method.Post, string.Empty, false);
                catalog.ThreadCatalog = new ThreadCatalog();
                catalog.ThreadCatalog.ThreadCatalogName = name;
                catalog.IsNew = true;


                if (name == string.Empty)
                {
                    msgDisplay.AddError("threadcatalogname", tempI, "分类名称不能为空");
                }
                else
                {
                    if (indexAndNames.ContainsValue(name))
                    {
                        msgDisplay.AddError("threadcatalogname", tempI, "重复的分类名称");
                    }
                    indexAndNames.Add(tempI, name);
                }


                if (sortOrders.Contains(catalog.SortOrder))
                {
                    msgDisplay.AddError("SortOrder", tempI, "重复的排序数字");
                }

                if (catalog.ThreadCatalogID == 0)
                {
                    newCatalogNames.Add(name);
                }

                sortOrders.Add(catalog.SortOrder);

                //if (forumThreadCatalogs.GetValue(catalog.ForumID, catalog.ThreadCatalogID) == null)
                //forumThreadCatalogs.Add(catalog);
                newForumThreadCatalogs.Add(catalog);
                j++;
            }



            if (msgDisplay.HasAnyError())
            {
                //forumThreadCatalogs.AddRange(newForumThreadCatalogs);
                int i = 0;
                foreach (ForumThreadCatalog catalog in newForumThreadCatalogs)
                {
                    catalog.ThreadCatalogID = i;
                    forumThreadCatalogs.Add(catalog);
                    i--;
                }
                return;
            }

            try
            {
                if (indexAndNames.Count == 0)
                {
                    msgDisplay.AddError("您已经启用了主题分类,必须至少添加一个主题分类");
                    return;
                }

                if (Forum.ThreadCatalogStatus != threadCatalogStatus)
                {
                    try
                    {
                        bool success = ForumBO.Instance.UpdateForumThreadCatalogStatus(Forum.ForumID, threadCatalogStatus);
                        if (!success)
                        {
                            CatchError <ErrorInfo>(delegate(ErrorInfo error)
                            {
                                msgDisplay.AddError(error);
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        msgDisplay.AddError(ex.Message);
                        return;
                    }
                }

                ThreadCatalogCollection threadCatalogs = ForumBO.Instance.CreateThreadCatelogs(newCatalogNames);

                //List<ForumThreadCatalog> results = new List<ForumThreadCatalog>();

                //ForumManager.UpdateThreadCatalogs

                ThreadCatalogCollection needUpdateThreadCatalogs = new ThreadCatalogCollection();
                for (int i = 0; i < forumThreadCatalogs.Count; i++)
                {
                    //if (forumThreadCatalogs[i].ThreadCatalogID != 0)
                    //{
                    ThreadCatalog tempThreadCatalog = new ThreadCatalog();
                    tempThreadCatalog.ThreadCatalogName = forumThreadCatalogs[i].ThreadCatalog.ThreadCatalogName;
                    tempThreadCatalog.ThreadCatalogID   = forumThreadCatalogs[i].ThreadCatalogID;
                    tempThreadCatalog.LogoUrl           = string.Empty;
                    needUpdateThreadCatalogs.Add(tempThreadCatalog);
                    //}
                    //else
                    //{
                    //    foreach (ThreadCatalog threadCatalog in threadCatalogs)
                    //    {
                    //        if (forumThreadCatalogs[i].ThreadCatalog.ThreadCatalogName == threadCatalog.ThreadCatalogName)
                    //        {
                    //            forumThreadCatalogs[i].ThreadCatalogID = threadCatalog.ThreadCatalogID;
                    //            //results.Add(forumThreadCatalogs[i]);
                    //            break;
                    //        }

                    //    }
                    //}
                }

                ForumBO.Instance.UpdateThreadCatalogs(needUpdateThreadCatalogs);
                //ForumManager.UpdateThreadCatalogs(needUpdateThreadCatalogs);

                for (int i = 0; i < newForumThreadCatalogs.Count; i++)
                {
                    foreach (ThreadCatalog threadCatalog in threadCatalogs)
                    {
                        if (newForumThreadCatalogs[i].ThreadCatalog.ThreadCatalogName == threadCatalog.ThreadCatalogName)
                        {
                            newForumThreadCatalogs[i].ThreadCatalogID = threadCatalog.ThreadCatalogID;
                            forumThreadCatalogs.Add(newForumThreadCatalogs[i]);
                            //results.Add(forumThreadCatalogs[i]);
                            break;
                        }
                    }
                }


                //if (ForumManager.AddThreadCatalogToForum(Forum.ForumID, forumThreadCatalogs) == true)
                if (ForumBO.Instance.AddThreadCatalogToForum(Forum.ForumID, forumThreadCatalogs) == true)
                {
                    forumThreadCatalogs = null;
                    forum = null;
                    _Request.Clear(Method.Post);
                }
                else
                {
                    msgDisplay.AddError("添加主题分类失败");
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }
예제 #6
0
        private void SaveThreadCatalogs()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("sortOrder", "threadcatalogname");

            ThreadCatalogStatus threadCatalogStatus = _Request.Get<ThreadCatalogStatus>("threadCategorySet", Method.Post, ThreadCatalogStatus.Enable);

            if (threadCatalogStatus == ThreadCatalogStatus.DisEnable)
            {
                if (Forum.ThreadCatalogStatus != threadCatalogStatus)
                {
                    try
                    {
                        bool success = ForumBO.Instance.UpdateForumThreadCatalogStatus(Forum.ForumID, threadCatalogStatus);
                        if (!success)
                        {
                            CatchError<ErrorInfo>(delegate(ErrorInfo error)
                            {
                                msgDisplay.AddError(error);
                            });
                        }
                        else
                        {
                            forum = null;
                            _Request.Clear(Method.Post);
                        }
                    }
                    catch (Exception ex)
                    {
                        msgDisplay.AddError(ex.Message);
                    }

                    return;
                }
            }


            int[] indexs = _Request.GetList<int>("catagories", Method.Post, new int[0]);

            //names = new Dictionary<int, string>();


            //List<ForumThreadCatalog> forumThreadCatalogs = new List<ForumThreadCatalog>();

            forumThreadCatalogs = new ForumThreadCatalogCollection();

            Dictionary<int, string> indexAndNames = new Dictionary<int, string>();

            List<int> sortOrders = new List<int>();

            List<string> newCatalogNames = new List<string>();

            foreach (int i in indexs)
            {
                ForumThreadCatalog catalog = new ForumThreadCatalog();
                catalog.ForumID = Forum.ForumID;
                catalog.ThreadCatalogID = _Request.Get<int>("threadCatagories_" + i, Method.Post, 0);
                catalog.SortOrder = _Request.Get<int>("sortorder_" + i, Method.Post, 0);
                string name = _Request.Get("threadCatalogName_" + i, Method.Post, string.Empty, false).Trim();
                catalog.ThreadCatalog = new ThreadCatalog();
                catalog.ThreadCatalog.ThreadCatalogName = name;


                if (name == string.Empty)
                {
                    msgDisplay.AddError("threadcatalogname", i, "分类名称不能为空");
                }
                else
                {
                    if (indexAndNames.ContainsValue(name))
                    {
                        msgDisplay.AddError("threadcatalogname", i, "重复的分类名称");
                    }
                    indexAndNames.Add(i, name);
                }


                if (sortOrders.Contains(catalog.SortOrder))
                {
                    msgDisplay.AddError("SortOrder", i, "重复的排序数字");
                }

                if (catalog.ThreadCatalogID == 0)
                    newCatalogNames.Add(name);

                sortOrders.Add(catalog.SortOrder);

                if (forumThreadCatalogs.GetValue(catalog.ForumID, catalog.ThreadCatalogID) == null)
                    forumThreadCatalogs.Add(catalog);

            }


            int[] newIndexs = _Request.GetList<int>("newcatagories", Method.Post, new int[0]);


            List<ForumThreadCatalog> newForumThreadCatalogs = new List<ForumThreadCatalog>();
            int j = 0;
            foreach (int i in newIndexs)
            {
                int tempI = j + indexs.Length;
                ForumThreadCatalog catalog = new ForumThreadCatalog();
                catalog.ForumID = Forum.ForumID;
                catalog.ThreadCatalogID = _Request.Get<int>("new_threadCatagories_" + i, Method.Post, 0);
                catalog.SortOrder = _Request.Get<int>("new_sortorder_" + i, Method.Post, 0);
                string name = _Request.Get("new_threadCatalogName_" + i, Method.Post, string.Empty, false);
                catalog.ThreadCatalog = new ThreadCatalog();
                catalog.ThreadCatalog.ThreadCatalogName = name;
                catalog.IsNew = true;


                if (name == string.Empty)
                {
                    msgDisplay.AddError("threadcatalogname", tempI, "分类名称不能为空");
                }
                else
                {
                    if (indexAndNames.ContainsValue(name))
                    {
                        msgDisplay.AddError("threadcatalogname", tempI, "重复的分类名称");
                    }
                    indexAndNames.Add(tempI, name);
                }


                if (sortOrders.Contains(catalog.SortOrder))
                {
                    msgDisplay.AddError("SortOrder", tempI, "重复的排序数字");
                }

                if (catalog.ThreadCatalogID == 0)
                    newCatalogNames.Add(name);

                sortOrders.Add(catalog.SortOrder);

                //if (forumThreadCatalogs.GetValue(catalog.ForumID, catalog.ThreadCatalogID) == null)
                //forumThreadCatalogs.Add(catalog);
                newForumThreadCatalogs.Add(catalog);
                j++;
            }



            if (msgDisplay.HasAnyError())
            {
                //forumThreadCatalogs.AddRange(newForumThreadCatalogs);
                int i = 0;
                foreach (ForumThreadCatalog catalog in newForumThreadCatalogs)
                {
                    catalog.ThreadCatalogID = i;
                    forumThreadCatalogs.Add(catalog);
                    i--;
                }
                return;
            }

            try
            {
                if (indexAndNames.Count == 0)
                {
                    msgDisplay.AddError("您已经启用了主题分类,必须至少添加一个主题分类");
                    return;
                }

                if (Forum.ThreadCatalogStatus != threadCatalogStatus)
                {
                    try
                    {
                        bool success = ForumBO.Instance.UpdateForumThreadCatalogStatus(Forum.ForumID, threadCatalogStatus);
                        if (!success)
                        {
                            CatchError<ErrorInfo>(delegate(ErrorInfo error)
                            {
                                msgDisplay.AddError(error);
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        msgDisplay.AddError(ex.Message);
                        return;
                    }
                }

                ThreadCatalogCollection threadCatalogs = ForumBO.Instance.CreateThreadCatelogs(newCatalogNames);

                //List<ForumThreadCatalog> results = new List<ForumThreadCatalog>();

                //ForumManager.UpdateThreadCatalogs

                ThreadCatalogCollection needUpdateThreadCatalogs = new ThreadCatalogCollection();
                for (int i = 0; i < forumThreadCatalogs.Count; i++)
                {
                    //if (forumThreadCatalogs[i].ThreadCatalogID != 0)
                    //{
                        ThreadCatalog tempThreadCatalog = new ThreadCatalog();
                        tempThreadCatalog.ThreadCatalogName = forumThreadCatalogs[i].ThreadCatalog.ThreadCatalogName;
                        tempThreadCatalog.ThreadCatalogID = forumThreadCatalogs[i].ThreadCatalogID;
                        tempThreadCatalog.LogoUrl = string.Empty;
                        needUpdateThreadCatalogs.Add(tempThreadCatalog);
                    //}
                    //else
                    //{
                    //    foreach (ThreadCatalog threadCatalog in threadCatalogs)
                    //    {
                    //        if (forumThreadCatalogs[i].ThreadCatalog.ThreadCatalogName == threadCatalog.ThreadCatalogName)
                    //        {
                    //            forumThreadCatalogs[i].ThreadCatalogID = threadCatalog.ThreadCatalogID;
                    //            //results.Add(forumThreadCatalogs[i]);
                    //            break;
                    //        }

                    //    }
                    //}

                }

                ForumBO.Instance.UpdateThreadCatalogs(needUpdateThreadCatalogs);
                //ForumManager.UpdateThreadCatalogs(needUpdateThreadCatalogs);

                for (int i = 0; i < newForumThreadCatalogs.Count; i++)
                {
                    foreach (ThreadCatalog threadCatalog in threadCatalogs)
                    {
                        if (newForumThreadCatalogs[i].ThreadCatalog.ThreadCatalogName == threadCatalog.ThreadCatalogName)
                        {
                            newForumThreadCatalogs[i].ThreadCatalogID = threadCatalog.ThreadCatalogID;
                            forumThreadCatalogs.Add(newForumThreadCatalogs[i]);
                            //results.Add(forumThreadCatalogs[i]);
                            break;
                        }

                    }
                }


                //if (ForumManager.AddThreadCatalogToForum(Forum.ForumID, forumThreadCatalogs) == true)
                if (ForumBO.Instance.AddThreadCatalogToForum(Forum.ForumID, forumThreadCatalogs) == true)
                {
                    forumThreadCatalogs = null;
                    forum = null;
                    _Request.Clear(Method.Post);
                }
                else
                {
                    msgDisplay.AddError("添加主题分类失败");
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }

        }
예제 #7
0
        public override bool AddThreadCatalogToForum(int forumID, ForumThreadCatalogCollection forumThreadCatalogs)
        {
            List<int> threadCatalogIDs = new List<int>();
            List<int> sortOrders = new List<int>();

            foreach (ForumThreadCatalog catalog in forumThreadCatalogs)
            {
                threadCatalogIDs.Add(catalog.ThreadCatalogID);
                sortOrders.Add(catalog.SortOrder);
            }

            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_AddThreadCatalogToForum";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ForumID", forumID, SqlDbType.Int);
                query.CreateParameter<string>("@ThreadCatalogIDs", StringUtil.Join(threadCatalogIDs), SqlDbType.VarChar, 8000);
                query.CreateParameter<string>("@SortOrders", StringUtil.Join(sortOrders), SqlDbType.VarChar, 8000);
                query.CreateParameter<int>("@ErrorCode", SqlDbType.Int, ParameterDirection.ReturnValue);

                query.ExecuteNonQuery();

                return (int)query.Parameters["@ErrorCode"].Value == 0;
            }
        }
예제 #8
0
 public abstract bool AddThreadCatalogToForum(int forumID, ForumThreadCatalogCollection forumThreadCatalogs);