private void btnUpdateCounts_Click(object sender, EventArgs e) { int numForums = 0; int numTopics = 0; int numPosts = 0; CategoryCollection categories = RepositoryRegistry.CategoryRepository.GetAll(); foreach (Category category in categories) { numForums += category.Forums.Count; foreach (Forum forum in category.Forums) { forum.TopicCount = forum.Topics.Count; numTopics += forum.TopicCount; forum.PostCount = 0; foreach (Topic topic in forum.Topics) { forum.PostCount += topic.Messages.Count; numPosts += forum.PostCount; } RepositoryRegistry.ForumRepository.Save(forum); } } WebPartParent.TopicCount = numTopics; WebPartParent.ForumCount = numForums; WebPartParent.PostCount = numPosts; WebPartParent.PersistProperties(); }
/// <summary> /// Notifies server controls that use composition-based implementation to create any child /// controls they contain in preparation for posting back or rendering. /// </summary> protected override void CreateChildControls() { try { string topicName = string.Empty; _form = new OWSForm(); Controls.Add(_form); _form.Controls.Add(BuildBasePageLinks()); _form.Controls.Add(new LiteralControl("<br>")); _form.Controls.Add(new LiteralControl("<table cellspacing=1 cellpadding=4 width=100% align=center border=1>")); _form.Controls.Add(new LiteralControl("<tr>")); _form.Controls.Add(new LiteralControl(string.Format("<td class=ms-ToolPaneTitle align=middle colspan=2>{0}</td>", _postModeTitle))); OWSLabelField lblSubject = new OWSLabelField(); lblSubject.Text = "Subject:"; _txtSubject = new OWSTextField(); _txtSubject.ID = "txtSubject"; _txtSubject.NumLines = 1; if (MessageMode != PostMode.New) { lblSubject.Visible = false; _txtSubject.Text = topicName; _txtSubject.Visible = false; } CreatePreviewSection(); CreateMessageBodySection(topicName); CreateButtonSection(); _form.Controls.Add(new LiteralControl("</table>")); } catch (Exception ex) { WebPartParent.AddError(ex); } }
private void SaveControlValues() { ForumApplication.Instance.Title = txtForumName.Text; WebPartParent.Name = ForumApplication.Instance.Title; WebPartParent.PersistProperties(); }