📄 weblogrsshandler.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;using CommunityServer.Components;namespace CommunityServer.Blogs.Components
{
/// <summary>
/// Summary description for WeblogRssHandler.
/// </summary>
public class WeblogRssHandler : BaseWeblogSyndicationHandler
{
public WeblogRssHandler()
{
//
// TODO: Add constructor logic here
//
}
protected int CategoryID = 0;
protected override string CacheKey
{
get
{
if(CategoryID <= 0)
return string.Format("Weblog:{0}:IndividualRss",CurrentSection.SectionID);
else
return string.Format("Weblog:{0}:CategoryRss{1}",CurrentSection.SectionID,CategoryID);
}
}
protected override int CacheTime
{
get
{
return 90;
}
}
/// <summary>
/// Override Process feed to make sure we check for a CategoryID Querystring
/// </summary>
protected override void ProcessFeed()
{
if(Context.Request.QueryString["CategoryID"] != null)
{
double cid = 0;
if(Double.TryParse( Context.Request.QueryString["CategoryID"], System.Globalization.NumberStyles.Integer, null, out cid ))
this.CategoryID = (int)cid;
}
base.ProcessFeed ();
}
protected override CachedFeed BuildFeed()
{
BlogThreadQuery query = CreateQuery();
ThreadSet threads = WeblogPosts.GetBlogThreads(query,true);
BaseRssWriter writer = null;
if(CategoryID <= 0)
writer = new WeblogRssWriter(threads.Threads,this.CurrentWeblog,this.BaseUrl);
else
{
PostCategory cat = PostCategories.GetCategory(CategoryID,CategoryType.BlogPost,CurrentSection.SectionID);
writer = new WeblogCategoryRssWriter(threads.Threads,CurrentWeblog,this.BaseUrl,cat);
}
DateTime dt = threads.Threads.Count > 0 ? ((WeblogPost)threads.Threads[0]).BloggerTime : DateTime.Now;
return new CachedFeed(dt,null,writer.GetXml());
}
protected virtual BlogThreadQuery CreateQuery()
{
BlogThreadQuery query = new BlogThreadQuery();
query.BlogPostType = BlogPostType.Post;
query.BlogID = CurrentSection.SectionID;
query.IncludeCategories = false;
query.PageIndex = 0;
query.PageSize = WeblogConfiguration.Instance().IndividualPostCount;
query.SortBy = BlogThreadSortBy.MostRecent;
query.SortOrder = SortOrder.Descending;
query.IsPublished = true;
query.IgnorePaging = true;
if(this.CategoryID > 0)
query.CategoryID = this.CategoryID;
else
query.PostConfig = BlogPostConfig.IsAggregated;
return query;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -