Welcome Guest, you are in: Namespace

BlogEngine.NET and Sueetie Data Integration

RSS
Modified on 2011/02/01 12:19 by daveburke Categorized as BlogEngine NET, Patterns and Origins
This page describes how Sueetie supports multiple BlogEngine.NET site blogs, and how each BlogEngine.NET instance handles its application data and how Sueetie integrates that data into its Framework processes.

Patterns: How Sueetie supports multiple BlogEngine.NET site blogs

For a quick review, Sueetie can support any number of BlogEngine.NET blogs both on the site and in site Groups. Thanks to the flexibility of BlogEngine.NET, this is done very efficiently by storing blog data as XML and membership data in SQL Server. This isolates blog data while requiring only 3 SQL tables to handle all site blog user data. This works great, but BlogEngine.NET data required better integration with Sueetie Core data in SQL to enable framework functions like generating favorite lists, global searching, analytic reporting and so forth.

It should be mentioned that one approach to supporting multiple BlogEngine.NET blogs on a site is by using a separate SQL prefix per blog instance (the default is "be_"), but this wasn't considered because of its needless redundancy as well as doing little to integrate data among, say, 100 blogs into Sueetie framework processes. Not a very clean option.

The current design of blog data in XML and user data in SQL logic works great and won't change. However, what all blog post and comment data are copied into two Sueetie_ tables using BlogEngine.NET's global event support. The two tables, Sueetie_bePosts and Sueetie_beComments, suffice to house all site blog posts and comments as well as integrate them with other Sueetie data. The Sueetie_bePosts table will have additional SueetieUserID(int) and SueetieBlogID(int) values to support Sueetie framework services, including the generation of User Favorite lists.

One additional table is required to uniquely identify the blogs on a Sueetie site, Sueetie_Applications. Sueetie_Applications, along with Sueetie_Content serve as The Unification of all community application data. More about this core data concept is found in Data Core: Unification. Below is a screenshot of Sueetie_Applications. It should be noted that the ApplicationKey, here as "blog" matches the blog's directory name.

Sueetie_Applications table



Tying it all together

Let's tie things together by first looking at the Sueetie_bePosts table, where all posts of all blogs will be centrally located. SueetiePostID serves as the Identity Primary Key simply because Sueetie data patterns are based on Integer IDs rather than Guids. UserID keys on Sueetie_Users.UserID and to all Sueetie User data and profiling info. ApplicationID keys on Sueetie_Applications.ApplicationID. The Sueetie_beComments table is the same structure as its be_PostComment counterpart with the addition of an Int primary key.

Sueetie_bePosts table

BlogEngine.NET Sueetie Extensions

Now back to BlogEngine.NET and how we'll be copying blog post and comment data into SQL Server. BlogEngine.NET's built-in Extensions Architecture makes this a snap. Two simple Sueetie Extensions will create the SQL post and comment records for us, triggered by BlogEngine.NET's Post.Saved and Post.CommentAdded global events.

Sueetie BlogEngine.NET Extensions

Here is what the Save Sueetie Post Extension looks like in BlogEngine.NET.

Sueetie Save Sueetie Post Extension in BlogEngine.NET

The Code: Saving a BlogEngine.NET Post

Our SueetieBlogPost and SueetieBlogComment containers are available in Sueetie.Core and populated in the Extension, then passed off to Sueetie's SQL Data Provider. Below is the method saving a new or updated blog post to SQL. The properties in bold are the only original Sueetie items we need to obtain.



private static void SaveToSql(Post post) 
{ 

	string description = post.Description;
	if (string.IsNullOrEmpty(description))
	{
		description = Utils.StripHtml(post.Content);
		if (description.Length > 
			BlogSettings.Instance.DescriptionCharacters)
			description = description.Substring(0, 
			BlogSettings.Instance.DescriptionCharacters) + "...";
	}

	SueetieBlogPost sueetieBlogPost = new SueetieBlogPost 
	{ 
		UserID = SueetieContext.Current.User.UserID, 
		ApplicationID = int.Parse(_settings.GetSingleValue("BlogID")), 
		PostID = post.Id, 
		Title = post.Title, 
		Description = description, 
		PostContent = post.Content, 
		DateCreated = post.DateCreated, 
		DateModified = post.DateModified, 
		Author = post.Author, 
		IsPublished = post.IsPublished, 
		IsCommentEnabled = post.IsCommentsEnabled, 
		Raters = post.Raters, 
		Rating = post.Rating, 
		Slug = post.Slug 
	}; 

	SueetieBlogs.CreateUpdateSueetieBlogPost(sueetieBlogPost); 
}


BlogEngine.NET Sueetie Data Integration: Origins

Very little origins information to share on the integration of BlogEngine.NET and Sueetie Data. We needed to increase data co-existence when building the Friends and Favorites functionality and giving users the ability to follow blog post authors and commenters and to tag blog posts and comments as favorites. Gathering friend and favorite data was easily available in the existing XML-SQL structures, but generating favorites lists required that the blog data required for those lists (as well as future features like analytics and global searching) be resident in SQL.

As for the technical origins of the approach used to integrate BlogEngine.NET data with Sueetie, that credit goes to the excellent developers of BlogEngine.NET who made the process drop-dead simple with BlogEngine.NET Extensions.

Top

ScrewTurn Wiki version 3.0.4.560.

Get in Touch

Dave Burke

Don't hesitate to contact Dave Burke with any questions about Sueetie or to consult with you about Sueetie Custom Community Development.

phone: (802) 343-1111
Copyright © 2008-2011 Sueetie LLC. All rights reserved.