예제 #1
0
        public override bool UpdateThreadCatalogs(ThreadCatalogCollection threadCatalogs)
        {
            using (SqlQuery query = new SqlQuery())
            {
                StringBuilder sql = new StringBuilder();

                int i = 0;
                foreach (ThreadCatalog threadCatalog in threadCatalogs)
                {
                    sql.AppendFormat(@"UPDATE [bx_ThreadCatalogs] SET [ThreadCatalogName] = @ThreadCatalogName_{0},[LogoUrl]=@LogoUrl_{0} WHERE [ThreadCatalogID] = @ThreadCatalogID_{0};", i);


                    query.CreateParameter <string>("@ThreadCatalogName_" + i, threadCatalog.ThreadCatalogName, SqlDbType.NVarChar, 64);
                    query.CreateParameter <string>("@LogoUrl_" + i, threadCatalog.LogoUrl, SqlDbType.NVarChar, 512);
                    query.CreateParameter <int>("@ThreadCatalogID_" + i, threadCatalog.ThreadCatalogID, SqlDbType.Int);


                    i++;
                }

                query.CommandText = sql.ToString();
                query.ExecuteNonQuery();
            }
            return(true);
        }
예제 #2
0
파일: ForumBO.cs 프로젝트: zhangbo27/bbsmax
        /// <summary>
        /// 不更新 totalThreads
        /// </summary>
        /// <param name="threadcatalogs"></param>
        /// <returns></returns>
        public bool UpdateThreadCatalogs(ThreadCatalogCollection threadcatalogs)
        {
            if (threadcatalogs.Count == 0)
            {
                return(true);
            }

            foreach (ThreadCatalog threadCatalog in threadcatalogs)
            {
                if (string.IsNullOrEmpty(threadCatalog.ThreadCatalogName))
                {
                    ThrowError <EmptyThreadCatalogNameError>(new EmptyThreadCatalogNameError("threadCatalogName"));
                    return(false);
                }
                if (StringUtil.GetByteCount(threadCatalog.ThreadCatalogName) > Consts.Forum_ThreadCatalogNameLength)
                {
                    ThrowError <InvalidThreadCatalogNameLengthError>(new InvalidThreadCatalogNameLengthError("ThreadCatalogName", threadCatalog.ThreadCatalogName));
                    return(false);
                }
                if (StringUtil.GetByteCount(threadCatalog.LogoUrl) > Consts.Forum_ThreadCatalogLogoUrlLength)
                {
                    ThrowError <InvalidThreadCatalogLogoUrlLengthError>(new InvalidThreadCatalogLogoUrlLengthError("LogoUrl", threadCatalog.LogoUrl));
                    return(false);
                }
            }

            bool success = ForumDaoV5.Instance.UpdateThreadCatalogs(threadcatalogs);

            if (success)
            {
                ClearThreadCatalogsCache();
            }

            return(success);
        }
예제 #3
0
파일: ForumBO.cs 프로젝트: zhangbo27/bbsmax
        public ThreadCatalogCollection GetAllThreadCatalogs()
        {
            if (s_AllThreadCatalogs == null)
            {
                s_AllThreadCatalogs = ForumDaoV5.Instance.GetAllThreadCatalogs();
            }

            return(s_AllThreadCatalogs);
        }
예제 #4
0
파일: ForumBO.cs 프로젝트: zhangbo27/bbsmax
        public ThreadCatalogCollection CreateThreadCatelogs(IEnumerable <string> catelogNames)
        {
            if (ValidateUtil.HasItems <string>(catelogNames) == false)
            {
                return(new ThreadCatalogCollection());
            }
            ThreadCatalogCollection threadCatalogs = ForumDaoV5.Instance.CreateThreadCatelogs(catelogNames);

            ClearThreadCatalogsCache();

            return(threadCatalogs);
        }
예제 #5
0
        protected string GetThreadCatalogList(int selectCatalogID, bool isShow)
        {
            ThreadCatalogCollection threadCatalogs = ForumBO.Instance.GetThreadCatalogs(ForumID);

            if (!isShow || threadCatalogs.Count == 0)
            {
                return(string.Empty);
            }


            if (Forum.ThreadCatalogStatus == ThreadCatalogStatus.DisEnable)
            {
                return(string.Empty);
            }

            StringBuilder selectString = new StringBuilder();

            selectString.Append("<select name=\"threadCatalogs\" size=\"1\">\r\n");

            int i = 0;

            foreach (ThreadCatalog threadCatalog in threadCatalogs)
            {
                if (i == 0)
                {
                    if (threadCatalog.ThreadCatalogID != 0)
                    {
                        if (Forum.ThreadCatalogStatus == ThreadCatalogStatus.Enable)
                        {
                            selectString.Append("<option value=\"0\">不选</option>\r\n");
                        }
                        else
                        {
                            selectString.Append("<option value=\"0\">请选择分类</option>\r\n");
                        }
                    }
                }

                if (selectCatalogID == threadCatalog.ThreadCatalogID)
                {
                    selectString.Append("<option value=\"").Append(threadCatalog.ThreadCatalogID).Append("\" selected=\"selected\">").Append(threadCatalog.ThreadCatalogName).Append("</option>\r\n");
                }
                else
                {
                    selectString.Append("<option value=\"").Append(threadCatalog.ThreadCatalogID).Append("\">").Append(threadCatalog.ThreadCatalogName).Append("</option>\r\n");
                }
                i++;
            }
            selectString.Append("</select>");

            return(selectString.ToString());
        }
예제 #6
0
        protected string GetForumThreadCatalogNames(int forumID, string separator)
        {
            ThreadCatalogCollection threadCatalogs = ForumBO.Instance.GetThreadCatalogs(forumID);
            StringBuilder           names          = new StringBuilder();

            foreach (ThreadCatalog catalog in threadCatalogs)
            {
                names.Append(catalog.ThreadCatalogName).Append(separator);
            }

            if (names.Length > 0)
            {
                return(names.ToString(0, names.Length - separator.Length));
            }

            return("(无)");
        }
예제 #7
0
파일: ForumBO.cs 프로젝트: zhangbo27/bbsmax
        /// <summary>
        /// 清理所有缓存
        /// </summary>
        public void ClearAllCache()
        {
            lock (allForumsLocker)
            {
                s_AllForums = null;
                s_AllForumsIndexByCodename = null;

                s_AllForumsForGuestList  = null;
                s_CategoriesForGuestList = null;
                s_Categories             = null;
                s_AllThreadCatalogs      = null;
                s_AllModerators          = null;
                //s_AllBannedUsers = null;
                s_ForumIdsForGuestVisit        = null;
                s_ForumIdsForGuestVisit_Cached = false;
            }
            BannedUserBO.Instance.ClearBannedUserCache();
        }
예제 #8
0
        public override void Action()
        {
            try
            {
                ValidateCodes.ValidateCodeManager.DeleteExperisValidateCodeActionRecord();
            }
            catch (Exception ex)
            {
                LogHelper.CreateErrorLog(ex);
            }

            try
            {
                FileManager.ClearExperisTempUploadFiles();
            }
            catch (Exception ex)
            {
                LogHelper.CreateErrorLog(ex);
            }

#if !Passport
            //重新统计论坛板块数据
            try
            {
                ForumCollection forums = ForumBO.Instance.GetAllForums();
                foreach (Forum forum in forums)
                {
                    ForumBO.Instance.UpdateForumData(forum);

                    ThreadCatalogCollection threadCatalogs = ForumBO.Instance.GetThreadCatalogs(forum.ForumID);
                    foreach (ThreadCatalog catalog in threadCatalogs)
                    {
                        ForumBO.Instance.UpdateForumThreadCatalogData(forum.ForumID, catalog.ThreadCatalogID, false);
                    }
                }

                ForumBO.Instance.ClearForumThreadCatalogsCache();
            }
            catch (Exception ex)
            {
                LogHelper.CreateErrorLog(ex);
            }
#endif
        }
예제 #9
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);
            }
        }
예제 #10
0
파일: ForumBO.cs 프로젝트: zhangbo27/bbsmax
        public ThreadCatalog GetForumThreadCatalog(int forumID, int threadCatalogID)
        {
            ThreadCatalogCollection threadCatalogs = GetThreadCatalogs(forumID);

            return(threadCatalogs.GetValue(threadCatalogID));
        }
예제 #11
0
파일: ForumBO.cs 프로젝트: zhangbo27/bbsmax
 private void ClearThreadCatalogsCache()
 {
     s_AllThreadCatalogs = null;
 }
예제 #12
0
        public override bool StepExecute(int operatorUserID, string param, ref long offset, ref int totalCount, ref int finishedCount, out string title, out bool isLastStep)
        {
            StringTable tempForumIDs = StringTable.Parse(param);

            int tempForumID = int.MaxValue;
            int maxForumID  = int.MinValue;

            foreach (string value in tempForumIDs.Values)
            {
                int forumID = int.Parse(value);

                if (maxForumID < forumID)
                {
                    maxForumID = forumID;
                }

                if (forumID > (int)offset)
                {
                    if (forumID < tempForumID)
                    {
                        tempForumID = forumID;
                    }
                }
            }

            if (tempForumID == maxForumID || tempForumID == int.MaxValue)
            {
                isLastStep = true;
            }
            else
            {
                isLastStep = false;
            }
            offset = tempForumID;

            Forum forum = ForumBO.Instance.GetForum(tempForumID, false);

            if (forum == null)
            {
                title = string.Empty;
                return(true);
            }

            //ForumManager.UpdateForumData(forum.ForumID, true);
            ForumBO.Instance.UpdateForumData(forum);

            //Dictionary<int, ThreadCatalog> threadCatalogs = ForumManager.GetThreadCatalogs(forum.ForumID);

            ThreadCatalogCollection threadCatalogs = ForumBO.Instance.GetThreadCatalogs(forum.ForumID);

            //int[] threadCatalogIDs = new int[threadCatalogs.Count];
            //threadCatalogs.Keys.CopyTo(threadCatalogIDs, 0);
            foreach (ThreadCatalog threadCatalog in threadCatalogs)
            {
                //ForumManager.UpdateForumThreadCatalogData(forum.ForumID, threadCatalogID);
                ForumBO.Instance.UpdateForumThreadCatalogData(forum.ForumID, threadCatalog.ThreadCatalogID, false);
                //System.Threading.Thread.Sleep(10);
            }
            //CacheUtil.Remove(MaxLabs.bbsMax.Common.BbsConst.CacheKey_ThreadCatalogsInForums);
            ForumBO.Instance.ClearForumThreadCatalogsCache();

            finishedCount++;


            title = "正更新版块“" + forum.ForumName + "”,总共 " + totalCount + ",已更新 " + finishedCount;

            return(true);
        }
예제 #13
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);
            }

        }
예제 #14
0
        public override bool UpdateThreadCatalogs(ThreadCatalogCollection threadCatalogs)
        {
            using (SqlQuery query = new SqlQuery())
            {
                StringBuilder sql = new StringBuilder();

                int i = 0;
                foreach (ThreadCatalog threadCatalog in threadCatalogs)
                {
                    sql.AppendFormat(@"UPDATE [bx_ThreadCatalogs] SET [ThreadCatalogName] = @ThreadCatalogName_{0},[LogoUrl]=@LogoUrl_{0} WHERE [ThreadCatalogID] = @ThreadCatalogID_{0};", i);


                    query.CreateParameter<string>("@ThreadCatalogName_" + i, threadCatalog.ThreadCatalogName, SqlDbType.NVarChar, 64);
                    query.CreateParameter<string>("@LogoUrl_" + i, threadCatalog.LogoUrl, SqlDbType.NVarChar, 512);
                    query.CreateParameter<int>("@ThreadCatalogID_" + i, threadCatalog.ThreadCatalogID, SqlDbType.Int);


                    i++;
                }

                query.CommandText = sql.ToString();
                query.ExecuteNonQuery();
            }
            return true;
        }
예제 #15
0
 /// <summary>
 /// 不更新 totalThreads
 /// </summary>
 public abstract bool UpdateThreadCatalogs(ThreadCatalogCollection threadCatalogs);