コード例 #1
0
ファイル: Forum.cs プロジェクト: zhangbo27/bbsmax
        public Forum(DataReaderWrap readerWrap)
        {
            ExtendedAttribute = new ForumExtendedAttribute();

            #region 填充论坛实体

            this.ForumID     = readerWrap.Get <int>("ForumID");
            this.ForumName   = readerWrap.Get <string>("ForumName");
            this.ParentID    = readerWrap.Get <int>("ParentID");
            this.ForumStatus = readerWrap.Get <ForumStatus>("ForumStatus");
            if (this.ParentID == 0)
            {
                this.ForumType = Enums.ForumType.Catalog;
            }
            else
            {
                this.ForumType = readerWrap.Get <ForumType>("ForumType");                           //(ForumType)Convert.ToInt32(reader["ForumType"]);
            }
            this.ThreadCatalogStatus = readerWrap.Get <ThreadCatalogStatus>("ThreadCatalogStatus"); //(ThreadCatalogStatus)Convert.ToInt32(reader["ThreadCatalogStatus"]);

            this.VisitPaths = StringList.Parse(readerWrap.Get <string>("VisitPaths"));

            this.CodeName = readerWrap.Get <string>("CodeName");

            this.Description = readerWrap.Get <string>("Description");
            this.Readme      = readerWrap.Get <string>("Readme");

            this.LogoSrc = readerWrap.Get <string>("LogoSrc");
            this.ThemeID = readerWrap.Get <string>("ThemeID");

            this.TotalThreads = readerWrap.Get <int>("TotalThreads");
            this.TotalPosts   = readerWrap.Get <int>("TotalPosts");
            this.TodayThreads = readerWrap.Get <int>("TodayThreads");
            this.TodayPosts   = readerWrap.Get <int>("TodayPosts");

            this.LastThreadID = readerWrap.Get <int>("LastThreadID");

            this.Password = readerWrap.Get <string>("Password");

            this.ColumnSpan = (int)readerWrap.Get <byte>("ColumnSpan");
            this.SortOrder  = readerWrap.Get <int>("SortOrder");

            ClubID = readerWrap.Get <int>("ClubID");

            string extendedAttributesString = readerWrap.Get <string>("ExtendedAttributes");

            if (!string.IsNullOrEmpty(extendedAttributesString))
            {
                ExtendedAttribute.Parse(extendedAttributesString);
            }


            #endregion
        }
コード例 #2
0
        private void SaveForum()
        {
            m_IsSuccess = false;
            MessageDisplay message = CreateMessageDisplay("codeName", "forumName", "parentID", "forumType", "logoSrc", "themeID", "password"
                , "DisplayInList", "new_DisplayInList", "VisitForum", "new_VisitForum", "SigninForumWithoutPassword", "new_SigninForumWithoutPassword");

            string codeName = _Request.Get("codeName", Method.Post, string.Empty);
            string forumName = _Request.Get("forumName", Method.Post, string.Empty, false);
            int sortOrder = _Request.Get<int>("sortorder", Method.Post, 0);
            ForumType forumType = _Request.Get<ForumType>("forumType", Method.Post, ForumType.Normal);

            string password;
            if (forumType == ForumType.Link)
            {
                password = _Request.Get("forumLink", Method.Post, string.Empty, false);
                if (password.Trim() == string.Empty)
                    message.AddError("password", "请填写链接地址");
            }
            else
            {
                password = _Request.Get("password", Method.Post, string.Empty);
            }

            int columnSpan = _Request.Get<int>("colSpan", Method.Post, 0);
            int parentID;
            if (forumType == ForumType.Catalog)
            {
                parentID = 0;
            }
            else
            {
                if (IsEdit)
                    parentID = Forum.ParentID;
                else
                    parentID = _Request.Get<int>("parentForum", Method.Post, 0);
            }
            string description = StringUtil.Trim(_Request.Get("Description", Method.Post, string.Empty, false));
            string readme = StringUtil.Trim(_Request.Get("readme", Method.Post, string.Empty, false));
            string logoSrc = _Request.Get("logo", Method.Post, string.Empty);
            string themeID = _Request.Get("theme", Method.Post, string.Empty);

            ThreadCatalogStatus threadCatalogStatus;
            if (IsEdit)
                threadCatalogStatus = Forum.ThreadCatalogStatus;
            else
                threadCatalogStatus = ThreadCatalogStatus.DisEnable;

            ForumExtendedAttribute extendedDatas = new ForumExtendedAttribute();

            extendedDatas.LinkOpenByNewWidow = _Request.Get<bool>("linktype", Method.Post, false);

            //extendedDatas.AllowGuestVisitForum = _Request.Get<bool>("AllowGuestVisitForum", Method.Post, true);
            //extendedDatas.DisplayInListForGuest = _Request.Get<bool>("DisplayInListForGuest", Method.Post, true);

            //extendedDatas.DisplayInList = new ExceptableSetting.ExceptableItem_bool().GetExceptable("DisplayInList", message);
            //extendedDatas.VisitForum = new ExceptableSetting.ExceptableItem_bool().GetExceptable("VisitForum", message);
            extendedDatas.SigninForumWithoutPassword = new ExceptableSetting.ExceptableItem_bool().GetExceptable("SigninForumWithoutPassword", message);


            extendedDatas.MetaDescription = _Request.Get("MetaDescription", Method.Post, "");
            extendedDatas.MetaKeywords = _Request.Get("MetaKeywords", Method.Post, "");
            extendedDatas.TitleAttach = _Request.Get("TitleAttach", Method.Post, "");

            if (message.HasAnyError())
            {
                return;
            }

            try
            {
                using (new ErrorScope())
                {
                    bool success;
                    int forumID;
                    if (IsEdit)
                    {
                        forumID = Forum.ForumID;
                        success = ForumBO.Instance.UpdateForum(My, forumID, codeName, forumName, forumType, password, logoSrc
                            , readme, description, themeID, columnSpan, sortOrder, extendedDatas);
                    }
                    else
                    {
                        success = ForumBO.Instance.CreateForum(My, codeName, forumName, parentID, forumType, password, logoSrc
                            , themeID, readme, description, threadCatalogStatus, columnSpan, sortOrder, extendedDatas, out forumID);
                    }
                    if (success == false)
                    {
                        CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            message.AddError(error);
                        });
                        m_IsSuccess = false;
                    }
                    else
                    {

                        if (new ExceptableItem_bool().AplyAllNode("SigninForumWithoutPassword"))//应用到所有下级版块
                        {
                            Dictionary<int, ForumExtendedAttribute> extendedAttributes = new Dictionary<int, ForumExtendedAttribute>();
                            ForumCollection childForums = ForumBO.Instance.GetAllSubForums(forumID);
                            foreach (Forum tempForum in childForums)
                            {
                                tempForum.ExtendedAttribute.SigninForumWithoutPassword = forum.ExtendedAttribute.SigninForumWithoutPassword;
                                extendedAttributes.Add(tempForum.ForumID, tempForum.ExtendedAttribute);
                            }

                            ForumBO.Instance.UpdateChildForumsExtendedAttributes(My, extendedAttributes);
                        }

                        if (IsEdit == false)
                            JumpTo("bbs/manage-forum.aspx");
                        else
                            BbsRouter.JumpToCurrentUrl("success=1");
                    }
                }
            }
            catch (Exception ex)
            {
                message.AddError(ex.Message);
            }
        }
コード例 #3
0
ファイル: Forum.cs プロジェクト: zhangbo27/bbsmax
 public Forum()
 {
     ExtendedAttribute = new ForumExtendedAttribute();
 }
コード例 #4
0
ファイル: ForumDao.cs プロジェクト: huchao007/bbsmax
        public override int UpdateForum(int forumID, string codeName, string forumName, ForumType forumType, string password, string logoUrl
            , string readme, string description, string themeID, int columnSpan, int sortOrder, ForumExtendedAttribute forumExtendedDatas)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_v5_UpdateForum";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ForumID", forumID, SqlDbType.Int);
                query.CreateParameter<string>("@CodeName", codeName, SqlDbType.NVarChar, 128);
                query.CreateParameter<string>("@ForumName", forumName, SqlDbType.NVarChar, 1024);
                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>("@ColumnSpan", columnSpan, SqlDbType.TinyInt);
                query.CreateParameter<int>("@SortOrder", sortOrder, SqlDbType.Int);
                query.CreateParameter<string>("@ExtendedAttributes", forumExtendedDatas.ToString(), SqlDbType.NText);

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

                query.ExecuteNonQuery();
                return (int)query.Parameters["@ErrorCode"].Value;
            }
        }