SyndicationServiceBase.cs :  » Bloggers » dasBlog » newtelligence » DasBlog » Web » Services » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Bloggers » dasBlog 
dasBlog » newtelligence » DasBlog » Web » Services » SyndicationServiceBase.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using newtelligence.DasBlog.Runtime;
using newtelligence.DasBlog.Web.Core;
using newtelligence.DasBlog.Web.Services.Rss20;
using System.Collections.Generic;


namespace newtelligence.DasBlog.Web{
    [DesignTimeVisible(false)]
  public class SyndicationServiceBase : System.Web.Services.WebService
  {
        protected IBlogDataService dataService;
        protected ILoggingDataService loggingService;
        protected DataCache cache;
        protected SiteConfig siteConfig;

        #region Component Designer generated code
    
        //Required by the Web Services Designer 
        private IContainer components = null;
        
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {

        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if(disposing && components != null)
            {
                components.Dispose();
            }
            base.Dispose(disposing);    
        }
    
        #endregion

    public SyndicationServiceBase()
    {

            InitializeComponent();
            if ( Context != null )
            {
                siteConfig = SiteConfig.GetSiteConfig();
                loggingService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext());
                dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), loggingService );
                cache = CacheFactory.GetCache();
                
            }
        }

        public SyndicationServiceBase(SiteConfig siteConfig, IBlogDataService dataService, ILoggingDataService loggingService)
        {
            InitializeComponent();
            this.dataService = dataService;
            this.loggingService = loggingService; 
            this.siteConfig = siteConfig;
        }


        protected string PreprocessItemContent( string entryId, string content )
        {
      if (siteConfig.ApplyContentFiltersToRSS)
      {
        content = SiteUtilities.FilterContent(entryId, content);
      }
      
      if ( siteConfig.EnableAggregatorBugging )
            {
                content = content + "<img width=\"0\" height=\"0\" src=\""+SiteUtilities.GetAggregatorBugUrl(siteConfig,entryId)+"\"/>";
            }

            if ( siteConfig.EnableRssItemFooters && 
                siteConfig.RssItemFooter != null && 
                siteConfig.RssItemFooter.Length > 0 )
            {
                content = content + "<br/><hr/>" + siteConfig.RssItemFooter;
            }
            
            

            return content;
            
        }
        

        protected class EntrySorter : IComparer<Entry>
        {
            public int Compare(Entry left, Entry right)
            {
                return right.CreatedUtc.CompareTo(left.CreatedUtc);
            }
        }

        protected EntryCollection BuildEntries(string category, int maxDayCount, int maxEntryCount)
        {
            EntryCollection entryList = new EntryCollection();

            if (category != null)
            {
                int entryCount = siteConfig.RssEntryCount;
                category = category.ToUpper();
                foreach (CategoryCacheEntry catEntry in dataService.GetCategories())
                {
                    if (catEntry.Name.ToUpper() == category)
                    {
                        foreach (CategoryCacheEntryDetail detail in catEntry.EntryDetails)
                        {
              Entry entry = dataService.GetEntry(detail.EntryId);
              if (entry != null)
              {
                entryList.Add(entry);
                entryCount--;
              }
              if (entryCount <= 0) break;
                        } // foreach (CategoryCacheEntryDetail
                    }
                    if (entryCount <= 0) break;
                } // foreach (CategoryCacheEntry
            }
            else
            {
                entryList = dataService.GetEntriesForDay(DateTime.Now.AddDays(siteConfig.ContentLookaheadDays).ToUniversalTime(), new Util.UTCTimeZone(), null, maxDayCount, maxEntryCount, null);
            }
            entryList.Sort( new EntrySorter() );
            return entryList;
        }

  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.