protected void gvItems_DataBinding(object sender, EventArgs e) { string postID = Request["PostID"]; int iPostID = 0; int.TryParse(postID, out iPostID); if (iPostID != 0) { ((GridView)sender).DataSource = BSComment.GetCommentsByPostID(iPostID, CommentStates.All); } else { ((GridView)sender).DataSource = BSComment.GetComments(CommentStates.All); } }
public List <BSComment> GetComments(CommentStates state) { return(BSComment.GetCommentsByPostID(PostID, state)); }
// Call RSS public static void GetRSS(Page page, RssTypes type) { XmlTextWriter writer = new XmlTextWriter(page.Response.OutputStream, System.Text.Encoding.UTF8); WriteRSSPrologue(writer, type); List <BSPost> posts = new List <BSPost>(); int intFeedCount = Blogsa.Settings["show_feed_count"] != null?Convert.ToInt32(Blogsa.Settings["show_feed_count"]) : 10; if (type == RssTypes.Comments) { List <BSComment> comments = BSComment.GetComments(CommentStates.Approved); if (comments.Count > 0) { foreach (BSComment comment in comments) { BSPost bsPost = BSPost.GetPost(comment.PostID); AddRSSItem(writer, bsPost.Title, bsPost.Link + "#Comments" + comment.CommentID, comment.Content, comment.Date.ToString("EEE, dd MMMM yyyy HH:mm:ss Z"), comment.UserName); } WriteRSSClosing(writer); writer.Flush(); writer.Close(); page.Response.ContentEncoding = System.Text.Encoding.UTF8; page.Response.ContentType = "text/xml"; page.Response.Cache.SetCacheability(HttpCacheability.NoCache); page.Response.End(); } } else if (type == RssTypes.CommentsByPost) { List <BSComment> comments = BSComment.GetCommentsByPostID(Convert.ToInt32(HttpContext.Current.Request["PostID"]), CommentStates.Approved); if (comments.Count > 0) { BSPost bsPost = BSPost.GetPost(Convert.ToInt32(HttpContext.Current.Request["PostID"])); foreach (BSComment comment in comments) { AddRSSItem(writer, bsPost.Title, bsPost.Link + "#Comments" + comment.CommentID, comment.Content, comment.Date.ToString("EEE, dd MMMM yyyy HH:mm:ss Z"), comment.UserName); } WriteRSSClosing(writer); writer.Flush(); writer.Close(); page.Response.ContentEncoding = System.Text.Encoding.UTF8; page.Response.ContentType = "text/xml"; page.Response.Cache.SetCacheability(HttpCacheability.NoCache); page.Response.End(); } } else if (type == RssTypes.Posts) { posts = BSPost.GetPosts(PostTypes.Article, PostStates.Published, 10); if (posts.Count > 0) { foreach (BSPost post in posts) { AddRSSItem(writer, post.Title, post.Link, post.Content, post.Date.ToString("EEE, dd MMMM yyyy HH:mm:ss Z"), post.UserName); } WriteRSSClosing(writer); writer.Flush(); writer.Close(); page.Response.ContentEncoding = System.Text.Encoding.UTF8; page.Response.ContentType = "text/xml"; page.Response.Cache.SetCacheability(HttpCacheability.NoCache); page.Response.End(); } } }