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 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);
        }
Esempio n. 3
0
        public PingbackAPI()
        {
            siteConfig = SiteConfig.GetSiteConfig();

            logDataService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext());
            dataService    = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logDataService);
        }
        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);
        }
Esempio n. 5
0
        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, "", ""));
        }
Esempio n. 6
0
 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 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);
            }
        }
Esempio n. 8
0
        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));
            }
        }
Esempio n. 9
0
 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);
 }
Esempio n. 10
0
        /// <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, "", ""));
        }
Esempio n. 11
0
 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);
 }
Esempio n. 12
0
        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;
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        public virtual void SetUp()
        {
            if (!Directory.Exists(ContentDirectory))
            {
                Directory.CreateDirectory(ContentDirectory);
            }

            DataService = BlogDataServiceFactory.GetService(ContentDirectory, null);
        }
Esempio n. 15
0
        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);
            }
        }
Esempio n. 16
0
        protected IBlogDataService GetDataService()
        {
            BlogDataServiceFactory.RemoveService(dasBlogContent.FullName);
            localhostBlogService = BlogDataServiceFactory.GetService(
                dasBlogContent.FullName,
                loggingService);
            Assert.IsNotNull(localhostBlogService);

            return(localhostBlogService);
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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);
        }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
 public SyndicationServiceBase()
 {
     InitializeComponent();
     if (Context != null)
     {
         siteConfig     = SiteConfig.GetSiteConfig();
         loggingService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext());
         dataService    = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), loggingService);
         cache          = CacheFactory.GetCache();
     }
 }
        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 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));
        }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        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 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);
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
        public static void FixIsPublic(string path)
        {
            ContentPath = path;

            BlogDataServiceFactory.RemoveService(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);

            foreach (Entry e in entries)
            {
                //if (e.IsPublic == false)
                {
                    try
                    {
                        Entry edit = dataService.GetEntryForEdit(e.EntryId);
                        edit.IsPublic = true;

                        if (edit.Categories == String.Empty)
                        {
                            edit.Categories = "Main";
                        }
                        EntrySaveState saved = dataService.SaveEntry(edit);

                        if (saved == EntrySaveState.Failed)
                        {
                            WriteLine(String.Format("Failed saving {0}", e.Title));
                        }
                        else
                        {
                            WriteLine(String.Format("Saved {0}", e.Title));
                        }
                    }
                    catch (Exception e1)
                    {
                        WriteLine(String.Format("Failed saving {0}, {1}", e.Title, e1.ToString()));
                    }
                }
            }
        }
        public void GetDaysWithEntries()
        {
            List <int>       dayNumbers  = new List <int>();
            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.AddDays(i).Day, 1, 0, 0).ToUniversalTime();
                dayNumbers.Add(DateTime.Now.AddDays(i).Day);
                i++;
                dataService.SaveEntry(entry, null);
            }

            DateTime[] days = dataService.GetDaysWithEntries(TimeZone.CurrentTimeZone);

            for (int i = 0; i < 12; i++)
            {
                int num = (int)dayNumbers[11 - i];
                Assert.AreEqual(num, days[i].Day);
                i++;
            }
        }
        public Entry GetEntry(DateTime entryDate, string entryTitle)
        {
            SiteConfig          siteConfig  = SiteConfig.GetSiteConfig();
            ILoggingDataService logService  = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext());
            IBlogDataService    dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService);

            //Only pass in the date portion of the entry date, do not pass in the time portion.
            DayEntry dayEntry = dataService.GetDayEntry(entryDate.Date);

            //this replacement of characters in the title was lifted directly from
            //  DasBlog.Web.Core::TitleMapperModule.HandleBeginRequest()
            entryTitle = entryTitle.Replace(".aspx", "");
            entryTitle = entryTitle.Replace("+", "");
            entryTitle = entryTitle.Replace(" ", "");
            entryTitle = entryTitle.Replace("%2b", "");
            entryTitle = entryTitle.Replace("%20", "");

            //now that we have a properly formatted title, use it to get a specific
            //  entry from the DayEntry object.  If there is more than one match to the
            //  title, the most recent entry will be matched.
            Entry entry = dayEntry.GetEntryByTitle(entryTitle);

            return(entry);
        }