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

📄 galleryrsshandler.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Globalization;
using CommunityServer.Components;

namespace CommunityServer.Galleries.Components
{
	/// <summary>
	/// Summary description for WeblogRssHandler.
	/// </summary>
	public class GalleryRssHandler : BaseGallerySyndicationHandler
	{
		public GalleryRssHandler()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		protected int CategoryID  = -1;
		protected RssType Type;

		protected override string CacheKey
		{
			get
			{
				if(CategoryID == -1)
					return string.Format("Gallery:{0}:Type:{1}", CurrentSection.SectionID, Type);
				else
					return string.Format("Gallery:{0}:Category:{1}:Type:{2}", CurrentSection.SectionID, CategoryID, Type);
			}
		}

		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"], NumberStyles.Integer, null, out cid ))
					this.CategoryID = (int)cid;
			}

			if(Context.Request.QueryString["Type"] != null)
				Type = (RssType)Enum.Parse(typeof(RssType), Context.Request.QueryString["Type"]);
			else
				Type = RssType.Pictures;

			base.ProcessFeed ();
		}


		protected override CachedFeed BuildFeed()
		{
			BaseRssWriter writer = null;
			DateTime date = DateTime.MinValue;

			switch(Type)
			{
				case RssType.Categories:
					ArrayList categoryItems = PostCategories.GetCategories(CurrentSection.SectionID, CategoryType.GalleryPicture);
					foreach(PostCategory category in categoryItems)
						if(category.MostRecentSubPostDate > date)
							date = category.MostRecentSubPostDate;
					writer = new GalleryRssWriter(categoryItems, CurrentGallery, this.BaseUrl);
					break;
				case RssType.Pictures:

					GalleryThreadQuery query = new GalleryThreadQuery();
					query.SectionID = CurrentGallery.SectionID;
					query.CategoryID = CategoryID;
					query.SortBy = GalleryThreadSortBy.ThreadDate;
					query.SortOrder = SortOrder.Descending;
					query.PageSize = 20;

					PostCategory cat = null;
					ArrayList pictureItems = Pictures.GetPictures(query).Threads;
					date =  pictureItems.Count > 0 ? ((Picture)pictureItems[0]).PostDate : DateTime.Now;
					writer = new GalleryPicturesRssWriter(pictureItems, CurrentGallery, this.BaseUrl, cat);
					break;
			}

			return new CachedFeed(date, null, writer.GetXml());

		}



	}
}

⌨️ 快捷键说明

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