.NET (29) Archiving (10) ASP.NET (9) Books (3) C Sharp (30) Code Generation (3) Dasblog (16) Design Patterns (4) Development (37) Exchange (14) Family (10) GPS (7) Hardware (10) mixuk07 (1) Mountaineering (7) MSCRM (6) Office (3) Outlook (13) Personal Development (4) PHP (4) PowerShell (7) Productivity (9) RSS (15) Running (2) Scripting (20) SCRUM (3) Service (3) Software (60) Support (17) TaHoGen (2) Technical (50) Tools (13) Twitter (5) Web (16) Windows 7 (4) Windows Mobile (10) WS* (1)
Sign In
Here's the code for the macros I created - feel free to copy / compile it yourself. I also included a compiled DLL here - BUT it is compiled against .NET2.0 so will only work if your hosting Dasblog in a ASP.NET2.0 virtual directory.
using System;
using System.Collections;
using System.Text;
using System.Web.UI;
using newtelligence.DasBlog.Runtime;
using newtelligence.DasBlog.Web.Core;
using newtelligence.DasBlog.Util;
namespace KensDasblogMacros
{
public class KensMacros
protected SharedBasePage sharedBasePage;
protected Entry currentEntry;
public KensMacros(SharedBasePage page, Entry entry)
sharedBasePage = page;
currentEntry = entry;
}
public virtual Control TrackbackCount()
if (this.currentEntry != null)
int trackbackCount = 0;
IBlogDataService dataService = sharedBasePage.DataService;
trackbackCount = dataService.GetTrackingsFor(currentEntry.EntryId).Count;
return new LiteralControl(trackbackCount.ToString());
return new LiteralControl("");
public virtual Control TrackbackCountAll()
int trackbackCountAll = 0;
DateTime[] daysWithEntries = dataService.GetDaysWithEntries(UTCTimeZone.CurrentTimeZone);
foreach (DateTime day in daysWithEntries)
EntryCollection entries = dataService.GetEntriesForDay(day, UTCTimeZone.CurrentTimeZone, String.Empty, 1, int.MaxValue, String.Empty);
foreach (Entry potentialEntry in entries)
trackbackCountAll += dataService.GetTrackingsFor(potentialEntry.EntryId).Count;
return new LiteralControl(trackbackCountAll.ToString());
public virtual Control KensBlogStats()
StringBuilder sb = new StringBuilder();
try
DateTime monthFirst = new DateTime((DateTime.UtcNow.Year), (DateTime.UtcNow.Month), 1, 0, 0, 0);
DateTime monthLast = new DateTime((DateTime.UtcNow.Year), (DateTime.UtcNow.Month), DateTime.DaysInMonth(DateTime.UtcNow.Year,DateTime.UtcNow.Month),23,59,59);
DateTime weekFirst = Macros.GetStartOfCurrentWeek();
DateTime weekLast = Macros.GetEndOfCurrentWeek();
DateTime yearFirst = Macros.GetStartOfYear(DateTime.UtcNow.Year);
DateTime yearLast = Macros.GetEndOfYear(DateTime.UtcNow.Year);
int allEntriesCount = 0;
int yearPostCount = 0;
int weekPostCount = 0;
int monthPostCount = 0;
DateTime[] daysWithEntries = dataService.GetDaysWithEntries(newtelligence.DasBlog.Util.UTCTimeZone.CurrentTimeZone);
EntryCollection entries = dataService.GetEntriesForDay(day, newtelligence.DasBlog.Util.UTCTimeZone.CurrentTimeZone, String.Empty, 1, int.MaxValue, String.Empty);
allEntriesCount += entries.Count;
if (potentialEntry.CreatedUtc > monthFirst && potentialEntry.CreatedUtc <= monthLast)
monthPostCount++;
if (potentialEntry.CreatedUtc > weekFirst && potentialEntry.CreatedUtc <= weekLast)
weekPostCount++;
if (potentialEntry.CreatedUtc > yearFirst && potentialEntry.CreatedUtc <= yearLast)
yearPostCount++;
trackbackCount += dataService.GetTrackingsFor(potentialEntry.EntryId).Count;
int commentCount = dataService.GetAllComments().Count;
sb.Append("<div class=\"blogStats\">");
sb.Append("<table border=\"0\" width=\"100%\">");
sb.Append("<tr><td align=\"left\">Total Posts</td><td align=\"right\">" + allEntriesCount + "</td></tr>");
sb.Append("<tr><td align=\"left\">This Year</td><td align=\"right\">" + yearPostCount + "</tr></td>");
sb.Append("<tr><td align=\"left\">This Month</td><td align=\"right\">" + monthPostCount + "</tr></td>");
sb.Append("<tr><td align=\"left\">This Week</td><td align=\"right\">" + weekPostCount + "</tr></td>");
sb.Append("<tr><td align=\"left\">Comments</td><td align=\"right\">" + commentCount + "</tr></td>");
sb.Append("<tr><td align=\"left\">Trackbacks</td><td align=\"right\">" + trackbackCount + "</tr></td>");
sb.Append("</table>");
sb.Append("</div>");
catch (Exception ex)
sharedBasePage.LoggingService.AddEvent(new EventDataItem(EventCodes.Error, "KensBlogStats Error: " + ex.ToString(), String.Empty));
return new LiteralControl(sb.ToString());
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u