IntranetFactory Tool

by David Palfery 22. July 2011 14:46

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.

image

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.

image 

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.

Link to the pricing and the tool http://intranetfactory.com/Products/63-sharepoint-factory.aspx

Tags:

Where and how to store Your Application settings in SharePoint 2010

by David Palfery 22. April 2011 11:51

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

image

To access this page you add a Custom Actionto the Central Administration page. The CKS Development Tools Edition extension provides a good template for adding these with one exception, the location settings should be a dropdown. Here is a link to the MSDN page that describes each location and the appropriate value. http://msdn.microsoft.com/en-us/library/bb802730.aspx

image

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

Managing SharePoint Configuration  http://msdn.microsoft.com/en-us/library/ff647766.aspx

The code from this demo can be downloaded from here

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.

image

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

image

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

image

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
{
    public class CustomerSettings
    {
        public string ConnectionString { get; set; }
 
        public string CustomerQuery { get; set; }
 
        public string 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.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using dp.sp.Utilities;
 
namespace WebPartExample.Biz
{
    public class PropertyBagManager : IDisposable
    {
        private SPWeb _web;
        public PropertyBagManager(SPWeb web)
        {
            _web = web;
        }
 
        public void AddCustomerSettings(CustomerSettings settings)
        {
            string sSettings = SerializationHelper.XmlSerialize(settings, typeof(CustomerSettings));
            if (_web.Properties.ContainsKey("CustomerSettings"))
            {
                _web.Properties["CustomerSettings"] = sSettings;
            }
            else
            {
                _web.Properties.Add("CustomerSettings", sSettings);
            }
           
            _web.Properties.Update();
 
        }
 
        public CustomerSettings GetCustomerSettings()
        {
            string stringSettings = _web.Properties["CustomerSettings"];
            if (stringSettings != null)
            {
                object oCust = SerializationHelper.XmlDeserialize(stringSettings, typeof(CustomerSettings));
                CustomerSettings Settings = (CustomerSettings)oCust;
                return Settings;
            }
            else
            {
                CustomerSettings Settings = new CustomerSettings();
                return Settings;
            }
        }
        
        public void Dispose()
        {
            _web.Dispose();
        }
    }
}

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 Sample code for this project is located here

How to build a SharePoint development environment

by David Palfery 25. March 2011 17:36
  1. 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.
  2. 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.
Microsoft Forefront Endpoint Protection 2010 installation

3. Add the Active Directory Domain Services Role

Activating and configuring the AD role

4. Install SQL Server Enterprise

Installing SQL Server

5. Install and Configure SharePoint for development

Installing and configuring SharePoint

6. Install Visual Studio and helpful Extensions see page/SharePoint-Tools.aspx

Installing Visual Studio and all the good extensions

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.

HAPPY SHAREPOINTING

Tags:

SharePoint Administration | SharePoint Development

How to get started in SharePoint development

by David Palfery 22. March 2011 15:26

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.

  1. Acquire  hardware virtual or metal
  2. install server 2008 r2
  3. add the Domain controller role
  4. add 3 new accounts
    1. SPFarm
    2. SQLService
    3. your developer account(don’t use admin)
  5. Install SQL server enterprise with everything (You never know when you will need it)
    1. run everything under SQLService
  6. Install SharePoint
    1. Configure for small farm Do not use stand alone option
    2. once installed it is ok to use the Central Admin wizard to configure your development environment.
  7. Install visual studio 2010
    1. Add the following plugins to VS through the Tools-> Extension manager
      1. CKS Development Tools Edition (Server) – the foundation one is also installed with server
      2. Power commands for Visual Studio 2010
      3. Productivity Power tools
      4. 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.

Tags:

SharePoint Development

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.

Blogroll