public void BlogDataService_ArchiveMonthSearch_Successful(IBlogDataService blogdataservice) { var dt = new DateTime(2004, 3, 1); var entries = blogdataservice.GetEntriesForMonth(dt, DateTimeZone.Utc, ""); Assert.Equal(5, entries.Count); }
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 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); }
public PingbackAPI() { siteConfig = SiteConfig.GetSiteConfig(); logDataService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logDataService); }
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 void BlogDataService_SearchEntries_Successful(IBlogDataService blogdataservice) { //// var entries = blogdataservice.GetEntriesForDay(DateTime.MaxValue.AddDays(-2), DateTimeZone.Utc, string.Empty, int.MaxValue, int.MaxValue, string.Empty); Assert.NotNull(entries); }
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 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 GetEntriesForDay() { IBlogDataService dataService = BlogDataServiceFactory.GetService(createEntries.FullName, null); // this will create an entry for each hour of the day in local time for (int i = 0; i < 24; i++) { Entry entry = TestEntry.CreateEntry(String.Format("Test Entry {0}", i), 5, 2); entry.CreatedUtc = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, i, 0, 0).ToUniversalTime(); dataService.SaveEntry(entry, null); } EntryCollection entries = dataService.GetEntriesForDay(DateTime.Now, TimeZone.CurrentTimeZone, String.Empty, int.MaxValue, int.MaxValue, String.Empty); Assert.AreEqual(24, entries.Count); foreach (Entry entry in entries) { // this test will make sure that the entries are all in the right day Entry lookup = dataService.GetEntry(entry.EntryId); Assert.IsNotNull(lookup); Assert.AreEqual(0, lookup.CompareTo(entry)); Assert.AreEqual(DateTime.Now.Date, entry.CreatedLocalTime.Date); } }
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 static void Save(DayExtra dayExtra, IBlogDataService dataService) { FileStream fileStream = FileUtils.OpenForWrite(Path.Combine(ContentPath, dayExtra.FileName)); if (fileStream != null) { try { XmlSerializer ser = new XmlSerializer(typeof (DayExtra), "urn:newtelligence-com:dasblog:runtime:data"); using (StreamWriter writer = new StreamWriter(fileStream)) { ser.Serialize(writer, dayExtra); } } catch (Exception ex) { WriteLine(String.Format("ERROR: Cannot write file: {0}", dayExtra.FileName)); WriteLine(ex.ToString()); } finally { fileStream.Close(); } } }
public SyndicationServiceBase(SiteConfig siteConfig, IBlogDataService dataService, ILoggingDataService loggingService) { InitializeComponent(); this.dataService = dataService; this.loggingService = loggingService; this.siteConfig = siteConfig; }
public static void Save(DayExtra dayExtra, IBlogDataService dataService) { FileStream fileStream = FileUtils.OpenForWrite(Path.Combine(ContentPath, dayExtra.FileName)); if (fileStream != null) { try { XmlSerializer ser = new XmlSerializer(typeof(DayExtra), "urn:newtelligence-com:dasblog:runtime:data"); using (StreamWriter writer = new StreamWriter(fileStream)) { ser.Serialize(writer, dayExtra); } } catch (Exception ex) { WriteLine(String.Format("ERROR: Cannot write file: {0}", dayExtra.FileName)); WriteLine(ex.ToString()); } finally { fileStream.Close(); } } }
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 SendEmailReport(DateTime reportDate, SiteConfig siteConfig, IBlogDataService dataService, ILoggingDataService loggingService) { MailMessage emailMessage = new MailMessage(); if (siteConfig.NotificationEMailAddress != null && siteConfig.NotificationEMailAddress.Length > 0) { emailMessage.To.Add(siteConfig.NotificationEMailAddress); } else { emailMessage.To.Add(siteConfig.Contact); } emailMessage.Subject = String.Format("Weblog Daily Activity Report for '{0}'", reportDate.ToLongDateString()); emailMessage.Body = GenerateReportEmailBody(reportDate); emailMessage.IsBodyHtml = true; emailMessage.BodyEncoding = System.Text.Encoding.UTF8; emailMessage.From = new MailAddress(siteConfig.Contact); SendMailInfo sendMailInfo = new SendMailInfo(emailMessage, siteConfig.SmtpServer, siteConfig.EnableSmtpAuthentication, siteConfig.UseSSLForSMTP, siteConfig.SmtpUserName, siteConfig.SmtpPassword, siteConfig.SmtpPort); dataService.AddTracking(null, sendMailInfo); // use this with null tracking object, just to get the email sent loggingService.AddEvent(new EventDataItem(EventCodes.ReportMailerReportSent, "", "")); }
/// <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(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 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 void SetUpTests() { ILoggingDataService loggingService; loggingService = LoggingDataServiceFactory.GetService( Path.Combine(ReflectionHelper.CodeBase(),@"logs")); BlogDataService = BlogDataServiceFactory.GetService( Path.Combine(ReflectionHelper.CodeBase(),@"Content"), loggingService); }
public virtual void TearDown() { if(Directory.Exists(ContentDirectory)) { Directory.Delete(ContentDirectory, true); } DataService = null; }
public virtual void SetUp() { if(!Directory.Exists(ContentDirectory)) { Directory.CreateDirectory(ContentDirectory); } DataService = BlogDataServiceFactory.GetService(ContentDirectory, null); }
public static void FixDays(string path) { ContentPath = path; IBlogDataService dataService = BlogDataServiceFactory.GetService(ContentPath, null); EntryCollection entries = dataService.GetEntriesForDay( DateTime.MaxValue.AddDays(-2), TimeZone.CurrentTimeZone, String.Empty, int.MaxValue, int.MaxValue, String.Empty); Hashtable DayEntries = new Hashtable(); foreach (Entry entry in entries) { DayEntry dayEntry = new DayEntry(); dayEntry.DateUtc = entry.CreatedUtc; if (DayEntries.ContainsKey(entry.CreatedUtc.Date)) { dayEntry = DayEntries[entry.CreatedUtc.Date] as DayEntry; } dayEntry.Entries.Add(entry); DayEntries[entry.CreatedUtc.Date] = dayEntry; } DirectoryInfo directoryInfo = new DirectoryInfo(path); foreach (FileInfo fileInfo in directoryInfo.GetFiles("*.dayentry.xml")) { // backup the old file try { DirectoryInfo backup = new DirectoryInfo(Path.Combine(directoryInfo.FullName, "backup")); if (!backup.Exists) { backup.Create(); } fileInfo.MoveTo(Path.Combine(backup.FullName, fileInfo.Name)); } catch (Exception e) { ErrorTrace.Trace(TraceLevel.Error, e); } } foreach (DayEntry dayEntry in DayEntries.Values) { Save(dayEntry, path); } }
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); }
protected IBlogDataService GetDataService() { BlogDataServiceFactory.RemoveService(dasBlogContent.FullName); localhostBlogService = BlogDataServiceFactory.GetService( dasBlogContent.FullName, loggingService); Assert.IsNotNull(localhostBlogService); return(localhostBlogService); }
protected IBlogDataService GetDataService() { BlogDataServiceFactory.RemoveService(dasBlogContent.FullName); localhostBlogService = BlogDataServiceFactory.GetService( dasBlogContent.FullName, loggingService); Assert.IsNotNull(localhostBlogService); return localhostBlogService; }
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 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 SyndicationServiceBase() { InitializeComponent(); if (Context != null) { siteConfig = SiteConfig.GetSiteConfig(); loggingService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), loggingService); cache = CacheFactory.GetCache(); } }
public static string CreateSeoMetaInformation(EntryCollection weblogEntries, IBlogDataService dataService) { string metaTags = "\r\n"; string currentUrl = HttpContext.Current.Request.Url.AbsoluteUri; if (currentUrl.IndexOf("categoryview.aspx", StringComparison.OrdinalIgnoreCase) > -1 || currentUrl.IndexOf("default.aspx?month=", StringComparison.OrdinalIgnoreCase) > -1) { metaTags += MetaNoindexFollowPattern; } else if (currentUrl.IndexOf("permalink.aspx", StringComparison.OrdinalIgnoreCase) > -1) { if (weblogEntries.Count >= 1) { Entry entry = weblogEntries[0]; metaTags = GetMetaTags(metaTags, entry); } } else if (currentUrl.IndexOf("commentview.aspx", StringComparison.OrdinalIgnoreCase) > -1 && !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["guid"])) { Entry entry = dataService.GetEntry(HttpContext.Current.Request.QueryString["guid"]); if (entry != null) { metaTags = GetMetaTags(metaTags, entry); } } else if (currentUrl.IndexOf("commentview.aspx", StringComparison.OrdinalIgnoreCase) > -1 && !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["title"])) { Entry entry = dataService.GetEntry(HttpContext.Current.Request.QueryString["title"]); if (entry != null) { metaTags = GetMetaTags(metaTags, entry); } } else if (currentUrl.IndexOf("default.aspx", StringComparison.OrdinalIgnoreCase) > -1) { var smt = new SeoMetaTags(); smt = smt.GetMetaTags(); if (smt != null) { if (!string.IsNullOrEmpty(smt.MetaDescription)) { metaTags += string.Format(MetaDescriptionTagPattern, smt.MetaDescription); } if (!string.IsNullOrEmpty(smt.MetaKeywords)) { metaTags += string.Format(MetaKeywordTagPattern, smt.MetaKeywords); } } metaTags += string.Format(CanonicalLinkPattern, SiteUtilities.GetBaseUrl()); } return(metaTags); }
public static string CreateSeoMetaInformation(EntryCollection weblogEntries, IBlogDataService dataService) { string metaTags = "\r\n"; string currentUrl = HttpContext.Current.Request.Url.AbsoluteUri; if (currentUrl.IndexOf("categoryview.aspx", StringComparison.OrdinalIgnoreCase) > -1 || currentUrl.IndexOf("default.aspx?month=", StringComparison.OrdinalIgnoreCase) > -1) { metaTags += MetaNoindexFollowPattern; } else if (currentUrl.IndexOf("permalink.aspx", StringComparison.OrdinalIgnoreCase) > -1) { if (weblogEntries.Count >= 1) { Entry entry = weblogEntries[0]; metaTags = GetMetaTags(metaTags, entry); } } else if (currentUrl.IndexOf("commentview.aspx", StringComparison.OrdinalIgnoreCase) > -1 && !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["guid"])) { Entry entry = dataService.GetEntry(HttpContext.Current.Request.QueryString["guid"]); if (entry != null) { metaTags = GetMetaTags(metaTags, entry); } } else if (currentUrl.IndexOf("commentview.aspx", StringComparison.OrdinalIgnoreCase) > -1 && !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["title"])) { Entry entry = dataService.GetEntry(HttpContext.Current.Request.QueryString["title"]); if (entry != null) { metaTags = GetMetaTags(metaTags, entry); } } else if (currentUrl.IndexOf("default.aspx", StringComparison.OrdinalIgnoreCase) > -1) { var smt = new SeoMetaTags(); smt = smt.GetMetaTags(); if (smt != null) { if (!string.IsNullOrEmpty(smt.MetaDescription)) { metaTags += string.Format(MetaDescriptionTagPattern, smt.MetaDescription); } if (!string.IsNullOrEmpty(smt.MetaKeywords)) { metaTags += string.Format(MetaKeywordTagPattern, smt.MetaKeywords); } } metaTags += string.Format(CanonicalLinkPattern, SiteUtilities.GetBaseUrl()); } return metaTags; }
public BlogService(IBlogDataService blogService) { // create mapper _mapper = new MapperConfiguration( cfg => { cfg.CreateMap <Core.BusinessModels.Blog.Blog, BlogModel>(); cfg.CreateMap <BlogModel, Core.BusinessModels.Blog.Blog>(); cfg.CreateMap <Core.BusinessModels.Blog.Blog, BlogDto>(); }).CreateMapper();; _blogService = blogService; }
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 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 GetEntry() { IBlogDataService dataService = BlogDataServiceFactory.GetService(createEntries.FullName, null); Entry entry = TestEntry.CreateEntry(String.Format("Test Entry"), 5, 2); dataService.SaveEntry(entry, null); DateTime dt = DateTime.Now; Entry returnEntry = dataService.GetEntry(entry.EntryId); TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - dt.Ticks); Console.WriteLine(ts.Milliseconds); Assert.AreEqual(0, entry.CompareTo(returnEntry)); }
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()); testLogs = new DirectoryInfo(Path.Combine(root.Parent.FullName, "TestLogs")); Assert.IsTrue(testLogs.Exists); loggingService = LoggingDataServiceFactory.GetService( testLogs.FullName); Assert.IsNotNull(loggingService); dasBlogContent = new DirectoryInfo("../../../newtelligence.DasBlog.Web/content"); localhostBlogService = GetDataService(); }
public static void RepairComments(DayExtra dayExtra, IBlogDataService dataService) { //SDH: Corruption or poorly imported comments can have no entry id! // Create one if it's missing. This will slowly repair the damage for (int i = 0; i < dayExtra.Comments.Count; i++) { if (dayExtra.Comments[i].EntryId == null) { dayExtra.Comments[i].EntryId = Guid.NewGuid().ToString(); Entry entry = dataService.GetEntry(dayExtra.Comments[i].TargetEntryId); if (entry != null) { dayExtra.Comments[i].TargetTitle = entry.Title; } WriteLine(String.Format("...Repaired Comments in {0}", dayExtra.FileName)); } } }
public static void SaveEntry(Entry entry, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { SaveEntry(entry, string.Empty, crosspostList, siteConfig, logService, dataService); }
public static void SaveEntry(Entry entry, string trackbackUrl, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { TrackbackInfoCollection trackbackList = null; if (trackbackUrl != null && trackbackUrl.Length > 0) { trackbackList = new TrackbackInfoCollection(); trackbackList.Add(new TrackbackInfo( trackbackUrl, SiteUtilities.GetPermaLinkUrl(siteConfig, entry), entry.Title, entry.Description, siteConfig.Title)); } InternalSaveEntry(entry, trackbackList, crosspostList, siteConfig, logService, dataService); logService.AddEvent( new EventDataItem( EventCodes.EntryAdded, entry.Title, SiteUtilities.GetPermaLinkUrl(siteConfig, entry.EntryId))); }
public SyndicationServiceExperimentalImplementation(SiteConfig siteConfig, IBlogDataService dataService, ILoggingDataService loggingService): base( siteConfig, dataService, loggingService ) { //CODEGEN: This call is required by the ASP.NET Web Services Designer InitializeComponent(); }
public BloggerAPI() { this.siteConfig = SiteConfig.GetSiteConfig(); this.logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); this.dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService ); }
public static void SaveEntry(Entry entry, TrackbackInfoCollection trackbackList, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { InternalSaveEntry(entry, trackbackList, crosspostList, siteConfig, logService, dataService); logService.AddEvent( new EventDataItem( EventCodes.EntryAdded, entry.Title, SiteUtilities.GetPermaLinkUrl(siteConfig, entry.EntryId))); }
public void SendEmailReport(DateTime reportDate, SiteConfig siteConfig, IBlogDataService dataService, ILoggingDataService loggingService) { MailMessage emailMessage = new MailMessage(); if ( siteConfig.NotificationEMailAddress != null && siteConfig.NotificationEMailAddress.Length > 0 ) { emailMessage.To.Add(siteConfig.NotificationEMailAddress); } else { emailMessage.To.Add(siteConfig.Contact); } emailMessage.Subject = String.Format("Weblog Daily Activity Report for '{0}'", reportDate.ToLongDateString()); emailMessage.Body = GenerateReportEmailBody(reportDate); emailMessage.IsBodyHtml = true; emailMessage.BodyEncoding = System.Text.Encoding.UTF8; emailMessage.From = new MailAddress(siteConfig.Contact); SendMailInfo sendMailInfo = new SendMailInfo(emailMessage, siteConfig.SmtpServer, siteConfig.EnableSmtpAuthentication, siteConfig.UseSSLForSMTP, siteConfig.SmtpUserName, siteConfig.SmtpPassword, siteConfig.SmtpPort); dataService.AddTracking(null, sendMailInfo ); // use this with null tracking object, just to get the email sent loggingService.AddEvent( new EventDataItem( EventCodes.ReportMailerReportSent,"","")); }
public static DateTime GetLatestModifedEntryDateTime(IBlogDataService dataService, EntryCollection entries) { // Check to see if we should send a HTTP 304 letting the RSS client // know that they have the latest version of the feed DateTime latest = DateTime.MinValue; // need to check to see if the last entry value doesn't exist // if it doesn't loop through posts to get the latest date if (dataService.GetLastEntryUpdate() == DateTime.MinValue) { foreach (Entry entry in entries) { DateTime created = entry.ModifiedLocalTime; if (created > latest) latest = created; } } else { latest = dataService.GetLastEntryUpdate().ToLocalTime(); } // we need to check to see if a comment entry has occured // after the last entry update. If it has don't return 304 DateTime latestComment = dataService.GetLastCommentUpdate(); if ( ( latestComment != DateTime.MinValue ) && ( latest < latestComment.ToLocalTime() ) ) latest = latestComment.ToLocalTime(); return new DateTime(latest.Year, latest.Month, latest.Day, latest.Hour, latest.Minute, latest.Second); }
internal CrosspostJob(object info, Entry entry, IBlogDataService dataService) { this.info = info; this.entry = entry; this.dataService = dataService; }
public static void SaveEntry(Entry entry, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { SiteUtilities.SaveEntry(entry,siteConfig,logService,dataService); }
public static EntrySaveState UpdateEntry(Entry entry, string trackbackUrl, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { EntrySaveState rtn = EntrySaveState.Failed; entry.ModifiedLocalTime = DateTime.Now; TrackbackInfoCollection trackbackList = null; if (trackbackUrl != null && trackbackUrl.Length > 0) { trackbackList = new TrackbackInfoCollection(); trackbackList.Add(new TrackbackInfo( trackbackUrl, SiteUtilities.GetPermaLinkUrl(siteConfig, entry), entry.Title, entry.Description, siteConfig.Title)); } rtn = InternalSaveEntry(entry, trackbackList, crosspostList, siteConfig, logService, dataService); logService.AddEvent( new EventDataItem( EventCodes.EntryChanged, entry.Title, SiteUtilities.GetPermaLinkUrl(entry.EntryId))); return rtn; }
public static void SaveEntry(Entry entry, TrackbackInfoCollection trackbackList, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { SiteUtilities.SaveEntry(entry,trackbackList,crosspostList,siteConfig,logService,dataService); }
private static EntrySaveState InternalSaveEntry(Entry entry, TrackbackInfoCollection trackbackList, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { EntrySaveState rtn = EntrySaveState.Failed; // we want to prepopulate the cross post collection with the crosspost footer if (siteConfig.EnableCrossPostFooter && siteConfig.CrossPostFooter != null && siteConfig.CrossPostFooter.Length > 0) { foreach (CrosspostInfo info in crosspostList) { info.CrossPostFooter = siteConfig.CrossPostFooter; } } // now save the entry, passign in all the necessary Trackback and Pingback info. try { // if the post is missing a title don't publish it if (entry.Title == null || entry.Title.Length == 0) { entry.IsPublic = false; } // if the post is missing categories, then set the categories to empty string. if (entry.Categories == null) entry.Categories = ""; rtn = dataService.SaveEntry( entry, (siteConfig.PingServices.Count > 0) ? new WeblogUpdatePingInfo(siteConfig.Title, SiteUtilities.GetBaseUrl(siteConfig), SiteUtilities.GetBaseUrl(siteConfig), SiteUtilities.GetRssUrl(siteConfig), siteConfig.PingServices) : null, (entry.IsPublic) ? trackbackList : null, siteConfig.EnableAutoPingback && entry.IsPublic ? new PingbackInfo( SiteUtilities.GetPermaLinkUrl(siteConfig, entry), entry.Title, entry.Description, siteConfig.Title) : null, crosspostList); SendEmail(entry, siteConfig, logService); } catch (Exception ex) { StackTrace st = new StackTrace(); logService.AddEvent( new EventDataItem(EventCodes.Error, ex.ToString() + Environment.NewLine + st.ToString(), "")); } // we want to invalidate all the caches so users get the new post BreakCache(siteConfig, entry.GetSplitCategories()); // give the XSS upstreamer a hint that things have changed //FIX: XSSUpstreamer.TriggerUpstreaming(); return rtn; }
/// <summary> /// Deletes an entry, including comments enclosures etc. /// </summary> /// <remarks>Admins can delete all, contributors only their own.</remarks> /// <param name="entryId">The entry to delete.</param> /// <param name="siteConfig"></param> /// <param name="logService"></param> /// <param name="dataService"></param> public static void DeleteEntry(string entryId, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { try { IPrincipal user = HttpContext.Current.User; Entry entry = dataService.GetEntry(entryId); //fix: admins can delete all, contributors only their own if (!CanEdit(user, entry)) { throw new SecurityException("Current user is not allowed to delete this entry!"); } string permalink = SiteUtilities.GetPermaLinkUrl(entry.EntryId); //string[] categories = entry.GetSplitCategories(); dataService.DeleteEntry(entryId, siteConfig.CrosspostSites); BreakCache(siteConfig, entry.GetSplitCategories()); // give the XSS upstreamer a hint that things have changed //FIX: XSSUpstreamer.TriggerUpstreaming(); // TODO: when we add support for more than just enclosures, we can't delete the entire folder DirectoryInfo enclosuresPath = new DirectoryInfo((Path.Combine(SiteConfig.GetBinariesPathFromCurrentContext(), entryId))); if (enclosuresPath.Exists) enclosuresPath.Delete(true); logService.AddEvent( new EventDataItem( EventCodes.EntryDeleted, entry.Title, permalink)); } catch (SecurityException) { throw; } catch (Exception ex) { StackTrace st = new StackTrace(); logService.AddEvent( new EventDataItem(EventCodes.Error, ex.ToString() + Environment.NewLine + st.ToString(), HttpContext.Current.Request.RawUrl)); // DESIGN: We should rethrow the exception for the calling class, but this break too much for this point release. } }
public static void SaveEntry(Entry entry, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { SaveEntry(entry, string.Empty, null, siteConfig, logService, dataService); }
public static void DeleteEntry(string entryId, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { SiteUtilities.DeleteEntry(entryId,siteConfig,logService,dataService); }
public static DateTime GetLatestModifedEntryDateTime(IBlogDataService dataService, EntryCollection entries) { return SiteUtilities.GetLatestModifedEntryDateTime(dataService, entries); }
public static EntrySaveState UpdateEntry(Entry entry, string trackbackUrl, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { return SiteUtilities.UpdateEntry(entry,trackbackUrl,crosspostList,siteConfig,logService,dataService); }
public static DateTime GetLatestModifedCommentDateTime(IBlogDataService dataService, CommentCollection comments) { return SiteUtilities.GetLatestModifedCommentDateTime(dataService,comments); }