⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 weblogatomhandler.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 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 WeblogAtomHandler : BaseWeblogSyndicationHandler
    {
        public WeblogAtomHandler()
        {
            //
            // TODO: Add constructor logic here
            //
        }

//        protected int CategoryID  = 0;

        protected override string CacheKey
        {
            get
            {
//                if(CategoryID <= 0)
                    return string.Format("Weblog:{0}:IndividualAtom",CurrentSection.SectionID);
//                else
//                    return string.Format("Weblog:{0}:CategoryRss{1}",CurrentSection.SectionID,CategoryID);
            }
        }

        protected override int CacheTime
        {
            get
            {
                return 30;
            }
        }
//
//        /// <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 = 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.PostConfig = BlogPostConfig.IsAggregated;
            query.IgnorePaging = true;

//            if(this.CategoryID > 0)
//                query.CategoryID = this.CategoryID;

            
            ThreadSet threads = WeblogPosts.GetBlogThreads(query,true);
            WeblogAtomWriter writer = null;

//            if(CategoryID <= 0)
                writer = new WeblogAtomWriter(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]).PostDate : DateTime.Now;
            
            return new CachedFeed(dt,null,writer.GetXml());

        }



    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -