private void SaveSettings2() { MessageDisplay msgDisplay = CreateMessageDisplay("PostContentLengths", "PostSubjectLengths", "PolemizeValidDays", "PollValidDays", "QuestionValidDays", "RecycleOwnThreadsIntervals", "UpdateThreadSortOrderIntervals", "CreatePostIntervals", "DeleteOwnThreadsIntervals", "AllowFileExtensions", "new_PostContentLengths", "new_PostSubjectLengths", "new_PolemizeValidDays", "new_PollValidDays", "new_QuestionValidDays", "new_RecycleOwnThreadsIntervals", "new_UpdateThreadSortOrderIntervals", "new_CreatePostIntervals", "new_DeleteOwnThreadsIntervals", "new_AllowFileExtensions" , "AllowAttachment", "AllowImageAttachment", "CreatePostAllowAudioTag", "CreatePostAllowEmoticon", "CreatePostAllowFlashTag", "CreatePostAllowHTML" , "CreatePostAllowImageTag", "CreatePostAllowMaxcode", "CreatePostAllowTableTag", "CreatePostAllowUrlTag", "CreatePostAllowVideoTag", "MaxPostAttachmentCount" , "MaxTopicAttachmentCount", "MaxSignleAttachmentSize", "ShowSignatureInThread", "ShowSignatureInPost", "CreateThreadNeedApprove", "ReplyNeedApprove" , "new_AllowAttachment", "new_AllowImageAttachment", "new_CreatePostAllowAudioTag", "new_CreatePostAllowEmoticon", "new_CreatePostAllowFlashTag", "new_CreatePostAllowHTML" , "new_CreatePostAllowImageTag", "new_CreatePostAllowMaxcode", "new_CreatePostAllowTableTag", "new_CreatePostAllowUrlTag", "new_CreatePostAllowVideoTag", "new_MaxPostAttachmentCount" , "new_MaxTopicAttachmentCount", "new_MaxSignleAttachmentSize", "new_ShowSignatureInThread", "new_ShowSignatureInPost", "new_CreateThreadNeedApprove", "new_ReplyNeedApprove" , "UpdateOwnPostIntervals", "new_UpdateOwnPostIntervals" , "EnableSellThread", "new_EnableSellThread" , "EnableSellAttachment", "new_EnableSellAttachment" , "DisplayInList", "new_DisplayInList" , "VisitForum", "new_VisitForum" , "SellAttachmentDays" , "SellThreadDays" , "ReplyReturnThreadLastPage" , "ThreadSortField" ); if (_Request.Get("inheritType", Method.Post, "False").ToLower() == "true")//继承上级 { ForumSettings tempSetting = AllSettings.Current.ForumSettings.Clone(); ForumSettingItemCollection tempItems = new ForumSettingItemCollection(); for (int i = 0; i < tempSetting.Items.Count; i++) { if (tempSetting.Items[i].ForumID == ForumID) { } else { tempItems.Add(tempSetting.Items[i]); } } tempSetting.Items = tempItems; try { if (!SettingManager.SaveSettings(tempSetting)) { CatchError <ErrorInfo>(delegate(ErrorInfo error) { msgDisplay.AddError(error); }); m_Success = false; } else { BbsRouter.JumpToUrl(Request.RawUrl, "success=true"); } } catch (Exception ex) { m_Success = false; msgDisplay.AddError(ex.Message); } return; } ForumSettingItem forumSetItem = new ForumSettingItem(); ExceptableItem_Int32scope int32scope = new ExceptableItem_Int32scope(); ExceptableItem_Second <long> second_long = new ExceptableItem_Second <long>(); ExceptableItem_Second <int> second_int = new ExceptableItem_Second <int>(); ExceptableItem_ExtensionList extensionList = new ExceptableItem_ExtensionList(); forumSetItem.ForumID = ForumID; forumSetItem.PostContentLengths = int32scope.GetExceptable("PostContentLengths", msgDisplay); //GetInt32Exceptable("PostContentLengths",msgDisplay); forumSetItem.PostSubjectLengths = int32scope.GetExceptable("PostSubjectLengths", msgDisplay); //GetInt32Exceptable("PostSubjectLengths",msgDisplay); forumSetItem.PolemizeValidDays = second_long.GetExceptable("PolemizeValidDays", msgDisplay); forumSetItem.PollValidDays = second_long.GetExceptable("PollValidDays", msgDisplay); forumSetItem.QuestionValidDays = second_long.GetExceptable("QuestionValidDays", msgDisplay); forumSetItem.RecycleOwnThreadsIntervals = second_int.GetExceptable("RecycleOwnThreadsIntervals", msgDisplay); forumSetItem.UpdateThreadSortOrderIntervals = second_int.GetExceptable("UpdateThreadSortOrderIntervals", msgDisplay); forumSetItem.UpdateOwnPostIntervals = second_int.GetExceptable("UpdateOwnPostIntervals", msgDisplay); forumSetItem.CreatePostIntervals = second_int.GetExceptable("CreatePostIntervals", msgDisplay); forumSetItem.DeleteOwnThreadsIntervals = second_int.GetExceptable("DeleteOwnThreadsIntervals", msgDisplay); forumSetItem.AllowFileExtensions = extensionList.GetExceptable("AllowFileExtensions", msgDisplay); forumSetItem.AllowAttachment = new ExceptableItem_bool().GetExceptable("AllowAttachment", msgDisplay); forumSetItem.AllowImageAttachment = new ExceptableItem_bool().GetExceptable("AllowImageAttachment", msgDisplay); forumSetItem.CreatePostAllowAudioTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowAudioTag", msgDisplay); forumSetItem.CreatePostAllowEmoticon = new ExceptableItem_bool().GetExceptable("CreatePostAllowEmoticon", msgDisplay); forumSetItem.CreatePostAllowFlashTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowFlashTag", msgDisplay); forumSetItem.CreatePostAllowHTML = new ExceptableItem_bool().GetExceptable("CreatePostAllowHTML", msgDisplay); forumSetItem.CreatePostAllowImageTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowImageTag", msgDisplay); forumSetItem.CreatePostAllowMaxcode = new ExceptableItem_bool().GetExceptable("CreatePostAllowMaxcode", msgDisplay); forumSetItem.CreatePostAllowTableTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowTableTag", msgDisplay); forumSetItem.CreatePostAllowUrlTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowUrlTag", msgDisplay); forumSetItem.CreatePostAllowVideoTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowVideoTag", msgDisplay); forumSetItem.MaxPostAttachmentCount = new ExceptableItem_Int_MoreThenZero().GetExceptable("MaxPostAttachmentCount", msgDisplay); forumSetItem.MaxTopicAttachmentCount = new ExceptableItem_Int_MoreThenZero().GetExceptable("MaxTopicAttachmentCount", msgDisplay); forumSetItem.MaxSignleAttachmentSize = new ExceptableItem_FileSize().GetExceptable("MaxSignleAttachmentSize", msgDisplay); forumSetItem.ShowSignatureInPost = new ExceptableItem_bool().GetExceptable("ShowSignatureInPost", msgDisplay); forumSetItem.ShowSignatureInThread = new ExceptableItem_bool().GetExceptable("ShowSignatureInThread", msgDisplay); forumSetItem.CreateThreadNeedApprove = new ExceptableItem_bool().GetExceptable("CreateThreadNeedApprove", msgDisplay); forumSetItem.ReplyNeedApprove = new ExceptableItem_bool().GetExceptable("ReplyNeedApprove", msgDisplay); forumSetItem.EnableSellThread = new ExceptableItem_bool().GetExceptable("EnableSellThread", msgDisplay); forumSetItem.EnableSellAttachment = new ExceptableItem_bool().GetExceptable("EnableSellAttachment", msgDisplay); forumSetItem.EnableHiddenTag = _Request.Get <bool>("enableHiddenTag", Method.Post, true); forumSetItem.EnableThreadRank = _Request.Get <bool>("EnableThreadRank", Method.Post, true); forumSetItem.DefaultThreadSortField = _Request.Get <ThreadSortField>("ThreadSortField", Method.Post, ThreadSortField.LastReplyDate); ThreadSortField oldThreadSortField = ForumSetting.DefaultThreadSortField; ThreadSortField newThreadSortField = forumSetItem.DefaultThreadSortField; forumSetItem.AllowGuestVisitForum = _Request.Get <bool>("AllowGuestVisitForum", Method.Post, true); forumSetItem.DisplayInListForGuest = _Request.Get <bool>("DisplayInListForGuest", Method.Post, true); forumSetItem.VisitForum = new ExceptableItem_bool().GetExceptable("VisitForum", msgDisplay); forumSetItem.DisplayInList = new ExceptableItem_bool().GetExceptable("DisplayInList", msgDisplay); forumSetItem.SellThreadDays = GetSeconds("SellThreadDays", msgDisplay); forumSetItem.SellAttachmentDays = GetSeconds("SellAttachmentDays", msgDisplay); forumSetItem.ReplyReturnThreadLastPage = _Request.Get <bool>("ReplyReturnThreadLastPage", Method.Post, false); if (msgDisplay.HasAnyError()) { m_Success = false; return; } ForumSettings settings = AllSettings.Current.ForumSettings.Clone(); ForumSettingItemCollection items = new ForumSettingItemCollection(); bool hasAdd = false; bool hasTopItem = false;//是否有ForumID为0的设置 foreach (ForumSettingItem item in settings.Items) { if (item.ForumID == forumSetItem.ForumID) { items.Add(forumSetItem); hasAdd = true; } else { ProcessApplyAllForumSetting(item, forumSetItem); items.Add(item); } if (item.ForumID == 0) { hasTopItem = true; } } if (hasAdd == false) { items.Add(forumSetItem); } if (hasTopItem == false)//如果没有 加入 { ForumSettingItem tempItem = new ForumSettingItem(); ProcessApplyAllForumSetting(tempItem, forumSetItem); items.Add(tempItem); } settings.Items = items; try { using (new ErrorScope()) { bool success = SettingManager.SaveSettings(settings); if (!success) { CatchError <ErrorInfo>(delegate(ErrorInfo error) { msgDisplay.AddError(error); }); m_Success = false; } else { if (_Request.Get <bool>("ThreadSortField_aplyallnode", Method.Post, false)) { ThreadCachePool.ClearAllCache(); } else if (oldThreadSortField != newThreadSortField) { ThreadCachePool.ClearAllCache(); } string rawUrl = Request.RawUrl; BbsRouter.JumpToUrl(rawUrl, "success=true"); } } } catch (Exception ex) { m_Success = false; msgDisplay.AddError(ex.Message); } }
private void SaveSettings2() { MessageDisplay msgDisplay = CreateMessageDisplay("PostContentLengths", "PostSubjectLengths", "PolemizeValidDays", "PollValidDays", "QuestionValidDays", "RecycleOwnThreadsIntervals", "UpdateThreadSortOrderIntervals", "CreatePostIntervals", "DeleteOwnThreadsIntervals", "AllowFileExtensions", "new_PostContentLengths", "new_PostSubjectLengths", "new_PolemizeValidDays", "new_PollValidDays", "new_QuestionValidDays", "new_RecycleOwnThreadsIntervals", "new_UpdateThreadSortOrderIntervals", "new_CreatePostIntervals", "new_DeleteOwnThreadsIntervals", "new_AllowFileExtensions" , "AllowAttachment", "AllowImageAttachment", "CreatePostAllowAudioTag", "CreatePostAllowEmoticon", "CreatePostAllowFlashTag", "CreatePostAllowHTML" , "CreatePostAllowImageTag", "CreatePostAllowMaxcode", "CreatePostAllowTableTag", "CreatePostAllowUrlTag", "CreatePostAllowVideoTag", "MaxPostAttachmentCount" , "MaxTopicAttachmentCount", "MaxSignleAttachmentSize", "ShowSignatureInThread", "ShowSignatureInPost", "CreateThreadNeedApprove", "ReplyNeedApprove" , "new_AllowAttachment", "new_AllowImageAttachment", "new_CreatePostAllowAudioTag", "new_CreatePostAllowEmoticon", "new_CreatePostAllowFlashTag", "new_CreatePostAllowHTML" , "new_CreatePostAllowImageTag", "new_CreatePostAllowMaxcode", "new_CreatePostAllowTableTag", "new_CreatePostAllowUrlTag", "new_CreatePostAllowVideoTag", "new_MaxPostAttachmentCount" , "new_MaxTopicAttachmentCount", "new_MaxSignleAttachmentSize", "new_ShowSignatureInThread", "new_ShowSignatureInPost", "new_CreateThreadNeedApprove", "new_ReplyNeedApprove" , "UpdateOwnPostIntervals", "new_UpdateOwnPostIntervals" , "EnableSellThread", "new_EnableSellThread" , "EnableSellAttachment", "new_EnableSellAttachment" , "DisplayInList", "new_DisplayInList" , "VisitForum", "new_VisitForum" , "SellAttachmentDays" , "SellThreadDays" , "ReplyReturnThreadLastPage" , "ThreadSortField" ); if (_Request.Get("inheritType", Method.Post, "False").ToLower() == "true")//继承上级 { ForumSettings tempSetting = AllSettings.Current.ForumSettings.Clone(); ForumSettingItemCollection tempItems = new ForumSettingItemCollection(); for (int i = 0; i < tempSetting.Items.Count; i++) { if (tempSetting.Items[i].ForumID == ForumID) { } else tempItems.Add(tempSetting.Items[i]); } tempSetting.Items = tempItems; try { if (!SettingManager.SaveSettings(tempSetting)) { CatchError<ErrorInfo>(delegate(ErrorInfo error) { msgDisplay.AddError(error); }); m_Success = false; } else { BbsRouter.JumpToUrl(Request.RawUrl, "success=true"); } } catch (Exception ex) { m_Success = false; msgDisplay.AddError(ex.Message); } return; } ForumSettingItem forumSetItem = new ForumSettingItem(); ExceptableItem_Int32scope int32scope = new ExceptableItem_Int32scope(); ExceptableItem_Second<long> second_long = new ExceptableItem_Second<long>(); ExceptableItem_Second<int> second_int = new ExceptableItem_Second<int>(); ExceptableItem_ExtensionList extensionList = new ExceptableItem_ExtensionList(); forumSetItem.ForumID = ForumID; forumSetItem.PostContentLengths = int32scope.GetExceptable("PostContentLengths", msgDisplay); //GetInt32Exceptable("PostContentLengths",msgDisplay); forumSetItem.PostSubjectLengths = int32scope.GetExceptable("PostSubjectLengths", msgDisplay);//GetInt32Exceptable("PostSubjectLengths",msgDisplay); forumSetItem.PolemizeValidDays = second_long.GetExceptable("PolemizeValidDays",msgDisplay); forumSetItem.PollValidDays = second_long.GetExceptable("PollValidDays", msgDisplay); forumSetItem.QuestionValidDays = second_long.GetExceptable("QuestionValidDays", msgDisplay); forumSetItem.RecycleOwnThreadsIntervals = second_int.GetExceptable("RecycleOwnThreadsIntervals", msgDisplay); forumSetItem.UpdateThreadSortOrderIntervals = second_int.GetExceptable("UpdateThreadSortOrderIntervals", msgDisplay); forumSetItem.UpdateOwnPostIntervals = second_int.GetExceptable("UpdateOwnPostIntervals", msgDisplay); forumSetItem.CreatePostIntervals = second_int.GetExceptable("CreatePostIntervals", msgDisplay); forumSetItem.DeleteOwnThreadsIntervals = second_int.GetExceptable("DeleteOwnThreadsIntervals", msgDisplay); forumSetItem.AllowFileExtensions = extensionList.GetExceptable("AllowFileExtensions", msgDisplay); forumSetItem.AllowAttachment = new ExceptableItem_bool().GetExceptable("AllowAttachment", msgDisplay); forumSetItem.AllowImageAttachment = new ExceptableItem_bool().GetExceptable("AllowImageAttachment", msgDisplay); forumSetItem.CreatePostAllowAudioTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowAudioTag", msgDisplay); forumSetItem.CreatePostAllowEmoticon = new ExceptableItem_bool().GetExceptable("CreatePostAllowEmoticon", msgDisplay); forumSetItem.CreatePostAllowFlashTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowFlashTag", msgDisplay); forumSetItem.CreatePostAllowHTML = new ExceptableItem_bool().GetExceptable("CreatePostAllowHTML", msgDisplay); forumSetItem.CreatePostAllowImageTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowImageTag", msgDisplay); forumSetItem.CreatePostAllowMaxcode = new ExceptableItem_bool().GetExceptable("CreatePostAllowMaxcode", msgDisplay); forumSetItem.CreatePostAllowTableTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowTableTag", msgDisplay); forumSetItem.CreatePostAllowUrlTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowUrlTag", msgDisplay); forumSetItem.CreatePostAllowVideoTag = new ExceptableItem_bool().GetExceptable("CreatePostAllowVideoTag", msgDisplay); forumSetItem.MaxPostAttachmentCount = new ExceptableItem_Int_MoreThenZero().GetExceptable("MaxPostAttachmentCount", msgDisplay); forumSetItem.MaxTopicAttachmentCount = new ExceptableItem_Int_MoreThenZero().GetExceptable("MaxTopicAttachmentCount", msgDisplay); forumSetItem.MaxSignleAttachmentSize = new ExceptableItem_FileSize().GetExceptable("MaxSignleAttachmentSize", msgDisplay); forumSetItem.ShowSignatureInPost = new ExceptableItem_bool().GetExceptable("ShowSignatureInPost",msgDisplay); forumSetItem.ShowSignatureInThread = new ExceptableItem_bool().GetExceptable("ShowSignatureInThread", msgDisplay); forumSetItem.CreateThreadNeedApprove = new ExceptableItem_bool().GetExceptable("CreateThreadNeedApprove", msgDisplay); forumSetItem.ReplyNeedApprove = new ExceptableItem_bool().GetExceptable("ReplyNeedApprove", msgDisplay); forumSetItem.EnableSellThread = new ExceptableItem_bool().GetExceptable("EnableSellThread", msgDisplay); forumSetItem.EnableSellAttachment = new ExceptableItem_bool().GetExceptable("EnableSellAttachment", msgDisplay); forumSetItem.EnableHiddenTag = _Request.Get<bool>("enableHiddenTag", Method.Post, true); forumSetItem.EnableThreadRank = _Request.Get<bool>("EnableThreadRank", Method.Post, true); forumSetItem.DefaultThreadSortField = _Request.Get<ThreadSortField>("ThreadSortField", Method.Post, ThreadSortField.LastReplyDate); ThreadSortField oldThreadSortField = ForumSetting.DefaultThreadSortField; ThreadSortField newThreadSortField = forumSetItem.DefaultThreadSortField; forumSetItem.AllowGuestVisitForum = _Request.Get<bool>("AllowGuestVisitForum", Method.Post, true); forumSetItem.DisplayInListForGuest = _Request.Get<bool>("DisplayInListForGuest", Method.Post, true); forumSetItem.VisitForum = new ExceptableItem_bool().GetExceptable("VisitForum", msgDisplay); forumSetItem.DisplayInList = new ExceptableItem_bool().GetExceptable("DisplayInList", msgDisplay); forumSetItem.SellThreadDays = GetSeconds("SellThreadDays", msgDisplay); forumSetItem.SellAttachmentDays = GetSeconds("SellAttachmentDays", msgDisplay); forumSetItem.ReplyReturnThreadLastPage = _Request.Get<bool>("ReplyReturnThreadLastPage", Method.Post, false); if (msgDisplay.HasAnyError()) { m_Success = false; return; } ForumSettings settings = AllSettings.Current.ForumSettings.Clone(); ForumSettingItemCollection items = new ForumSettingItemCollection(); bool hasAdd = false; bool hasTopItem = false;//是否有ForumID为0的设置 foreach (ForumSettingItem item in settings.Items) { if (item.ForumID == forumSetItem.ForumID) { items.Add(forumSetItem); hasAdd = true; } else { ProcessApplyAllForumSetting(item,forumSetItem); items.Add(item); } if (item.ForumID == 0) hasTopItem = true; } if (hasAdd == false) items.Add(forumSetItem); if (hasTopItem == false)//如果没有 加入 { ForumSettingItem tempItem = new ForumSettingItem(); ProcessApplyAllForumSetting(tempItem, forumSetItem); items.Add(tempItem); } settings.Items = items; try { using (new ErrorScope()) { bool success = SettingManager.SaveSettings(settings); if (!success) { CatchError<ErrorInfo>(delegate(ErrorInfo error) { msgDisplay.AddError(error); }); m_Success = false; } else { if (_Request.Get<bool>("ThreadSortField_aplyallnode", Method.Post, false)) { ThreadCachePool.ClearAllCache(); } else if (oldThreadSortField != newThreadSortField) { ThreadCachePool.ClearAllCache(); } string rawUrl = Request.RawUrl; BbsRouter.JumpToUrl(rawUrl, "success=true"); } } } catch (Exception ex) { m_Success = false; msgDisplay.AddError(ex.Message); } }