private void DisplayCategory() { Controls.Add(new LiteralControl("<table width=100% cellspacing=0 cellpadding=3>")); Controls.Add(new LiteralControl("<tr>")); Controls.Add(new LiteralControl("<td width=1% class=\"ms-ToolPaneTitle\"> </td>")); Controls.Add(new LiteralControl("<td align=left class=\"ms-ToolPaneTitle\">Forum</td>")); Controls.Add(new LiteralControl("<td align=center width=7% class=\"ms-ToolPaneTitle\">Topics</td>")); Controls.Add(new LiteralControl("<td align=center width=7% class=\"ms-ToolPaneTitle\">Posts</td>")); Controls.Add(new LiteralControl("<td align=center width=25% class=\"ms-ToolPaneTitle\">Last Post</td>")); Controls.Add(new LiteralControl("</tr>")); UserSession session = GetSession(); CategoryCollection categories = session.UserCategories; foreach (Category category in categories) { string categoryName = category.Name; int categoryId = category.Id; if (category.HasAccess(ForumApplication.Instance.CurrentUser, Permission.Rights.Read)) { Controls.Add(new LiteralControl("<tr>")); string link = ForumApplication.Instance.GetLink(SharePointForumControls.ViewForums, "category={0}", categoryId); Controls.Add(new LiteralControl(string.Format("<td class=\"ms-TPHeader\" colspan=5><a href=\"{0}\"><strong>{1}</strong></a></td>", link, categoryName))); Controls.Add(new LiteralControl("</tr>")); ForumCollection forumCollection = category.Forums; if (forumCollection.Count > 0) { DisplayForum(forumCollection); } } } Controls.Add(new LiteralControl("</table>")); }
/// <summary> /// 返回所有子版块包括下下级 /// </summary> /// <param name="forumID"></param> /// <returns></returns> public ForumCollection GetAllSubForums(int forumID) { ForumCollection forums = new ForumCollection(); GetChildForums(forumID, ref forums); return(forums); }
public void BindData() { string prefix = "--"; ddlForums.Items.Clear(); ForumGroupCollection forumGroups = ForumManager.GetAllForumGroups(); foreach (ForumGroup forumGroup in forumGroups) { ListItem forumGroupItem = new ListItem(forumGroup.Name, "0"); this.ddlForums.Items.Add(forumGroupItem); ForumCollection forums = forumGroup.Forums; foreach (Forum forum in forums) { ListItem forumItem = new ListItem(prefix + forum.Name, forum.ForumID.ToString()); this.ddlForums.Items.Add(forumItem); if (forum.ForumID == this.selectedForumId) { forumItem.Selected = true; } } } this.ddlForums.DataBind(); }
public ForumCollection<Forum> GetForums(Boolean active) { ForumCollection<Forum> _coll = new ForumCollection<Forum>(this.ConnectionString); ArgumentsList _arg = new ArgumentsList(new ArgumentsListItem("Active", active.ToString())); _coll.LitePopulate(_arg, false, null); return _coll; }
/// <summary> /// Gets all forum entities which belong to a given section. /// </summary> /// <param name="sectionID">The section ID from which forums should be retrieved</param> /// <returns>Entity collection with entities for all forums in this section sorted alphabitacally</returns> public static ForumCollection GetAllForumsInSection(int sectionID) { var q = new QueryFactory().Forum .Where(ForumFields.SectionID == sectionID) .OrderBy(ForumFields.OrderNo.Ascending(), ForumFields.ForumName.Ascending()); var toReturn = new ForumCollection(); toReturn.GetMulti(q); return(toReturn); }
internal void ClearModeratorCache() { s_AllModerators = null; ForumCollection forums = this.GetAllForums(); foreach (Forum forum in forums) { forum.ClearModeratorCache(); } }
/// <summary> /// 清除屏蔽用户的缓存 /// </summary> internal void ClearBannedUserCache() { s_AllBannedUsers = null; ForumCollection forums = ForumBO.Instance.GetAllForums(); foreach (Forum forum in forums) { forum.ClearBannedUserCache(); } }
private void GetChildForums(int forumID, ref ForumCollection forums) { foreach (Forum forum in GetAllForums()) { if (forum.ParentID == forumID) { forums.Add(forum); GetChildForums(forum.ForumID, ref forums); } } }
/// <summary> /// Updates the user/forum/thread statistics after a message insert. Also makes sure if the thread isn't in a queue and the forum has a default support /// queue that the thread is added to that queue /// </summary> /// <param name="threadID">The thread ID.</param> /// <param name="userID">The user ID.</param> /// <param name="transactionToUse">The transaction to use.</param> /// <param name="postingDate">The posting date.</param> /// <param name="addToQueueIfRequired">if set to true, the thread will be added to the default queue of the forum the thread is in, if the forum /// has a default support queue and the thread isn't already in a queue.</param> /// <remarks>Leaves the passed in transaction open, so it doesn't commit/rollback, it just performs a set of actions inside the /// passed in transaction.</remarks> internal static void UpdateStatisticsAfterMessageInsert(int threadID, int userID, Transaction transactionToUse, DateTime postingDate, bool addToQueueIfRequired, bool subscribeToThread) { // user statistics UserEntity userUpdater = new UserEntity(); // set the amountofpostings field to an expression so it will be increased with 1. userUpdater.Fields[(int)UserFieldIndex.AmountOfPostings].ExpressionToApply = (UserFields.AmountOfPostings + 1); UserCollection users = new UserCollection(); transactionToUse.Add(users); users.UpdateMulti(userUpdater, (UserFields.UserID == userID)); // update directly on the DB. // thread statistics ThreadEntity threadUpdater = new ThreadEntity(); threadUpdater.ThreadLastPostingDate = postingDate; threadUpdater.MarkedAsDone = false; ThreadCollection threads = new ThreadCollection(); transactionToUse.Add(threads); threads.UpdateMulti(threadUpdater, (ThreadFields.ThreadID == threadID)); // forum statistics. Load the forum from the DB, as we need it later on. Use a fieldcompareset predicate to fetch the forum as we don't know the // forumID as we haven't fetched the thread ForumCollection forums = new ForumCollection(); transactionToUse.Add(forums); // use a fieldcompare set predicate to select the forumid based on the thread. This filter is equal to // WHERE ForumID == (SELECT ForumID FROM Thread WHERE ThreadID=@ThreadID) var forumFilter = new FieldCompareSetPredicate( ForumFields.ForumID, ThreadFields.ForumID, SetOperator.Equal, (ThreadFields.ThreadID == threadID)); forums.GetMulti(forumFilter); ForumEntity containingForum = null; if(forums.Count>0) { // forum found. There's just one. containingForum = forums[0]; containingForum.ForumLastPostingDate = postingDate; // save the forum. Just save the collection forums.SaveMulti(); } if(addToQueueIfRequired) { // If the thread involved isn't in a queue, place it in the default queue of the forum (if applicable) SupportQueueEntity containingQueue = SupportQueueGuiHelper.GetQueueOfThread(threadID, transactionToUse); if((containingQueue == null) && (containingForum != null) && (containingForum.DefaultSupportQueueID.HasValue)) { // not in a queue, and the forum has a default queue. Add the thread to the queue of the forum SupportQueueManager.AddThreadToQueue(threadID, containingForum.DefaultSupportQueueID.Value, userID, transactionToUse); } } //subscribe to thread if indicated if(subscribeToThread) { UserManager.AddThreadToSubscriptions(threadID, userID, transactionToUse); } }
public ForumCollection FindByCategoryId(int id) { SharePointListDescriptor descriptor = Provider.GetListItemsByField(ForumConstants.Lists_Forums, "CategoryID", id.ToString()); ForumCollection forumCollection = new ForumCollection(); foreach (SharePointListItem listItem in descriptor.SharePointListItems) { forumCollection.Add(ForumMapper.CreateDomainObject(listItem)); } return(forumCollection); }
public ForumCollection GetAll() { SharePointListDescriptor descriptor = Provider.GetAllListItems(ForumConstants.Lists_Forums); ForumCollection forumCollection = new ForumCollection(); foreach (SharePointListItem listItem in descriptor.SharePointListItems) { forumCollection.Add(ForumMapper.CreateDomainObject(listItem)); } return(forumCollection); }
private static ForumCollection DBMapping(DBForumCollection dbCollection) { if (dbCollection == null) return null; ForumCollection collection = new ForumCollection(); foreach (DBForum dbItem in dbCollection) { Forum item = DBMapping(dbItem); collection.Add(item); } return collection; }
/// <summary> /// 筛选出所有符合条件的版块 /// </summary> /// <param name="filter"></param> /// <returns></returns> internal ForumCollection GetForums(GetForumFilter filter) { ForumCollection result = new ForumCollection(); foreach (Forum forum in GetAllForums()) { if (filter(forum)) { result.Add(forum); } } return(result); }
private void GetParentForum(int parentID, ref ForumCollection forums) { Forum forum = GetForum(parentID); if (forum != null) { forums.Insert(0, forum); if (forum.ParentID != 0) { GetParentForum(forum.ParentID, ref forums); } } }
//===================== private void GetSubForums(string separator, Forum forum, GetForumFilter filter, ref ForumCollection forums, ref List <string> forumSeparators) { ForumCollection childForums = forum.AllSubForums; foreach (Forum tempForum in childForums) { if (filter == null || filter(tempForum)) { forums.Add(tempForum); forumSeparators.Add(separator); GetSubForums(separator + separator, tempForum, filter, ref forums, ref forumSeparators); } } }
private static void InitForumLockers() { Dictionary <int, object> forumLockers = new Dictionary <int, object>(); ForumCollection forums = ForumBO.Instance.GetAllForums(); for (int i = 0; i < forums.Count; i++) { forumLockers.Add(forums[i].ForumID, new object()); } forumLockers.Add(0, new object()); s_ForumLockers = forumLockers; }
protected string GetForumPath(int forumID) { StringBuffer sb = new StringBuffer(); ForumCollection parentForums = ForumBO.Instance.GetAllParentForums(forumID); foreach (Forum f in parentForums) { sb += f.ForumID; sb += "-"; } sb += forumID; return(sb.ToString()); }
//public void ClearGuestCache() //{ // s_AllForumsForGuestList = null; // s_CategoriesForGuestList = null; // s_ForumIdsForGuestVisit = null; // s_ForumIdsForGuestVisit_Cached = false; //} public bool ResetYestodayPostsAndDayMaxPosts() { ForumCollection forums = GetAllForums(); //设置昨天最高发帖数 int yestodayPosts = 0; int yestodayTopics = 0; foreach (Forum forum in forums) { yestodayPosts += forum.TodayPosts; yestodayTopics += forum.TodayThreads; } return(VarsManager.UpdateYestodayPostAndMaxPost(yestodayPosts, yestodayTopics, DateTimeUtil.Now.AddDays(-1))); }
/// <summary> /// /// </summary> /// <param name="separator"></param> /// <param name="filter">如果为null则返回所有版块</param> /// <param name="forums"></param> /// <param name="forumSeparators"></param> public void GetTreeForums(string separator, GetForumFilter filter, out ForumCollection forums, out List <string> forumSeparators) { ForumCollection rootForums = GetCategories(); forums = new ForumCollection(); forumSeparators = new List <string>(); foreach (Forum forum in rootForums) { if (filter == null || filter(forum)) { forums.Add(forum); forumSeparators.Add(string.Empty); GetSubForums(separator, forum, filter, ref forums, ref forumSeparators); } } }
private void RenderForumsMenu() { ForumCollection forums = DataProvider.Instance().GetForumsByForumGroupId(Forum.ForumGroupId, Context.User.Identity.Name); forums.Sort(); string forumMenu = "<div class='popupMenu' style='position: absolute; display: none;' id='" + this.UniqueID + ":forumMenu'>"; forumMenu += "<div class='popupTitle'>Forums</div>"; for (int i = 0; i < forums.Count; i++) { forumMenu += "<div class='popupItem'> <a href='" + UrlShowForum + ((Forum)forums[i]).ForumID + "'>" + ((Forum)forums[i]).Name + "</a> </div>"; } forumMenu += "</div>"; Page.RegisterClientScriptBlock(this.UniqueID + ":forumMenu", forumMenu); }
/// <summary> /// Fills in the forum list based on the selected Section in cbxSections /// </summary> private void FillForumList() { // clear list first cbxForums.Items.Clear(); int currentSectionID = Convert.ToInt32(cbxSections.SelectedItem.Value); ForumCollection forums = ForumGuiHelper.GetAllForumsInSection(currentSectionID); cbxForums.DataSource = forums; cbxForums.DataTextField = "ForumName"; cbxForums.DataValueField = "ForumID"; cbxForums.DataBind(); cbxForums.Items[0].Selected = true; _forumID = Convert.ToInt32(cbxForums.SelectedItem.Value); }
private void Page_Load(object sender, System.EventArgs e) { // If the user doesn't have any access rights to management stuff, the user should // be redirected to the default of the global system. if (!SessionAdapter.HasSystemActionRights()) { // doesn't have system rights. redirect. Response.Redirect("../Default.aspx", true); } // Check if the user has the right systemright if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement)) { // no, redirect to admin default page, since the user HAS access to the admin menu. Response.Redirect("Default.aspx", true); } _sectionID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["SectionID"]); if (!Page.IsPostBack) { // Get the section directly from the DB, instead from the in-memory cache SectionEntity section = SectionGuiHelper.GetSection(_sectionID); // Show results in the labels if (section != null) { // Section found // Get the forums in the section ForumCollection forums = ForumGuiHelper.GetAllForumsInSection(_sectionID); if (forums.Count > 0) { // section has forums. User is not able to delete the section. Show error message plus // disable delete button lblRuleError.Visible = true; btnDelete.Disabled = true; } lblSectionName.Text = section.SectionName; lblSectionDescription.Text = section.SectionDescription; } else { // the section doesn't exist anymore Response.Redirect("ModifyDeleteSection.aspx", true); } } }
public void LoadStateFromIsoStorage() { if (!MainDataSource.Instance.IsActive) { UserDataSource user = CoreExtensions.LoadFromFile <UserDataSource>("user.xml"); PinnedItemsCollection pins = CoreExtensions.LoadFromFile <PinnedItemsCollection>("pins.xml"); ForumCollection forums = CoreExtensions.LoadFromFile <ForumCollection>("forums.xml"); UserBookmarks bookmarks = CoreExtensions.LoadFromFile <UserBookmarks>("bookmarks.xml"); ThreadTable threads = CoreExtensions.LoadFromFile <ThreadTable>("threads.xml"); MainDataSource.Instance.CurrentUser = user; MainDataSource.Instance.Pins = pins; MainDataSource.Instance.Forums = forums; MainDataSource.Instance.Bookmarks = bookmarks; MainDataSource.Instance.ThreadTable = threads; } }
/// <summary> /// 获取版块的所有父版块( 最顶级的父版块 在第一项 按顺序排列) /// </summary> /// <param name="forumID"></param> /// <returns></returns> public ForumCollection GetAllParentForums(int forumID) { ForumCollection tempForums = new ForumCollection(); Forum forum = GetForum(forumID); if (forum == null) { return(tempForums); } if (forum.ParentID == 0) { return(tempForums); } GetParentForum(forum.ParentID, ref tempForums); return(tempForums); }
private void DisplayForum(ForumCollection forumCollection) { foreach (Forum forum in forumCollection) { if (forum.HasAccess(ForumApplication.Instance.CurrentUser, Permission.Rights.Read)) { Controls.Add(new LiteralControl("<tr class=\"ms-alternating\">")); Controls.Add(new LiteralControl(string.Format("<td valign=\"top\"><img src=\"{0}\"></td>", ForumApplication.Instance.ForumImage))); string link = ForumApplication.Instance.GetLink(SharePointForumControls.ViewTopics, "forum={0}", forum.Id); Controls.Add(new LiteralControl(string.Format("<td valign=\"top\"><a href=\"{0}\">{1}</a><br>{2}</td>", link, forum.Name, forum.Description))); Controls.Add(new LiteralControl(string.Format("<td align=center valign=\"top\">{0}</td>", forum.TopicCount))); Controls.Add(new LiteralControl(string.Format("<td align=center valign=\"top\">{0}</td>", forum.PostCount))); Controls.Add(new LiteralControl(string.Format("<td align=center valign=\"top\">{0}</td>", forum.LastPost))); Controls.Add(new LiteralControl("</tr>")); } } }
/// <summary> /// Deletes the support queue with the ID specified. /// </summary> /// <param name="queueID">The queue ID of the queue to delete.</param> /// <returns>true if succeeded, false otherwise</returns> /// <remarks>All threads in the queue are automatically de-queued and not in a queue anymore. The Default support queue /// for forums which have this queue as the default support queue is reset to null.</remarks> public static bool DeleteSupportQueue(int queueID) { // we'll do several actions in one atomic transaction, so start a transaction first. Transaction trans = new Transaction(IsolationLevel.ReadCommitted, "DeleteSupportQ"); try { // first reset all the FKs in Forum to NULL if they point to this queue. ForumEntity forumUpdater = new ForumEntity(); // set the field to NULL. This is a nullable field, so we can just set the field to 'null', thanks to nullable types. forumUpdater.DefaultSupportQueueID = null; // update the entities directly in the db, use a forum collection for that ForumCollection forums = new ForumCollection(); trans.Add(forums); // specify a filter that only the forums which have this queue as the default queue are updated and have their FK field set to NULL. forums.UpdateMulti(forumUpdater, (ForumFields.DefaultSupportQueueID == queueID)); // delete all SupportQueueThread entities which refer to this queue. This will make all threads which are in this queue become queue-less. SupportQueueThreadCollection supportQueueThreads = new SupportQueueThreadCollection(); trans.Add(supportQueueThreads); // delete them directly from the db. supportQueueThreads.DeleteMulti((SupportQueueThreadFields.QueueID == queueID)); // it's now time to delete the actual supportqueue entity. SupportQueueCollection supportQueues = new SupportQueueCollection(); trans.Add(supportQueues); // delete it directly from the db. int numberOfQueuesDeleted = supportQueues.DeleteMulti((SupportQueueFields.QueueID == queueID)); // done so commit the transaction. trans.Commit(); return(numberOfQueuesDeleted > 0); } catch { // first roll back the transaction trans.Rollback(); // then bubble up the exception throw; } finally { trans.Dispose(); } }
private ForumCollection GetSubForums(ForumCollection forums, int forumId) { ForumCollection subforums = null; foreach (Forum s in forums) { if (s.ParentForumId == forumId) { if (subforums == null) { subforums = new ForumCollection(); } s.TabId = TabId; subforums.Add(s); } } return(subforums); }
/// <summary> /// 清理所有缓存 /// </summary> public void ClearAllCache() { lock (allForumsLocker) { s_AllForums = null; s_AllForumsIndexByCodename = null; s_AllForumsForGuestList = null; s_CategoriesForGuestList = null; s_Categories = null; s_AllThreadCatalogs = null; s_AllModerators = null; //s_AllBannedUsers = null; s_ForumIdsForGuestVisit = null; s_ForumIdsForGuestVisit_Cached = false; } BannedUserBO.Instance.ClearBannedUserCache(); }
public override void Action() { try { ValidateCodes.ValidateCodeManager.DeleteExperisValidateCodeActionRecord(); } catch (Exception ex) { LogHelper.CreateErrorLog(ex); } try { FileManager.ClearExperisTempUploadFiles(); } catch (Exception ex) { LogHelper.CreateErrorLog(ex); } #if !Passport //重新统计论坛板块数据 try { ForumCollection forums = ForumBO.Instance.GetAllForums(); foreach (Forum forum in forums) { ForumBO.Instance.UpdateForumData(forum); ThreadCatalogCollection threadCatalogs = ForumBO.Instance.GetThreadCatalogs(forum.ForumID); foreach (ThreadCatalog catalog in threadCatalogs) { ForumBO.Instance.UpdateForumThreadCatalogData(forum.ForumID, catalog.ThreadCatalogID, false); } } ForumBO.Instance.ClearForumThreadCatalogsCache(); } catch (Exception ex) { LogHelper.CreateErrorLog(ex); } #endif }
private void DisplayForum(ForumCollection forumCollection) { foreach (Forum forum in forumCollection) { Controls.Add(new LiteralControl("<tr class=\"ms-alternating\">")); Controls.Add(new LiteralControl(string.Format("<td valign=\"top\"><img src=\"{0}\"></td>", ForumApplication.Instance.ForumImage))); string forumLink = ForumApplication.Instance.GetLink(SharePointForumControls.ViewTopics, "forum={0}", forum.Id); Controls.Add(new LiteralControl(string.Format("<td><a href=\"{0}\">{1}</a><br>{2}</td>", forumLink, forum.Name, forum.Description))); string editLink = ForumApplication.Instance.GetLink(SharePointForumControls.EditForum, "forum={0}", forum.Id); Controls.Add(new LiteralControl(string.Format("<td align=center><a href=\"{0}\">Edit</a></td>", editLink))); string permissionLink = ForumApplication.Instance.GetLink(SharePointForumControls.ManageForumPermissions, "forum={0}", forum.Id); Controls.Add(new LiteralControl( string.Format("<td align=center><a href=\"{0}\">Manage Permissions</a></td>", permissionLink))); Controls.Add(new LiteralControl("</tr>")); } }
// ********************************************************************* // GetAllForums // /// <summary> /// Returns all of the forums in the database. /// </summary> /// <param name="ShowAllForums">If ShowAllForums is true, ALL forums, active and nonactive, /// are returned. If ShowAllForums is false, just the active forums are returned.</param> /// <returns>A ForumCollection with all of the active forums, or all of the active and nonactive /// forums, depending on the value of the ShowAllForums property.</returns> /// // ***********************************************************************/ public static ForumCollection GetAllForums(bool showAllForums, string username) { ForumCollection forums = null; // If the user is anonymous we'll take some load off the database if (username == null) { if (HttpContext.Current.Cache["ForumCollection-AllForums-Anonymous"] != null) { return((ForumCollection)HttpContext.Current.Cache["ForumCollection-AllForums-Anonymous"]); } } // Optimize this method to ensure we only ask for the forums once per request if (HttpContext.Current.Items["ForumCollection" + showAllForums + username] == null) { // Create Instance of the IDataProviderBase IDataProviderBase dp = DataProvider.Instance(); forums = dp.GetAllForums(showAllForums, username); // If we have a user add the results to the items collection else add to cache if (username == null) { HttpContext.Current.Cache.Insert("ForumCollection-AllForums-Anonymous", forums, null, DateTime.Now.AddMinutes(1), TimeSpan.Zero); } else { HttpContext.Current.Items.Add("ForumCollection" + showAllForums + username, forums); } return(forums); } else { forums = (ForumCollection)HttpContext.Current.Items["ForumCollection" + showAllForums + username]; } return(forums); }
private void initForums() { lock (allForumsLocker) { if (s_AllForums == null || s_AllForumsIndexByCodename == null || s_AllForumsForGuestList == null || s_Categories == null || s_CategoriesForGuestList == null) { s_AllForums = ForumDaoV5.Instance.GetAllForums(); s_AllForumsIndexByCodename = new Dictionary <string, Forum>(); s_AllForumsForGuestList = new ForumCollection(); s_Categories = new ForumCollection(); s_CategoriesForGuestList = new ForumCollection(); foreach (Forum forum in s_AllForums) { if (s_AllForumsIndexByCodename.ContainsKey(forum.CodeName) == false) { s_AllForumsIndexByCodename.Add(forum.CodeName, forum); } if (forum.CanDisplayInList(User.Guest)) { s_AllForumsForGuestList.Add(forum); } if (forum.ForumID > 0 && forum.ParentID == 0) { s_Categories.Add(forum); } if (forum.ForumID > 0 && forum.ParentID == 0 && forum.CanVisit(User.Guest)) { s_CategoriesForGuestList.Add(forum); } } } } }
/// <summary> /// Deletes the support queue with the ID specified. /// </summary> /// <param name="queueID">The queue ID of the queue to delete.</param> /// <returns>true if succeeded, false otherwise</returns> /// <remarks>All threads in the queue are automatically de-queued and not in a queue anymore. The Default support queue /// for forums which have this queue as the default support queue is reset to null.</remarks> public static bool DeleteSupportQueue(int queueID) { // we'll do several actions in one atomic transaction, so start a transaction first. Transaction trans = new Transaction(IsolationLevel.ReadCommitted, "DeleteSupportQ"); try { // first reset all the FKs in Forum to NULL if they point to this queue. ForumEntity forumUpdater = new ForumEntity(); // set the field to NULL. This is a nullable field, so we can just set the field to 'null', thanks to nullable types. forumUpdater.DefaultSupportQueueID = null; // update the entities directly in the db, use a forum collection for that ForumCollection forums = new ForumCollection(); trans.Add(forums); // specify a filter that only the forums which have this queue as the default queue are updated and have their FK field set to NULL. forums.UpdateMulti(forumUpdater, (ForumFields.DefaultSupportQueueID == queueID)); // delete all SupportQueueThread entities which refer to this queue. This will make all threads which are in this queue become queue-less. SupportQueueThreadCollection supportQueueThreads = new SupportQueueThreadCollection(); trans.Add(supportQueueThreads); // delete them directly from the db. supportQueueThreads.DeleteMulti((SupportQueueThreadFields.QueueID == queueID)); // it's now time to delete the actual supportqueue entity. SupportQueueCollection supportQueues = new SupportQueueCollection(); trans.Add(supportQueues); // delete it directly from the db. int numberOfQueuesDeleted = supportQueues.DeleteMulti((SupportQueueFields.QueueID == queueID)); // done so commit the transaction. trans.Commit(); return (numberOfQueuesDeleted > 0); } catch { // first roll back the transaction trans.Rollback(); // then bubble up the exception throw; } finally { trans.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { //关闭侧边栏 if (_Request.IsClick("Default_Close_Sidebar")) { ProcessUpdateUserOption(true); } //开启侧边栏 if (_Request.IsClick("Default_Open_Sidebar")) { ProcessUpdateUserOption(false); } //快速登录 if (_Request.IsClick("btLogin")) { MessageDisplay msgDisplay = CreateMessageDisplay(); using (ErrorScope es = new ErrorScope()) { if (CheckValidateCode("login", msgDisplay)) { ValidateCodeManager.CreateValidateCodeActionRecode("login"); string username = _Request.Get("username", Method.Post, string.Empty, false); string password = _Request.Get("password", Method.Post, string.Empty, false); //如果全局UserLoginType为Username -或者- 后台设置全局UserLoginType为All且用户选择了账号登陆 则为true UserLoginType loginType = _Request.Get<UserLoginType>("logintype", Method.Post, UserLoginType.Username); bool isUsernameLogin = (LoginType == UserLoginType.Username || (LoginType == UserLoginType.All && loginType == UserLoginType.Username)); int cookieTime = _Request.Get<int>("cookietime", Method.Post, 0); bool success; try { success = UserBO.Instance.Login(username, password, _Request.IpAddress, cookieTime > 0, isUsernameLogin); if (success == false) { if (es.HasUnCatchedError) { es.CatchError<UserNotActivedError>(delegate(UserNotActivedError err) { Response.Redirect(err.ActiveUrl); }); es.CatchError<EmailNotValidatedError>(delegate(EmailNotValidatedError err) { Response.Redirect(err.ValidateUrl); }); es.CatchError<ErrorInfo>(delegate(ErrorInfo error) { msgDisplay.AddError(error); }); } } } catch (Exception ex) { msgDisplay.AddException(ex); success = false; } if (success) { BbsRouter.JumpToCurrentUrl(); } } } } else { UpdateOnlineStatus(OnlineAction.ViewIndexPage, 0, ""); //OnlineManager.UpdateOnlineUser(MyUserID, 0, 0, My.OnlineStatus, OnlineAction.ViewIndexPage, Request, Response); AddNavigationItem("欢迎光临,现在是" + UserNow); } ForumCollection tempForums = new ForumCollection(); foreach (Forum forum in ForumCatalogs) { WaitForFillSimpleUsers<Moderator>(forum.Moderators); foreach (Forum subForum in forum.SubForumsForList) { WaitForFillSimpleUsers<Moderator>(subForum.Moderators); } tempForums.AddRange(forum.SubForumsForList); } ForumBO.Instance.SetForumsLastThread(tempForums); SubmitFillUsers(); }
protected void Page_Load(object sender, EventArgs e) { if (Current_user == null || Current_user.ID == 0) { is_login = false; return; } string t = Editor.Text; is_login = true; type = Request["type"]; if (!IsPostBack) { if (!string.IsNullOrEmpty(type) && type == "edit") { long.TryParse(Request["postid"], out postid); if (postid > 0) { hoachdinhtuonglai.Data.Core.Post p = PostDA.SelectByID(postid); if (p != null) { Editor.Text = p.Content; txttitle.Text = p.Title; //RadioButtonListCate.SelectedValue = p.CateID.Value.ToString(); objID = p.ObjectID.Value; txtKeyword.Text = p.Tags; } } } listCate = ForumDA.SelectAll(); setCate(listCate); } }
/// <summary> /// Gets all forum entities which belong to a given section. /// </summary> /// <param name="sectionID">The section ID from which forums should be retrieved</param> /// <returns>Entity collection with entities for all forums in this section sorted alphabitacally</returns> public static ForumCollection GetAllForumsInSection(int sectionID) { var q = new QueryFactory().Forum .Where(ForumFields.SectionID == sectionID) .OrderBy(ForumFields.OrderNo.Ascending(), ForumFields.ForumName.Ascending()); var toReturn = new ForumCollection(); toReturn.GetMulti(q); return toReturn; }
public string Render() { if (string.IsNullOrEmpty(Template)) { return "Please specify a template"; } StringBuilder sb = new StringBuilder(); Data.ForumsDB fdb = new Data.ForumsDB(); ForumCollection allForums = fdb.Forums_List(PortalId, ModuleId); ForumCollection filteredForums = new ForumCollection(); foreach (Forum f in allForums) { if (f.ForumGroup.Active && f.Active && f.ParentForumId == 0) { if (Permissions.HasPerm(f.Security.View, ForumUser.UserRoles)) { f.TabId = TabId; f.SubForums = GetSubForums(allForums, f.ForumID); filteredForums.Add(f); } } } string groupTemplate = TemplateUtils.GetTemplateSection(Template, "[AF:DIR:FORUMGROUP]", "[/AF:DIR:FORUMGROUP]"); string forumTemplate = TemplateUtils.GetTemplateSection(Template, "[AF:DIR:FORUM]", "[/AF:DIR:FORUM]"); string subForumTemplate = TemplateUtils.GetTemplateSection(Template, "[AF:DIR:SUBFORUM]", "[/AF:DIR:SUBFORUM]"); int currGroup = -1; string gtmp = string.Empty; string ftmp = string.Empty; string subtmp = string.Empty; StringBuilder list = new StringBuilder(); bool inprogress = false; foreach (Forum f in filteredForums) { if (currGroup != f.ForumGroupId) { if (! (string.IsNullOrEmpty(gtmp))) { gtmp = gtmp.Replace("[FORUMHOLDER]", string.Empty); list.Append(gtmp); } gtmp = groupTemplate; gtmp = TemplateUtils.ReplaceSubSection(gtmp, "[FORUMHOLDER]", "[AF:DIR:FORUM]", "[/AF:DIR:FORUM]"); gtmp = ParseForumGroup(f.ForumGroup, gtmp); ftmp = forumTemplate; ftmp = TemplateUtils.ReplaceSubSection(ftmp, "[SUBFORUMHOLDER]", "[AF:DIR:SUBFORUM]", "[/AF:DIR:SUBFORUM]"); subtmp = subForumTemplate; currGroup = f.ForumGroupId; } string forums = ParseForum(f, ftmp); if (f.SubForums != null) { foreach (Forum s in f.SubForums) { forums = forums.Replace("[SUBFORUMHOLDER]", ParseForum(s, subtmp) + "[SUBFORUMHOLDER]"); } } forums = forums.Replace("[SUBFORUMHOLDER]", string.Empty); gtmp = gtmp.Replace("[FORUMHOLDER]", forums + "[FORUMHOLDER]"); } gtmp = gtmp.Replace("[FORUMHOLDER]", string.Empty); list.Append(gtmp); Template = TemplateUtils.ReplaceSubSection(Template, list.ToString(), "[AF:DIR:FORUMGROUP]", "[/AF:DIR:FORUMGROUP]"); return Template; }
protected void setCate(ForumCollection list) { RadioButtonListCate.Items.Clear(); ListItem rd = new ListItem(); foreach (Forum c in list) { rd = new ListItem(); rd.Text = c.ForumName; rd.Value = c.ID.ToString(); if (c.ID == objID) rd.Selected = true; RadioButtonListCate.Items.Add(rd); } RadioButtonListCate.DataBind(); }
public ForumCollection Forums_List(int PortalId, int ModuleId) { ForumCollection f = new ForumCollection(); object obj = DataCache.CacheRetrieve(string.Format(CacheKeys.ForumList, ModuleId)); if (obj != null) { f = (ForumCollection)obj; } else { using (IDataReader dr = SqlHelper.ExecuteReader(_connectionString, dbPrefix + "ForumsList", PortalId, ModuleId)) { Forum fi = null; ForumGroupInfo gi = null; while (dr.Read()) { fi = new Forum(); gi = new ForumGroupInfo(); fi.ModuleId = int.Parse(dr["ModuleId"].ToString()); fi.ForumID = Convert.ToInt32(dr["ForumId"].ToString()); fi.Active = bool.Parse(dr["Active"].ToString()); fi.ForumDesc = dr["ForumDesc"].ToString(); fi.ForumGroupId = int.Parse(dr["ForumGroupId"].ToString()); fi.ForumID = int.Parse(dr["ForumId"].ToString()); fi.ForumName = dr["ForumName"].ToString(); fi.GroupName = dr["GroupName"].ToString(); fi.Hidden = bool.Parse(dr["Hidden"].ToString()); fi.ParentForumId = Convert.ToInt32(dr["ParentForumId"].ToString()); DateTime postTime; if (! (DateTime.TryParse(dr["LastPostDate"].ToString(), out postTime))) { fi.LastPostDateTime = new DateTime(); } else { fi.LastPostDateTime = postTime; } fi.LastTopicId = int.Parse(dr["LastTopicId"].ToString()); fi.LastReplyId = int.Parse(dr["LastReplyId"].ToString()); fi.LastPostSubject = dr["LastPostSubject"].ToString(); fi.LastPostDisplayName = dr["LastPostAuthorName"].ToString(); fi.LastPostUserID = int.Parse(dr["LastPostAuthorId"].ToString()); fi.LastPostUserName = fi.LastPostDisplayName; fi.LastRead = DateTime.Parse(dr["LastRead"].ToString()); gi.Active = bool.Parse(dr["GroupActive"].ToString()); gi.Hidden = bool.Parse(dr["GroupHidden"].ToString()); gi.GroupName = fi.GroupName; gi.ForumGroupId = fi.ForumGroupId; gi.PrefixURL = dr["GroupPrefixURL"].ToString(); //gi.SEO = dr("GroupSEO").ToString fi.ForumGroup = gi; fi.Security.Announce = dr["CanAnnounce"].ToString(); fi.Security.Attach = dr["CanAttach"].ToString(); fi.Security.Create = dr["CanCreate"].ToString(); fi.Security.Delete = dr["CanDelete"].ToString(); fi.Security.Edit = dr["CanEdit"].ToString(); fi.Security.Lock = dr["CanLock"].ToString(); fi.Security.ModApprove = dr["CanModApprove"].ToString(); fi.Security.ModDelete = dr["CanModDelete"].ToString(); fi.Security.ModEdit = dr["CanModEdit"].ToString(); fi.Security.ModLock = dr["CanModLock"].ToString(); fi.Security.ModMove = dr["CanModMove"].ToString(); fi.Security.ModPin = dr["CanModPin"].ToString(); fi.Security.ModSplit = dr["CanModSplit"].ToString(); fi.Security.ModUser = dr["CanModUser"].ToString(); fi.Security.Pin = dr["CanPin"].ToString(); fi.Security.Poll = dr["CanPoll"].ToString(); fi.Security.Block = dr["CanBlock"].ToString(); fi.Security.Read = dr["CanRead"].ToString(); fi.Security.Reply = dr["CanReply"].ToString(); fi.Security.Subscribe = dr["CanSubscribe"].ToString(); fi.Security.Trust = dr["CanTrust"].ToString(); fi.Security.View = dr["CanView"].ToString(); fi.ForumSettings = LoadSettings(dr); fi.PrefixURL = dr["PrefixURL"].ToString(); //.SEO = dr("ForumSEO").ToString fi.TotalTopics = int.Parse(dr["TotalTopics"].ToString()); fi.TotalReplies = int.Parse(dr["TotalReplies"].ToString()); f.Add(fi); } dr.Close(); } DataCache.CacheStore(string.Format(CacheKeys.ForumList, ModuleId), f); } return f; }
/// <summary> /// Deletes the given forum from the system, including <b>all</b> threads in this forum and messages in those threads. /// </summary> /// <param name="forumID">Forum ID.</param> /// <returns>True if succeeded, false otherwise</returns> public static bool DeleteForum(int forumID) { // first all threads in this forum have to be removed, then this forum should be removed. Do this in one transaction. Transaction trans = new Transaction(IsolationLevel.ReadCommitted, "DeleteForum"); try { PredicateExpression forumFilter = new PredicateExpression(); forumFilter.Add((ForumFields.ForumID == forumID)); // remove all threads in this forum ThreadManager.DeleteAllThreadsInForum(forumID, trans); // remove all ForumRoleForumActionRight entities for this forum ForumRoleForumActionRightCollection forumRoleActionRights = new ForumRoleForumActionRightCollection(); trans.Add(forumRoleActionRights); forumRoleActionRights.DeleteMulti(ForumRoleForumActionRightFields.ForumID == forumID); // remove the forum entity. do this by executing a direct delete statement on the database ForumCollection forums = new ForumCollection(); trans.Add(forums); forums.DeleteMulti(forumFilter); trans.Commit(); return true; } catch { // exception occured, rollback trans.Rollback(); throw; } finally { trans.Dispose(); } }
private ForumCollection GetSubForums(ForumCollection forums, int forumId) { ForumCollection subforums = null; foreach (Forum s in forums) { if (s.ParentForumId == forumId) { if (subforums == null) { subforums = new ForumCollection(); } s.TabId = TabId; subforums.Add(s); } } return subforums; }