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.ServiceModel;
using System.ServiceModel.Activation;
namespace newtelligence.DasBlog.Web.Services{
[ServiceContract, AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
public partial class WebWebServices
{
protected IBlogDataService dataService;
protected ILoggingDataService loggingService;
protected SiteConfig siteConfig;
public WebWebServices()
{
siteConfig = SiteConfig.GetSiteConfig();
loggingService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext());
dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), System.Web.Hosting.HostingEnvironment.MapPath(SiteConfig.GetSiteConfig().BinariesDir), loggingService);
}
public WebWebServices(SiteConfig siteConfig, IBlogDataService dataService, ILoggingDataService loggingService)
{
this.dataService = dataService;
this.loggingService = loggingService;
this.siteConfig = siteConfig;
}
protected string PreprocessItemContent( string entryId, string content )
{
if (siteConfig.ApplyContentFiltersToRSS)
{
content = Utils.FilterContent(entryId, content);
}
if ( siteConfig.EnableAggregatorBugging )
{
content = content + "<img width=\"0\" height=\"0\" src=\""+Utils.GetAggregatorBugUrl(siteConfig,entryId)+"\"/>";
}
if ( siteConfig.EnableRssItemFooters &&
siteConfig.RssItemFooter != null &&
siteConfig.RssItemFooter.Length > 0 )
{
content = content + "<br/><hr/>" + siteConfig.RssItemFooter;
}
return content;
}
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;
}
}
}
|