Dave Burke : Freelance .NET Web Developer specializing in Online Communities

CSTiers grows up

I blogged about my CodeSmith project named CSTiers when it was born.   I've been using it quite a bit to generate custom Chameleon controls, Provider classes, and business objects.  This weekend I added templates to generate custom Configuration, Roles, Context, urls and user, along with a CSModule to create the custom user on CS CreateUser.  With the addition of the new templates to the CodeSmith project I am now generating a complete ready-to-use custom Community Server class library project.

You'll have to do a bit of scrolling here, but not much more reading.  Below are the CodeSmith templates that comprise CSTiers.  Also in the picture are the template folders containing the CodeSmith templates I use in everyday CS development.


 

The templates give you a good idea of the objects that are created in an empty Visual Studio project.  The generated project is shown below.  You might have noticed the SiteUrls_Override.config, a DBVT.config, DBVT.xml resources file and a couple of Dummy.aspx files in the CodeSmith templates.  We'll output those to the Web directories.  Dummy.aspx is used to confirm that the project is fully operational.  We'll do that by displaying a Dummy Chameleon control that's included in our CodeSmith-generated project files.  We'll see that in a bit.



 

 

Our project handles the requirements of most custom Community Server projects, where we'll need a data provider, a custom user object, our own context, configuration and roles support, and the ability to create urls. Nearly all of the classes are derived from existing Community Server objects so we can do things like

 

DBVTUser user = DBVTContext.Current.DBVTUser;
if (user.IsInBillingGroup)
    do something...

or

DBVTConfiguration dbvtConfig = DBVTConfiguration.GetConfig();
image.ImageUrl = Globals.ApplicationPath + "/images/" + dbvtConfig.UploadImageFileName;


It also means that I'll probably be rewriting a lot of CSTiers when CS2008 hits the streets.  :-)

The process of creating a working project starts with creating an empty class library in the Community Server solution.  Then I run a single SQL script to create dbvt_users and dbvt_dummy tables and a couple of stored procedures.   The CodeSmith project then creates all of the files in my Visual Studio project, which builds successfully with no additional modification.  Two CommunityServer.config updates and a web.config file update in the Community Server Web project and we're good to go.

Since I try to use CodeSmith as much as possible to do the work for me, I added a CodeSmith template that does the .config coding for me as well, writing it to a .TXT file for cut and pasting.  Here's a sample of that output.

 

Steps to complete new project setup:

1) Add DBVTDataProvider to communityserver.config <Providers />

    <add
name = "DBVTDataProvider"
type = "DBVT.Sample.Components.DBVTSqlDataProvider, DBVT.Sample"
connectionStringName = "SiteSqlServer"    databaseOwnerStringName = "SiteSqlServerOwner"
    />

2) Add CreateDBVTUser module to communityserver.config <CSModules />

<add name = "CreateDBVTUser" type = "DBVT.Sample.Components.CreateDBVTUser, DBVT.Sample" />

3) Add DBVT control to web.config Controls area

<add tagPrefix="DBVT" namespace="DBVT.Sample.Controls" assembly="DBVT.Sample" />

 

The final step is to make sure everything works.  First we'll create a new account to confirm that the CreateDBVTUser CSModule is entering a new record into the dbvt_users table, then we'll view our dummy.aspx page.


Comments (5) | Post RSS RSS comment feed

Posted on 2/10/2008 3:52:41 PM by Dave Burke
Categories: .NET | CodeSmith | Community Server
Tags: No tags for this post

Related posts

Comments

2/10/2008 11:39:35 PM Permalink

Why don't you generate 1 and 2 straight to communityserver_override.config files?

Alex |

2/11/2008 4:04:44 AM Permalink

Alex, thank you for the excellent suggestion!  Of course.  I hadn't thought of that.  Thanks, Afscrome!

daveburke |

2/13/2008 6:40:25 AM Permalink

Why don't you use Nettiers Template? It is the best approach to code simplicity ever! It let's you focus on what is really important

diego |

2/13/2008 6:45:32 AM Permalink

Diego, what ya mean?  CSTiers is a customized version of the most excellent NetTiers, but with a CS-specific output.  I guess I'm fuzzy on your point, cause if I wanted to create a NetTiers project I'd use the NetTiers template, if a custom CS project, then my CSTiers templates.  Thanks for visiting and the comment.

daveburke |

11/16/2008 11:36:32 AM Permalink

Trackback from Dave Burke

Moving from DBVT-Think to DRIVE-Think

Dave Burke |

Comments are closed

This site was built with the Sueetie .NET Online Community Framework. Learn more about Sueetie at Sueetie.com.