public void SetAjaxResult(JsonBuilder json) { m_AjaxResult = json.ToString(); }
public static string BuildJsonObject(object obj) { return(JsonBuilder.GetJson(obj, null)); }
public static string BuildJsonObject(object obj, params string[] excludePropertys) { return(JsonBuilder.GetJson(obj, excludePropertys)); }
public void ProcessPost() { m_Action = _Request.Get("postaction",Method.Post,string.Empty); string validateCodeAction; MessageDisplay msgDisplay = CreateMessageDisplay(); if (IsReply || IsEditPost) validateCodeAction = "ReplyTopic"; else validateCodeAction = "CreateTopic"; if (CheckValidateCode(validateCodeAction, msgDisplay)) { string subject = _Request.Get("subject", Method.Post, string.Empty); string content = _Request.Get("editor_content", Method.Post, string.Empty, false); int iconID = _Request.Get<int>("posticon", Method.Post, 0); string ipAddress = _Request.IpAddress; string idString = _Request.Get("enableitem", Method.Post, string.Empty).ToLower(); //---------如果是以新的UBB方式提交---------- string formatMode = _Request.Get("editorallowtype", Method.Post, "ubb").ToLower(); bool enableHTML = false; bool enableMaxCode3 = false; if (AllowHtml && AllowMaxcode) { enableHTML = StringUtil.EqualsIgnoreCase(_Request.Get("contentformat", Method.Post, string.Empty), "enablehtml"); if (enableHTML == false) enableMaxCode3 = true; } else if (AllowHtml) enableHTML = true; else if (AllowMaxcode) enableMaxCode3 = true; bool enableEmoticons = (idString.IndexOf("enableemoticons") > -1); bool enableSignature = (idString.IndexOf("enablesignature") > -1); bool enableReplyNotice = (idString.IndexOf("enablereplynotice") > -1); AttachmentCollection attachments = new AttachmentCollection(); List<int> tempUploadFileIds = new List<int>(); string postUsername = null; int postUserID; if (IsEditPost || IsEditThread) { postUserID = 0; } else { postUserID = MyUserID; if(IsLogin) postUsername = My.Name; else { if (EnableGuestNickName) postUsername = _Request.Get("guestnickname", Method.Post, string.Empty); else postUsername = ""; } } //string attachIdsText = _Request.Get("attachIds", Method.Post, string.Empty, false); //if (string.IsNullOrEmpty(attachIdsText) == false) //{ // int[] attachIds = StringUtil.Split<int>(attachIdsText, ','); // GetAttachments(attachIds, "0", postUserID, msgDisplay, ref attachments); //} //string diskIdsText = _Request.Get("diskFileIDs", Method.Post, string.Empty, false); //if (string.IsNullOrEmpty(diskIdsText) == false) //{ // int[] diskFileIDs = StringUtil.Split<int>(diskIdsText, ','); //} GetAttachments(postUserID, msgDisplay, ref attachments); if (msgDisplay.HasAnyError()) return; bool success = false; try { int threadID = ThreadID, postID = PostID; if (IsCreateThread) { #region bool isLocked = _Request.Get<bool>("cbLockThread", Method.Post, false); int threadCatalogID = _Request.Get<int>("threadCatalogs", Method.Post, 0); if (Action == "thread") { int price = _Request.Get<int>("price", Method.Post, 0); success = PostBOV5.Instance.CreateThread(My, false, enableEmoticons, ForumID, threadCatalogID, iconID, subject, string.Empty, price , postUsername, isLocked, false, content, enableHTML, enableMaxCode3, enableSignature, enableReplyNotice, ipAddress , attachments, out threadID, out postID); } else if (Action == "poll") { bool alwaysEyeable = !_Request.IsChecked("cbNoEyeable", Method.Post, false); int multiple = _Request.Get<int>("voteMultiple", Method.Post, 0); TimeSpan expiresDate = GetExpiresDate(ThreadType.Poll); string pollItemString = _Request.Get("vote", Method.Post, string.Empty).Trim(); success = PostBOV5.Instance.CreatePoll(pollItemString, multiple, alwaysEyeable, expiresDate , My, false, enableEmoticons, ForumID, threadCatalogID, iconID, subject, string.Empty , postUsername, isLocked, false, content, enableHTML, enableMaxCode3, enableSignature, enableReplyNotice, ipAddress , attachments, out threadID, out postID); } else if (Action == "question") { int reward = _Request.Get<int>("reward", Method.Post, 0); int rewardCount = _Request.Get<int>("rewardCount", Method.Post, 0); bool alwaysEyeable = !_Request.IsChecked("notEyeable", Method.Post, true); TimeSpan expiresDate = GetExpiresDate(ThreadType.Question); success = PostBOV5.Instance.CreateQuestion(reward, rewardCount, alwaysEyeable, expiresDate , My, false, enableEmoticons, ForumID, threadCatalogID, iconID, subject, string.Empty , postUsername, isLocked, false, content, enableHTML, enableMaxCode3, enableSignature, enableReplyNotice, ipAddress , attachments, out threadID, out postID); } else if (Action == "polemize") { string agreeViewPoint = _Request.Get("AgreeViewPoint", Method.Post, string.Empty); string againstViewPoint = _Request.Get("AgainstViewPoint", Method.Post, string.Empty); TimeSpan expiresDate = GetExpiresDate(ThreadType.Polemize); success = PostBOV5.Instance.CreatePolemize(agreeViewPoint, againstViewPoint, expiresDate , My, false, enableEmoticons, ForumID, threadCatalogID, iconID, subject, string.Empty , postUsername, isLocked, false, content, enableHTML, enableMaxCode3, enableSignature, enableReplyNotice, ipAddress , attachments, out threadID, out postID); } if (success) { bool sticky = _Request.Get<bool>("cbStickyThread", Method.Post, false); bool globalStickyThread = _Request.Get<bool>("cbGlobalStickyThread", Method.Post, false); int[] threadIDs = new int[] { threadID }; if (globalStickyThread) { PostBOV5.Instance.SetThreadsStickyStatus(My, ForumID, null, threadIDs, ThreadStatus.GlobalSticky, null, false, false, true, ""); } else if (sticky) { PostBOV5.Instance.SetThreadsStickyStatus(My, ForumID, null, threadIDs, ThreadStatus.Sticky, null, false, false, true, ""); } if (isLocked)//记录日志 { string threadLog; PostBOV5.Instance.CreateThreadManageLog(My, _Request.IpAddress, ModeratorCenterAction.LockThread, new int[] { MyUserID }, ForumID , new int[] { threadID }, new string[] { subject }, string.Empty, true, out threadLog); BasicThread thread = ThreadCachePool.GetThread(threadID); if (string.IsNullOrEmpty(threadLog) == false && thread!=null) { thread.ThreadLog = threadLog; } } } #endregion } else if (IsEditThread || IsEditPost) { int lastEditorID = MyUserID; string lastEditor = My.Username; #region bool recodeEditLog = _Request.Get("recodeEditLog", Method.Post, "true").ToLower() == "true"; if (!recodeEditLog && HasEditPermission) { lastEditorID = 0; lastEditor = string.Empty; } if (IsEditThread) { int threadCatalogID = _Request.Get<int>("threadCatalogs", Method.Post, 0); int price = _Request.Get<int>("price", Method.Post, 0); success = PostBOV5.Instance.UpdateThread(My, ThreadID, threadCatalogID, iconID, subject, price, lastEditorID, lastEditor , content, enableEmoticons, enableHTML, enableMaxCode3, enableSignature, enableReplyNotice, attachments, false ); } else { success = PostBOV5.Instance.UpdatePost(My, PostID, iconID, subject, lastEditorID, lastEditor, content, enableEmoticons, enableHTML , enableMaxCode3, enableSignature, enableReplyNotice, attachments, false); } #endregion } else //回复 { PostType postType = (PostType)_Request.Get<int>("viewPointType", Method.Post, 0); int parentID = PostID; success = PostBOV5.Instance.ReplyThread(My, ThreadID, postType, iconID, subject, content, enableEmoticons , enableHTML, enableMaxCode3, enableSignature, enableReplyNotice, ForumID, postUsername, ipAddress, parentID , attachments, false, out postID); } if (success == false) { CatchError<ErrorInfo>(delegate(ErrorInfo error) { if (error is UnapprovedError) { //AlertWarning(""); //ShowWarning(error.Message, BbsUrlHelper.GetForumUrl(Forum.CodeName)); if (IsAjaxRequest) { m_Message = error.Message; m_JumpLinks.Add("返回列表页", BbsUrlHelper.GetForumUrl(Forum.CodeName)); m_IsPostAlert = true; PostReturnUrl = BbsUrlHelper.GetForumUrl(Forum.CodeName); } else { ShowWarning(error.Message, BbsUrlHelper.GetForumUrl(Forum.CodeName)); } //NameObjectCollection paramList = new NameObjectCollection(); //paramList.Add("IsPostSuccess", false); //paramList.Add("IsPostAlert", true); //paramList.Add("PostMessage", m_Message); //paramList.Add("JumpLinks", new JumpLinkCollection()); //paramList.Add("PostReturnUrl", PostReturnUrl); //Display("~/max-templates/default/_part/post_success.aspx?_max_ajaxids_=post_success", true, paramList); } else msgDisplay.AddError(error); }); } else { if (IsEditPost == false && IsEditThread == false)//编辑的时候 不记录 ValidateCodeManager.CreateValidateCodeActionRecode(validateCodeAction); string returnUrl = null; if (Type != "") { SystemForum sf; if (string.Compare(Type, SystemForum.RecycleBin.ToString(), true) == 0) returnUrl = UrlHelper.GetRecycledThreadsUrl(CodeName); else if (string.Compare(Type, SystemForum.UnapprovePosts.ToString(), true) == 0) returnUrl = UrlHelper.GetUnapprovedPostsUrl(CodeName); else if (string.Compare(Type, SystemForum.UnapproveThreads.ToString(), true) == 0) returnUrl = UrlHelper.GetUnapprovedThreadsUrl(CodeName); else { returnUrl = BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, 1); } } BasicThread thread = PostBOV5.Instance.GetThread(threadID); int threadPages = thread.TotalPages; if (IsReply) { bool returnLastUrl = _Request.Get<int>("tolastpage", Method.Post, 0) == 1; int returnPage = _Request.Get<int>("page", Method.Get, 1); string lastUrl = BbsUrlHelper.GetLastThreadUrl(Forum.CodeName, threadID, thread.ThreadTypeString, postID, threadPages, true); returnUrl = BbsUrlHelper.GetThreadUrl(Forum.CodeName, threadID, thread.ThreadTypeString, returnPage); if (returnLastUrl) { m_Message = "回复成功,现在将转入该主题的最后一页"; m_JumpLinks.Add("如果没有自动跳转,请点此处", lastUrl); m_JumpLinks.Add("如果要转入该主题的第" + returnPage + "页,请点此处", returnUrl); returnUrl = lastUrl; } else { m_Message = "回复成功,现在将转入该主题的第" + returnPage + "页"; m_JumpLinks.Add("如果没有自动跳转,请点此处", returnUrl); m_JumpLinks.Add("如果要转入该主题的最后一页,请点此处", lastUrl); } } else if (IsCreateThread) { returnUrl = BbsUrlHelper.GetThreadUrl(Forum.CodeName, threadID, thread.ThreadTypeString, 1); } else { if (Type == "") returnUrl = BbsUrlHelper.GetThreadUrl(Forum.CodeName, threadID, thread.ThreadTypeString, 1); } JsonBuilder json = new JsonBuilder(); json.Set("issuccess", true); PostReturnUrl = returnUrl; if (IsReply == false) { m_JumpLinks.Add("如果没有自动跳转,请点此处", returnUrl); m_Message = "操作成功,现在将转入查看主题页"; } m_JumpLinks.Add("如果要返回主题列表,请点击此处", BbsUrlHelper.GetForumUrl(Forum.CodeName)); m_IsPostSuccess = true; //ShowSuccess("操作成功,现在将转入查看主题页", links); if (IsAjaxRequest == false) { ShowSuccess(m_Message, m_JumpLinks); } else { AjaxPanelContext.SetAjaxResult(json); } } } catch (Exception ex) { msgDisplay.AddException(ex); } } }