I was asked to lend a hand on a SharePoint project that was at the phase of starting over on the Information Architecture. I had seen advertisement for this tool and thought I would give it a try, well have someone else give it a try. My ECM/BA guy gave me a call two hours later on fire about this thing. It is everything Balsamiq is to the mainstream programing but for SharePoint. My BA guy spent three weeks working with the customer getting the site planed out in the mockups including pages and webparts on those pages. The customers loved it and forgot about what color the button was.

After my BA was done I noticed that they had a tool you could install on the server to generate the sites based on the Mockups. I was a bit skeptical so I snap shoted my development VM and installed the tool, create a new web application and site collection and ran the the tool. Twenty minutes later I had the actual intranet with sample data and permissions built. Done, Amazing, Awesome.

The free version only creates 10 pages, the for pay version for enterprise is about $1000.00 but that is only one days work for most SharePoint consultants and this will save that times 10.

Most applications even SharePoint ones require some data to start. For instance a connection string or the location of a web service, this data often needs to be configurable by the consumer of our application. Conventional ASP.Net practices tell us to store this data in the web.config file, however when working with SharePoint that offers some potential issues. Using the Hierarchical Object Store for a Farm or the Property Bag of a Web Application or Site Collection or Web we can persist this information in the SharePoint database using the SharePoint API. This way we can provide our users the ability to update this information form Central Admin or Site Settings instead of having to update the web.config file on each of the SharePoint servers. I will demo an example of this and show you how you can make your apps more admin friendly, professional, and scalable.

The first example I have is a Timer Job that syncs a database table with a SharePoint group. This is a common request I get from large organizations. The general layout of the project I got from Andrew Connell’s post on MSDN http://msdn.microsoft.com/en-us/library/cc406686(v=office.12).aspx . I took his example of the Hierarchical Object Store a bit further and created some management classes which help with multiple instances of configuration data. This was necessary in this example because I need one set of configuration data for each group the client wants to sync.

The other fantastic concept I got from this article which I believe should be applied to all SharePoint customizations where configuration settings are necessary is the Admin page that sets and edits those values to the Hierarchical Object Store.

When the timer job starts it can now open this configuration data from the Hierarchical Object Storeand utilize it regardless of which app server it runs on. If the admins add a new server to the farm they do not have to worry about making sure they get all you development settings in the web.config file. Microsoft recommends this as a best practice as stated in this article here on MSDN

The other example I have is with a WebPart project using the Web property bag. This project displays customer information from the Northwinds database through a WebPart. The admin page stores the customer ID, Connection string and the query to select the customer in the SPWeb.Properties property bag. This allows the admin to change the database and even the table that the customer information is selected from write from the Site Settings page. The purpose of the original application was to allow the customer info to be indexed so that the client could search on street address and find the customer site.

Again I have created a Custom Action,only this time on the site settings page of the web.

And I have also created an admin page, this one sits in the Layouts folder.

In this project I have used a little bit better architecture and separated out the SharePoint integration into a .biz class so that it can be tested. Ultimately I would like to have it unit tested with Moles but did not have time to get all that working, future post. So this project is integration tested but is using the SP1 MSTest tool inside of Visual Studio instead of having to try ad wire in nUnit.

I created a CustomerSettings class to store the ConnectionString, CustomerQuery, and CustomerID properties.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace WebPartExample.Biz

{

publicclass CustomerSettings

{

publicstring ConnectionString { get; set; }

publicstring CustomerQuery { get; set; }

publicstring CustomerID { get; set; }

}

}

I created a PropertyBagManager class to take care of the task of reading and writing my CustomerSettings class(DTO) to the property bag.

So when the WebPart loads it creates a new PropertyBagManager and calls then GetCustomerSettings method which populates a CustomerSettings DTO from the property bag and returns it. The WebPart then creates a CustomerFactory class taking the settings as a constructor parameter and calls the GetCustomer method and displays the information on the page.

The first step in building a SharePoint development environment is to create a VM with Server 2008 R2 SP1 and patch it to the latest updates.

Install an Antivirus. I like to use Microsoft Forefront Endpoint Protection 2010 mostly because I get it for free from my company's MSDN subscription. See the below video on how to install it for a dev environment.

7. At this point you will want to make a backup of your environment. If you are using VMware then simply copying the files to another hard drive will work fine. If you are using HyperV make sure you do an export first.

The most common question I receive as a SharePoint SIG (Special Interest Group) leader is “how do I get started on developing in SharePoint?”. Well SharePoint development has a somewhat steep learning curve, it’s a lot better now thanks to the new tooling in 2010 but still somewhat steep. Microsoft has done a good job putting out plenty of SharePoint examples and training packs for example:

Yet there is still so much to understand and be aware of before developing that it makes the entry into this space seem impossible. Well there is one really good training source I have found that eases that entry and that is LearnDevNow.

My advice to get started would be first to watch the LearnDevNowvideos on SharePoint administration then to setup your own development environment. I plan to blog next on exactly how I do that but here is a brief overview of the steps I follow.

Acquire hardware virtual or metal

install server 2008 r2

add the Domain controller role

add 3 new accounts

SPFarm

SQLService

your developer account(don’t use admin)

Install SQL server enterprise with everything (You never know when you will need it)

run everything under SQLService

Install SharePoint

Configure for small farm Do not use stand alone option

once installed it is ok to use the Central Admin wizard to configure your development environment.

Install visual studio 2010

Add the following plugins to VS through the Tools-> Extension manager

CKS Development Tools Edition (Server) – the foundation one is also installed with server

Power commands for Visual Studio 2010

Productivity Power tools

Visual Studio 2010 SharePoint Power tools

Once you have your development environment built then you can move on to the development portion of the LearnDevNowvideos and try the related labs.

Page List

Month List

About the author

David offers over 9 years of experience designing and developing enterprise ASP.NET applications. With proven leadership capabilities improving business automation, David has a strong passion for developing leading edge applications with the latest technology to save money, increase quality, and deliver value. David’s experience on the .NET platform includes SharePoint 2007 and 2010, VB.NET, C#.NET and ASP.NET. In addition to his skills in application development, David has also prototyped a number of rich interactive applications in Silverlight for internal and external use. His experience with both design and development makes him a great fit to any team working on the Microsoft platform.

David is also a frequent speaker at local user group meetings on topics of SharePoint, ASP.Net, AJAX, and Silverlight. David has started a local Special Interest Group for Silverlight and SharPoint in the Milwaukee area.