Example #1
0
        public bool UpdateForumThreadCatalogStatus(int forumID, ThreadCatalogStatus status)
        {
            bool success = ForumDaoV5.Instance.UpdateForumThreadCatalogStatus(forumID, status);

            if (success)
            {
                ClearAllCache();
            }

            return(success);
        }
Example #2
0
        public override bool UpdateForumThreadCatalogStatus(int forumID, ThreadCatalogStatus status)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_UpdateForumThreadCatalogStatus";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter <int>("@ForumID", forumID, SqlDbType.Int);
                query.CreateParameter <int>("@ThreadCatalogStatus", (int)status, SqlDbType.TinyInt);

                query.ExecuteNonQuery();
            }

            return(true);
        }
Example #3
0
        public bool CreateForum(AuthUser operatorUser, string codeName, string forumName, int parentID, ForumType forumType, string password, string logoSrc
                                , string themeID, string readme, string description, ThreadCatalogStatus threadCatalogStaus, int columnSpan, int sortOrder
                                , ForumExtendedAttribute forumExtendedDatas, out int forumID)
        {
            forumID = 0;
            if (!AllSettings.Current.BackendPermissions.Can(operatorUser, BackendPermissions.Action.Manage_Forum))
            {
                ThrowError <NoPermissionManageForumError>(new NoPermissionManageForumError(0));
                return(false);
            }


            if (false == ValidateForumParams(codeName, forumName, parentID, forumType, password, logoSrc, themeID))
            {
                return(false);
            }
            int result = ForumDaoV5.Instance.CreateForum(codeName, forumName, parentID, forumType, password, logoSrc, themeID, readme, description, threadCatalogStaus, columnSpan, sortOrder, forumExtendedDatas, out forumID);

            switch (result)
            {
            case 13:
                ThrowError <DuplicateForumCodeNameError>(new DuplicateForumCodeNameError("codename", codeName));
                return(false);

            case -1:
                ThrowError <ParentForumNotExistsError>(new ParentForumNotExistsError("parentID"));
                return(false);

            default: break;
            }

            ClearAllCache();
            ThreadCachePool.ClearAllCache();

            return(true);
        }
        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);
            }
        }
Example #5
0
        public override int CreateForum(string codeName, string forumName, int parentID, ForumType forumType, string password, string logoUrl
                                        , string themeID, string readme, string description, ThreadCatalogStatus threadCatalogStaus, int columnSpan, int sortOrder
                                        , ForumExtendedAttribute forumExtendedDatas, out int forumID)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_v5_CreateForum";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter <string>("@CodeName", codeName, SqlDbType.NVarChar, 128);
                query.CreateParameter <string>("@ForumName", forumName, SqlDbType.NVarChar, 1024);
                query.CreateParameter <int>("@ParentID", parentID, SqlDbType.Int);
                query.CreateParameter <int>("@ForumType", (int)forumType, SqlDbType.TinyInt);
                query.CreateParameter <string>("@Password", password, SqlDbType.NVarChar, 64);
                query.CreateParameter <string>("@LogoUrl", logoUrl, SqlDbType.NVarChar, 256);
                query.CreateParameter <string>("@ThemeID", themeID, SqlDbType.NVarChar, 64);
                query.CreateParameter <string>("@Readme", readme, SqlDbType.NText);
                query.CreateParameter <string>("@Description", description, SqlDbType.NText);
                query.CreateParameter <int>("@ThreadCatalogStatus", (int)threadCatalogStaus, SqlDbType.TinyInt);
                query.CreateParameter <int>("@ColumnSpan", columnSpan, SqlDbType.TinyInt);
                query.CreateParameter <int>("@SortOrder", sortOrder, SqlDbType.Int);
                query.CreateParameter <string>("@ExtendedAttributes", forumExtendedDatas.ToString(), SqlDbType.NText);

                query.CreateParameter <int>("@ForumID", SqlDbType.Int, ParameterDirection.Output);
                query.CreateParameter <int>("@ErrorCode", SqlDbType.Int, ParameterDirection.ReturnValue);

                query.ExecuteNonQuery();

                forumID = (int)query.Parameters["@ForumID"].Value;
                return((int)query.Parameters["@ErrorCode"].Value);
            }
        }
Example #6
0
        public override bool UpdateForumThreadCatalogStatus(int forumID, ThreadCatalogStatus status)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_UpdateForumThreadCatalogStatus";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ForumID", forumID, SqlDbType.Int);
                query.CreateParameter<int>("@ThreadCatalogStatus", (int)status, SqlDbType.TinyInt);

                query.ExecuteNonQuery();
            }

            return true;
        }
Example #7
0
        public override int CreateForum(string codeName, string forumName, int parentID, ForumType forumType, string password, string logoUrl
            , string themeID, string readme, string description, ThreadCatalogStatus threadCatalogStaus, int columnSpan, int sortOrder
            , ForumExtendedAttribute forumExtendedDatas, out int forumID)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_v5_CreateForum";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<string>("@CodeName", codeName, SqlDbType.NVarChar, 128);
                query.CreateParameter<string>("@ForumName", forumName, SqlDbType.NVarChar, 1024);
                query.CreateParameter<int>("@ParentID", parentID, SqlDbType.Int);
                query.CreateParameter<int>("@ForumType", (int)forumType, SqlDbType.TinyInt);
                query.CreateParameter<string>("@Password", password, SqlDbType.NVarChar, 64);
                query.CreateParameter<string>("@LogoUrl", logoUrl, SqlDbType.NVarChar, 256);
                query.CreateParameter<string>("@ThemeID", themeID, SqlDbType.NVarChar, 64);
                query.CreateParameter<string>("@Readme", readme, SqlDbType.NText);
                query.CreateParameter<string>("@Description", description, SqlDbType.NText);
                query.CreateParameter<int>("@ThreadCatalogStatus", (int)threadCatalogStaus, SqlDbType.TinyInt);
                query.CreateParameter<int>("@ColumnSpan", columnSpan, SqlDbType.TinyInt);
                query.CreateParameter<int>("@SortOrder", sortOrder, SqlDbType.Int);
                query.CreateParameter<string>("@ExtendedAttributes", forumExtendedDatas.ToString(), SqlDbType.NText);

                query.CreateParameter<int>("@ForumID", SqlDbType.Int, ParameterDirection.Output);
                query.CreateParameter<int>("@ErrorCode", SqlDbType.Int, ParameterDirection.ReturnValue);

                query.ExecuteNonQuery();

                forumID = (int)query.Parameters["@ForumID"].Value;
                return (int)query.Parameters["@ErrorCode"].Value;
            }
        }
Example #8
0
 public abstract int CreateForum(string codeName, string forumName, int parentID, ForumType forumType, string password, string logoUrl
                                 , string themeID, string readme, string description, ThreadCatalogStatus threadCatalogStaus, int columnSpan, int sortOrder
                                 , ForumExtendedAttribute forumExtendedDatas, out int forumID);
Example #9
0
 public abstract bool UpdateForumThreadCatalogStatus(int forumID, ThreadCatalogStatus status);