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

CS Nuglet: A simple member list containing extended properties

I enjoyed a thread over the last couple of days with Goofy and the Genyus on generating a Community Server member list containing member first and last names and their email address.  This is slightly problematic because there is no first and last name field in any CS user table.  The user full name, which is an optional profile item, is stored as a single extended user property (with first name and last name together) in the name/value keys located in the cs_UserProfile PropertyNames/PropertyValues fields.

The conversation became fun when I made the mistake of saying this is something that could be whipped out in "an hour or two, tops," so Genyus (Community Server MVP Gary McPherson) threw down a double-dog dare to make me prove my project estimate.  Goofy was actually looking to pay someone to do this for him, so it was a brilliant strategy on his part to pit egos of a CS MVP against an ex-CS Evangelist when he saw an opening.

Gary McPherson is one of the best Community Server devs out there, so I knew I had to work fast.  I blogged on doing something very similar to this in my CS Nuglet: Customizing the Member Luv Grid.  My one-hour estimate was based on a simple ASCII-delimited list that could be copied and pasted from a webpage to excel or some other app. It also had to be drop and play, a separate .DLL and an .ASPX that required no installation.

The result of the hour's effort of generating a list of member full names and email addresses is a Memberlist .DLL and .ASPX package in my Downloads area.  Drop the .DLL in the \bin and the .ASPX anywhere.  Load the .ASPX and the following sample data is generated for copy-n-paste.  The only full name displayed here is "Henry Spontaine," whereas the other records contain the username by default in absence of a user fullname property.

 

It's as simplistic as it can be, but the source is available for more sophisticated tasks.  The core logic that generates the list is below.  A UserSet object is populated with all users, with each UserSet User ArrayList item cast to a User object with all extended properties available, like the CommonNameOrUserName property used here.

 

private void CreateList()
{
UserSet userSet = null;

UserQuery query = new UserQuery();
query.PageSize = Int32.MaxValue;

userSet = Users.GetUsers(query, false);

string output = String.Empty;
for (int i = 0; i < userSet.TotalRecords; i++)
{
User _user = (User)userSet.Users[ i ];
output += _user.CommonNameOrUserName + ", " + _user.Email + "<br>"
}

lblMemberList.Text = output;
}

Comments (0) | Post RSS RSS comment feed

Posted on 1/2/2007 8:47:30 PM by Dave Burke
Categories: Community Server
Tags:

Related posts


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke