private static bool InitializeBlacklist(IBlackList referrerBlacklist, string path) { ILoggingDataService loggingService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); try { referrerBlacklist.Initialize(path); BlacklistUpdateState updateState = referrerBlacklist.UpdateBlacklist(); if (updateState == BlacklistUpdateState.Failed) { loggingService.AddEvent( new EventDataItem(EventCodes.Error, referrerBlacklist.ToString() + " could not be updated: ", "InitializeBlacklist")); } else if (updateState == BlacklistUpdateState.Updated) { loggingService.AddEvent( new EventDataItem(EventCodes.ApplicationStartup, referrerBlacklist.ToString() + " updated: ", "InitializeBlacklist")); } return(true); } catch (Exception ex) { loggingService.AddEvent(new EventDataItem(EventCodes.Error, referrerBlacklist.ToString() + " could not be initialized: " + ex.ToString(), "InitializeBlacklist")); } return(false); }
public BlogManager(IDasBlogSettings settings, ISiteSecurityManager siteSecurityRepository) { _dasBlogSettings = settings; _siteSecurity = siteSecurityRepository; _loggingDataService = LoggingDataServiceFactory.GetService(_dasBlogSettings.WebRootDirectory + _dasBlogSettings.SiteConfiguration.LogDir); _dataService = BlogDataServiceFactory.GetService(_dasBlogSettings.WebRootDirectory + _dasBlogSettings.SiteConfiguration.ContentDir, _loggingDataService); }
public string CreateEntry(Entry entry, string username, string password) { SiteConfig siteConfig = SiteConfig.GetSiteConfig(); if (!siteConfig.EnableEditService) { throw new ServiceDisabledException(); } Authenticate(username, password); // ensure that the entryId was filled in // if (entry.EntryId == null || entry.EntryId.Length == 0) { entry.EntryId = Guid.NewGuid().ToString(); } // ensure the dates were filled in, otherwise use NOW if (entry.CreatedUtc == DateTime.MinValue) { entry.CreatedUtc = DateTime.UtcNow; } if (entry.ModifiedUtc == DateTime.MinValue) { entry.ModifiedUtc = DateTime.UtcNow; } ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); SiteUtilities.SaveEntry(entry, string.Empty, null, siteConfig, logService, dataService); return(entry.EntryId); }
public PingbackAPI() { siteConfig = SiteConfig.GetSiteConfig(); logDataService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logDataService); }
public string UpdateEntry(Entry entry, string username, string password) { SiteConfig siteConfig = SiteConfig.GetSiteConfig(); if (!siteConfig.EnableEditService) { throw new ServiceDisabledException(); } Authenticate(username, password); ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); EntrySaveState val = SiteUtilities.UpdateEntry(entry, null, null, siteConfig, logService, dataService); string rtn = string.Empty; if (val.Equals(EntrySaveState.Updated)) { rtn = entry.EntryId; } else { rtn = val.ToString(); } return(rtn); }
public void SetUpForTests() { // This method will be run each and every time a test method is run. // Place common initialization steps here that should be run before // every test. DirectoryInfo root = new DirectoryInfo(ReflectionHelper.CodeBase()); testContent = new DirectoryInfo(Path.Combine(root.Parent.FullName, "TestContent")); Assert.IsTrue(testContent.Exists); testLogs = new DirectoryInfo(Path.Combine(root.Parent.FullName, "TestLogs")); Assert.IsTrue(testLogs.Exists); loggingService = LoggingDataServiceFactory.GetService( testLogs.FullName); Assert.IsNotNull(loggingService); blogService = BlogDataServiceFactory.GetService( testContent.FullName, loggingService); Assert.IsNotNull(blogService); loggingService.AddEvent(new EventDataItem(EventCodes.ApplicationStartup, "", "")); }
public SubscriptionManager(IDasBlogSettings settings) { dasBlogSettings = settings; loggingDataService = LoggingDataServiceFactory.GetService(Path.Combine(dasBlogSettings.WebRootDirectory, dasBlogSettings.SiteConfiguration.LogDir)); dataService = BlogDataServiceFactory.GetService(Path.Combine(dasBlogSettings.WebRootDirectory, dasBlogSettings.SiteConfiguration.ContentDir), loggingDataService); }
public void ProcessRequest(HttpContext context) { ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); try { IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); SiteConfig siteConfig = SiteConfig.GetSiteConfig(); string languageFilter = context.Request.Headers["Accept-Language"]; if (SiteSecurity.IsInRole("admin")) { languageFilter = ""; } EntryCollection entries = dataService.GetEntriesForDay(DateTime.UtcNow, siteConfig.GetConfiguredTimeZone(), languageFilter, 1, 1, String.Empty); if (entries != null && entries.Count > 0) { Entry e = entries[0]; context.Response.Write(e.Title); } } catch (Exception ex) { logService.AddEvent(new EventDataItem(EventCodes.Error, "Error generating Microsummary: " + ex.ToString(), String.Empty)); } }
public XmlRpcManager(IDasBlogSettings settings, ISiteSecurityManager siteSecurityManager) { dasBlogSettings = settings; this.siteSecurityManager = siteSecurityManager; loggingDataService = LoggingDataServiceFactory.GetService(dasBlogSettings.WebRootDirectory + dasBlogSettings.SiteConfiguration.LogDir); dataService = BlogDataServiceFactory.GetService(dasBlogSettings.WebRootDirectory + dasBlogSettings.SiteConfiguration.ContentDir, loggingDataService); }
/// <summary> /// Report-Mailer runs in background thread and this is the thread function. /// </summary> public void Run() { IBlogDataService dataService = null; ILoggingDataService loggingService = null; DateTime lastReportDateUTC = DateTime.Now.ToUniversalTime(); SiteConfig siteConfig = SiteConfig.GetSiteConfig(configPath); loggingService = LoggingDataServiceFactory.GetService(logPath); dataService = BlogDataServiceFactory.GetService(contentPath, loggingService); ErrorTrace.Trace(System.Diagnostics.TraceLevel.Info, "ReportMailer thread spinning up"); loggingService.AddEvent(new EventDataItem(EventCodes.ReportMailerServiceStart, "", "")); do { try { // reload on every cycle to get the current settings siteConfig = SiteConfig.GetSiteConfig(configPath); loggingService = LoggingDataServiceFactory.GetService(logPath); dataService = BlogDataServiceFactory.GetService(contentPath, loggingService); if (siteConfig.EnableDailyReportEmail) { if (siteConfig.SmtpServer != null && siteConfig.SmtpServer.Length > 0 && lastReportDateUTC.Day != DateTime.Now.ToUniversalTime().Day) { // It's a new day so send the report SendEmailReport(lastReportDateUTC, siteConfig, dataService, loggingService); // and update the cached date to today lastReportDateUTC = DateTime.Now.ToUniversalTime(); } } // tick again in an hour Thread.Sleep(TimeSpan.FromSeconds(3600)); } catch (ThreadAbortException abortException) { ErrorTrace.Trace(System.Diagnostics.TraceLevel.Info, abortException); loggingService.AddEvent(new EventDataItem(EventCodes.ReportMailerServiceShutdown, "", "")); break; } catch (Exception e) { // if the siteConfig can't be read, stay running regardless // default wait time is 60 minutes in that case ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error, e); loggingService.AddEvent(new EventDataItem(EventCodes.ReportMailerServiceError, e.ToString().Replace("\n", "<br />"), null, null)); Thread.Sleep(TimeSpan.FromSeconds(3600)); } }while (true); ErrorTrace.Trace(System.Diagnostics.TraceLevel.Info, "ReportMailer thread terminating"); loggingService.AddEvent(new EventDataItem(EventCodes.ReportMailerServiceShutdown, "", "")); }
public BlogManager(ILogger <BlogManager> logger, IDasBlogSettings dasBlogSettings) { this.dasBlogSettings = dasBlogSettings; this.logger = logger; var loggingDataService = LoggingDataServiceFactory.GetService(this.dasBlogSettings.WebRootDirectory + this.dasBlogSettings.SiteConfiguration.LogDir);; dataService = BlogDataServiceFactory.GetService(this.dasBlogSettings.WebRootDirectory + this.dasBlogSettings.SiteConfiguration.ContentDir, loggingDataService); }
public BlogManager(IDasBlogSettings settings, ILogger <BlogManager> logger) { dasBlogSettings = settings; var loggingDataService = LoggingDataServiceFactory.GetService(dasBlogSettings.WebRootDirectory + dasBlogSettings.SiteConfiguration.LogDir); dataService = BlogDataServiceFactory.GetService(dasBlogSettings.WebRootDirectory + dasBlogSettings.SiteConfiguration.ContentDir, loggingDataService); this.logger = logger; }
public XmlRpcManager(IDasBlogSettings dasBlogSettings, ISiteSecurityManager siteSecurityManager, IFileSystemBinaryManager binaryManager) { this.dasBlogSettings = dasBlogSettings; this.siteSecurityManager = siteSecurityManager; this.binaryManager = binaryManager; loggingDataService = LoggingDataServiceFactory.GetService(dasBlogSettings.WebRootDirectory + dasBlogSettings.SiteConfiguration.LogDir); dataService = BlogDataServiceFactory.GetService(dasBlogSettings.WebRootDirectory + dasBlogSettings.SiteConfiguration.ContentDir, loggingDataService); }
public void BlogDataService_GetEntriesWithFalse_Successful() { BlogDataServiceFactory.RemoveService(UnitTestsConstants.TestContentLocation); IBlogDataService blogdataservice = BlogDataServiceFactory.GetService(UnitTestsConstants.TestContentLocation, LoggingDataServiceFactory.GetService(UnitTestsConstants.TestLoggingLocation)); // gets both public and non-public var entries = blogdataservice.GetEntries(false); Assert.Equal(23, entries.Count); }
public BlogManager(ILogger <BlogManager> logger, IOptions <BlogManagerOptions> settingsOptionsAccessor, IOptionsMonitor <BlogManagerModifiableOptions> monitoredOptionsAccessor, IOptions <BlogManagerExtraOptions> extraOptionsAccessor) { opts = new Options(settingsOptionsAccessor, monitoredOptionsAccessor, extraOptionsAccessor); this.logger = logger; var loggingDataService = LoggingDataServiceFactory.GetService(opts.WebRootDirectory + opts.LogDir); dataService = BlogDataServiceFactory.GetService(opts.WebRootDirectory + opts.ContentDir, loggingDataService); }
public FeedController(ISubscriptionManager subscriptionManager, IHttpContextAccessor httpContextAccessor, IXmlRpcManager xmlRpcManager, IMemoryCache memoryCache, IDasBlogSettings dasBlogSettings) { this.subscriptionManager = subscriptionManager; this.xmlRpcManager = xmlRpcManager; this.memoryCache = memoryCache; this.dasBlogSettings = dasBlogSettings; loggingDataService = LoggingDataServiceFactory.GetService(dasBlogSettings.WebRootDirectory + dasBlogSettings.SiteConfiguration.LogDir); }
public void SetUpTests() { ILoggingDataService loggingService; loggingService = LoggingDataServiceFactory.GetService( Path.Combine(ReflectionHelper.CodeBase(), @"logs")); BlogDataService = BlogDataServiceFactory.GetService( Path.Combine(ReflectionHelper.CodeBase(), @"Content"), loggingService); }
public Entry GetEntry(string entryId) { SiteConfig siteConfig = SiteConfig.GetSiteConfig(); ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); Entry entry = dataService.GetEntry(entryId); return(entry); }
public SyndicationServiceBase() { InitializeComponent(); if (Context != null) { siteConfig = SiteConfig.GetSiteConfig(); loggingService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), loggingService); cache = CacheFactory.GetCache(); } }
public FileSystemBinaryManager(IDasBlogSettings settings) { var siteConfig = settings.SiteConfiguration; virtBinaryPathRelativeToContentRoot = siteConfig.BinariesDir.TrimStart('~'); // => "/content/binary" var physBinaryPath = Path.Combine(settings.WebRootDirectory, virtBinaryPathRelativeToContentRoot.TrimStart('/')); Uri physBinaryPathUrl = new Uri(physBinaryPath); var loggingDataService = LoggingDataServiceFactory.GetService(settings.WebRootDirectory + settings.SiteConfiguration.LogDir); dataService = BinaryDataServiceFactory.GetService(physBinaryPath, physBinaryPathUrl, loggingDataService); }
private static void LogSuccess(string userName) { ILoggingDataService loggingService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); if (HttpContext.Current == null) { loggingService.AddEvent(new EventDataItem(EventCodes.SecuritySuccess, userName, "non-web")); } else { loggingService.AddEvent(new EventDataItem(EventCodes.SecuritySuccess, userName, HttpContext.Current.Request.UserHostAddress)); } }
public FileSystemBinaryManager(IDasBlogSettings settings) { var siteConfig = settings.SiteConfiguration; virtBinaryPathRelativeToContentRoot = siteConfig.BinariesDir.TrimStart('~'); // => "/content/binary" string physBinaryPath = Path.Combine(settings.WebRootDirectory, virtBinaryPathRelativeToContentRoot.TrimStart('/')); // => "c:\...\DaBlog.Web.UI\content/binary" // WebRootDirectory is a misnomer. It should be called ContentRootDirectory // ContentRootDirectory is not "c:\...\DasBlog.Web.UI\contnet". It is actually "c:\...\DasBlog.Web.UI" // WebRootDirectory is "wwwroot". Uri physBinaryPathUrl = new Uri(physBinaryPath); var loggingDataService = LoggingDataServiceFactory.GetService(settings.WebRootDirectory + settings.SiteConfiguration.LogDir); dataService = BinaryDataServiceFactory.GetService(physBinaryPath, physBinaryPathUrl, loggingDataService); }
public void ProcessRequest(HttpContext context) { SiteConfig siteConfig = SiteConfig.GetSiteConfig(); string sourceId; string referrerUrl; /* * This service is a bit diffent from the other handlers, because * the "bugs" are out in the wild regardless of whether the service is * enabled. So the service must yield a valid result, regardless of * whetr */ if (siteConfig.EnableCrossposts) { sourceId = context.Request.QueryString["id"]; referrerUrl = context.Request.UrlReferrer != null?context.Request.UrlReferrer.ToString() : ""; try { ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); Entry entry = dataService.GetEntry(sourceId); if (entry != null) { // we'll check whether the entry exists just to avoid trash in the DB logService.AddCrosspostReferrer( new LogDataItem( SiteUtilities.GetPermaLinkUrl(siteConfig, sourceId), referrerUrl, context.Request.UserAgent, context.Request.UserHostName)); } else { StackTrace st = new StackTrace(); logService.AddEvent(new EventDataItem(EventCodes.Error, "Entry was not found: " + sourceId + " " + st.ToString(), "")); } } catch (Exception exc) { // absorb ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error, exc); } } context.Response.OutputStream.Write(aggBugBitmap, 0, aggBugBitmap.Length); context.Response.ContentType = "image/gif"; context.Response.StatusCode = 200; context.Response.End(); }
public FileSystemBinaryManager(IDasBlogSettings dasBlogSettings, IConfigFileService <MetaTags> metaTagFileService, IConfigFileService <SiteConfig> siteConfigFileService, IOptions <ConfigFilePathsDataOption> optionsAccessor) { this.dasBlogSettings = dasBlogSettings; this.metaTagFileService = metaTagFileService; this.siteConfigFileService = siteConfigFileService; options = optionsAccessor.Value; contentBinaryUrl = dasBlogSettings.RelativeToRoot(options.BinaryUrlRelative); var physBinaryPathUrl = new Uri(contentBinaryUrl); var loggingDataService = LoggingDataServiceFactory.GetService(Path.Combine(dasBlogSettings.WebRootDirectory, dasBlogSettings.SiteConfiguration.LogDir)); this.binaryDataService = BinaryDataServiceFactory.GetService(options.BinaryFolder, physBinaryPathUrl, loggingDataService); }
public BlogManager(IDasBlogSettings settings, ILogger <BlogManager> logger , IOptions <BlogManagerOptions> settingsOptionsAccessor , IOptionsMonitor <BlogManagerModifiableOptions> monitoredOptionsAccessor , IOptions <BlogManagerExtraOptions> extraOptionsAccessor ) { opts = new Options(settingsOptionsAccessor, monitoredOptionsAccessor, extraOptionsAccessor); this.logger = logger; dasBlogSettings = settings; var loggingDataService = LoggingDataServiceFactory.GetService(Pass(() => dasBlogSettings.WebRootDirectory, () => opts.WebRootDirectory) + Pass(() => dasBlogSettings.SiteConfiguration.LogDir, () => opts.LogDir)); dataService = BlogDataServiceFactory.GetService(Pass(() => dasBlogSettings.WebRootDirectory, () => opts.WebRootDirectory) + Pass(() => dasBlogSettings.SiteConfiguration.ContentDir, () => opts.ContentDir), loggingDataService); }
public void ProcessRequest(HttpContext context) { try { //Cache the sitemap for 8 hours... DataCache cache = CacheFactory.GetCache(); string CacheKey = "TimelineXml"; timeline root = cache[CacheKey] as timeline; if (root == null) //we'll have to build it... { ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); SiteConfig siteConfig = SiteConfig.GetSiteConfig(); root = new timeline(); root.events = new eventCollection(); int i = 0; //All Pages (stop after 750...it gets too big and the browser can't handle it...we'd need // to include dynamic paging EntryCollection entryCache = dataService.GetEntries(false); //Fortunately this comes in ordered by post date, descending foreach (Entry e in entryCache) { if (e.IsPublic && (++i < 750)) { //then add permalinks string url = SiteUtilities.GetPermaLinkUrl(siteConfig, (ITitledEntry)e); @event foo = new @event(e.CreatedLocalTime, false, TruncateDotDotDot(StripAllTags(e.Title), 50), url); foo.text += String.Format("<div align=\"right\"><a href=\"{0}\">More...</a></div>", url); root.events.Add(foo); } } cache.Insert(CacheKey, root, DateTime.Now.AddHours(8)); } XmlSerializer x = new XmlSerializer(typeof(timeline)); x.Serialize(HttpContext.Current.Response.OutputStream, root); HttpContext.Current.Response.ContentType = "text/xml"; } catch (Exception exc) { ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error, exc); } }
public static void RemoveBlacklist(Type type) { ILoggingDataService loggingService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); if (blacklists.ContainsKey(type.Name) == true) { try { blacklists.Remove(type.Name); } catch (Exception ex) { loggingService.AddEvent(new EventDataItem(EventCodes.Error, type.Name.ToString() + " could not be removed: " + ex.ToString(), "")); } } }
public FileSystemBinaryManager(IDasBlogSettings dasBlogSettings, IConfigFileService <MetaTags> metaTagFileService, IConfigFileService <SiteConfig> siteConfigFileService) { this.dasBlogSettings = dasBlogSettings; this.metaTagFileService = metaTagFileService; this.siteConfigFileService = siteConfigFileService; var siteConfig = this.dasBlogSettings.SiteConfiguration; virtBinaryPathRelativeToContentRoot = siteConfig.BinariesDir.TrimStart('~'); var physBinaryPath = Path.Combine(this.dasBlogSettings.WebRootDirectory, virtBinaryPathRelativeToContentRoot.TrimStart('/')); var physBinaryPathUrl = new Uri(physBinaryPath); var loggingDataService = LoggingDataServiceFactory.GetService(dasBlogSettings.WebRootDirectory + dasBlogSettings.SiteConfiguration.LogDir); dataService = BinaryDataServiceFactory.GetService(physBinaryPath, physBinaryPathUrl, loggingDataService); }
public void ProcessRequest(HttpContext context) { SiteConfig siteConfig = SiteConfig.GetSiteConfig(); string targetUrl; string sourceId; if (!siteConfig.EnableClickThrough) { context.Response.StatusCode = 503; context.Response.Status = "503 Service Unavailable"; context.Response.End(); return; } sourceId = context.Request.QueryString["id"]; targetUrl = context.Request.QueryString["url"]; if (targetUrl == null || targetUrl.Length == 0) { context.Response.Redirect(SiteUtilities.GetStartPageUrl(siteConfig)); return; } else { try { ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); Entry entry = dataService.GetEntry(sourceId); if (entry != null) { // we'll check whether the entry exists just to avoid trash in the DB logService.AddClickThrough( new LogDataItem(targetUrl, SiteUtilities.GetPermaLinkUrl(siteConfig, sourceId), context.Request.UserAgent, context.Request.UserHostName)); } } catch (Exception exc) { // absorb ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error, exc); } } context.Response.Redirect(targetUrl); }
public void DeleteEntry(string entryId, string username, string password) { SiteConfig siteConfig = SiteConfig.GetSiteConfig(); if (!siteConfig.EnableEditService) { throw new ServiceDisabledException(); } Authenticate(username, password); ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); //dataService.DeleteEntry(entryId, siteConfig.CrosspostSites); SiteUtilities.DeleteEntry(entryId, siteConfig, logService, dataService); }