예제 #1
0
        protected void ProcessPost()
        {
            string         validateCodeAction = "ReplyTopic";
            MessageDisplay msgDisplay         = CreateMessageDisplay();

            if (CheckValidateCode(validateCodeAction, msgDisplay))
            {
                PostType postType        = (PostType)_Request.Get <int>("viewPointType", Method.Post, 0);
                bool     isReplyPolemize = _Request.Get <bool>("isReplyPolemize", Method.Post, false);

                if (isReplyPolemize && postType == PostType.Normal)
                {
                    msgDisplay.AddError("请选择您的观点!");
                    return;
                }

                string postNickName;
                if (IsLogin == false)
                {
                    if (EnableGuestNickName)
                    {
                        postNickName = _Request.Get("guestNickName", Method.Post, "");
                    }
                    else
                    {
                        postNickName = "";
                    }
                }
                else
                {
                    postNickName = My.Name;
                }
                string subject   = _Request.Get("Subject", Method.Post, string.Empty);
                string content   = _Request.Get("Editor", Method.Post, string.Empty, false);
                string iPAddress = _Request.IpAddress;

                //string enableItems = _Request.Get("enableItem", Method.Post, string.Empty);

                bool enableHTML     = false;
                bool enableMaxCode3 = false;
                if (AllowHtml && AllowMaxcode)
                {
                    enableHTML = _Request.Get <int>("eritoSellect", Method.Post, 0) == 1;

                    if (enableHTML == false)
                    {
                        enableMaxCode3 = true;
                    }
                }
                else if (AllowHtml)
                {
                    enableHTML = true;
                }

                else if (AllowMaxcode)
                {
                    enableMaxCode3 = true;
                }

                bool enableEmoticons   = true; // (enableItems.IndexOf("enableemoticons", StringComparison.OrdinalIgnoreCase) > -1);
                bool enableSignature   = true; //(enableItems.IndexOf("enablesignature", StringComparison.OrdinalIgnoreCase) > -1);
                bool enableReplyNotice = true; //(enableItems.IndexOf("enablereplynotice", StringComparison.OrdinalIgnoreCase) > -1);

                int  postID        = 0;
                bool success       = false;
                bool hasCatchError = false;
                try
                {
                    success = PostBOV5.Instance.ReplyThread(
                        My, ThreadID, postType, 0, subject, content, enableEmoticons, enableHTML, enableMaxCode3, enableSignature
                        , enableReplyNotice, ForumID, postNickName, iPAddress, 0, new AttachmentCollection(), false, out postID);
                }
                catch (Exception ex)
                {
                    msgDisplay.AddException(ex);
                    hasCatchError = true;
                }

                if (hasCatchError == false)
                {
                    if (success == false)
                    {
                        CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            if (error is UnapprovedError)
                            {
                                _Request.Clear();
                                AlertWarning(error.Message);
                            }
                            else
                            {
                                msgDisplay.AddError(error);
                            }
                        });
                    }
                    else
                    {
                        ValidateCodeManager.CreateValidateCodeActionRecode(validateCodeAction);
                        bool returnLastUrl = _Request.Get <int>("tolastpage", Method.Post, 0) == 1;

                        UserBO.Instance.UpdateUserReplyReturnThreadLastPage(My, returnLastUrl);

                        if (IsAjaxRequest)
                        {
                            AlertSuccess("操作成功");//告诉客户端操作成功
                            if (returnLastUrl)
                            {
                                PageNumber = PostBOV5.Instance.GetThread(ThreadID).TotalPages;
                            }
                            else
                            {
                                PageNumber         = PageNumber;
                                m_ThreadLastPostID = postID;
                            }
                            //_Request.Clear();
                        }
                        else
                        {
                            string returnUrl;
                            if (returnLastUrl)
                            {
                                returnUrl = BbsUrlHelper.GetLastThreadUrl(Forum.CodeName, ThreadID, postID, PostBOV5.Instance.GetThread(ThreadID).TotalPages, true);
                            }
                            else
                            {
                                returnUrl = BbsUrlHelper.GetThreadUrl(Forum.CodeName, ThreadID, PostBOV5.Instance.GetThread(ThreadID).ThreadTypeString, PageNumber) + "?lastPostID=" + postID;
                            }
                            Response.Redirect(returnUrl);
                        }
                    }
                }
            }
        }