Thursday, May 3, 2012

Visual Studio SharePoint Solution Structure

One of the key things that needs to be sorted out in the initial phase of a project is to design the solution structure. A well thought through solution structure will enable good scale-ability and flexibility to future enhancements / changes to the solution.

Visual studio by default provides a number of solution templates for SharePoint 2010. However, many a times, these do not fit in properly when there are a number of elements / features in the solution. The following is the approach that have proven to be very useful. This approach can be taken as a base approach and can be modified to suit individual needs.

The first thing that needs to be ironed out is the names schema for the folders, projects, files. For this example,
Folders:  .
Project: .Sharepoint.

Web provisioning project (XYZ.Sharepoint.Provisioning) :
This project is responsible for getting the gathering all the project deliverable in a single location and preparing for packaging of the solution. The SharePoint project consist of multiple WSPs and other artifacts. Gathering them manually from their respective folders gives a lot of room for errors (picking old files, omissions etc). This project will build the entire solution, copy all the deliverable from the respective locations and move them to a single location.


Site Structure: This project will contain all the site definitions, templates, themes, master pages etc.


Presentation, Business and Data 
The traditional 3 layer approach with separate project for Presentation, Business and data project. It is recommended to group the projects on a logical level. i.e all web parts related to a particular module should be grouped together to form a single project.

Folder Structure: The visual studio logical folder is a excellent method to organised the solution. All the similar elements should be grouped together in folders so that the solution can be easily understood by the developers. The folders are logical folders and visual studio does not create physical folder to replicate the same.

XYZ Third Party Tools: This contains the third party tools used. In case of open source tools, the code base for the same is kept here so that the source is available for enhancement in future

XYZ Tools: This folder maintains all the standalone custom tool developed for the application.

XYZ Test: This folder contains all the automated unit test projects built for the solution

Friday, February 12, 2010

Installing MOSS on a single server machine

This blog forms a guideline for Installing MOSS on a single server machine .
Many a times, developer start off on a moss project on a pre built MOSS VPC image. This saves a lot of time and the developer can jump start and be productive. One main drawback of the VPC is that, it is real slow to work on and many a case, it can be a real pain to work with. This is when i decided to pump up my desktop and make this as a Single server MOSS box that really responds to my clicks :)

My first installation was performed on my gut feel and was not really the optimal installation. So I had to reinstall the box again. And this led me to write this blog. So that my mistakes could actually help someone to not make them.

Now what all are the pre requisites for the MOSS installation
  • Install Windows Server 2003 /2008
  • Install SQL Server 2005 (Optional)
  • Install Microsoft Office  (Optional)
Install Windows Server 2003 /2008
  • I stongly recomend to install MOSS on a clean machine. I ran into trouble when i was reinstalling the MOSS after uninstalling a previous attempt. The Reinstallation sometimes fails to create the content database properly. And thus will lead to many more issues later.

          2003 instructions
          2008 instructions 
  • Ensure that all the updates / patches / hot fixes for the OS are run after installation.
  • Install the Antivirus. You would not want to see all your effort go down the drain, would you?
  • If you are installing this in your office environment, you would like to join this server to the domain. In my case, i created a domain on the server. Click here for instruction on how to create a domain. 
  • Create a new Active Directory (AD) account. This account ( Service Account ) will be used for all MOSS installation purpose. This account requires the local Admin rights.
  • Install IIS
  • Install .NET framework 2.0 as well as 3.0

Install SQL Server 2005
  • Log in as the service account created in last step.
  • Install the SQL Server 2005 / 2008
  • 2005 instructions : http://msdn.microsoft.com/en-us/library/ms143516(SQL.90).aspx
  • 2008 instructions : http://msdn.microsoft.com/en-us/library/ms143219.aspx
  • Install SQL Sever Management Studio (Optional)
  • Add the service account to the Service Administrator and Database Creator roles.
  • Run the windows update and install all the updates for the SQL Server.


Now we are ready to install MOSS.
Get the installation CD, A cup of tea and a book ( Calvin and Hobbes will be a good option )
Login as the Service Account created.
Open start menu > Run > InetMgr
Ensure that 'ASP.net V2.0.50727' web service extension is allowed in IIS. If this is not allowed then perform a 'repair' on .net 3.0 framework using add/remove programs.Web service extension will now appear in the list.
Insert the MOSS CD and run Setup.exe
Enter the CD Key when prompted
Choose the Advanced Option for the installation. The basic option will install basic version of SQL Server and will not utilise the SQL Server that we installed earlier.
Select the Complete installation option in the next prompt ( Server type ) and then click on Install.
Once the installation runs to completion, it will pop up a screen with the option "Run the SharePoint products and Technologies Wizard now". Check this option and finish the installation.
After the installation, the MOSS wizard will jump up on the screen.
A warning message stating that many of the services will be restarted will be popped. Click on Yes.
An option to configue the farm will be promped. Select 'No , I want to create a new farm' option.
Provide the database server (your server name) and your account details (Note: the Account should be entered in domain\user format). Leave the database name as the default. Click 'Next'.
Leave the authentication mode as 'NTLM', set a specific port number is desired (not required) and click 'Next'.
You'll get a summary screen; click 'Next' and now sit back and sip the tea. if it still not complete, i now suggest you to start on the book that you picked up.

NOTE: if the setup fails, check the application log. It would mostly be due to the issues in creating content database. Check the SQL Server installation / Service Account permissions.

You'll get a success screen at the end, click 'Finish'.

The Wizard will now open up the Central Admin. Your Server is ready to be productive.

There are a set of configurations that are to be completed on the server. The MOSS portal will work even without these configurations. But to utilize the full potential of the MOSS, it is recomended that these steps also to be completed. I will be posting on those steps in my next blog

Monday, February 1, 2010

Improve MOSS Performance


Sharepoint/ MOSS is a resource intensive application. And this is exactly the reason why the sharepoint / MOSS developer needs to be extra cautious on the performance implication of the code that they spin out.
Here is some pointers to areas where the processing power is drained out.  A little caution here and there can increase the performance of the application significantly.

During the development phase, the developers may not notice the impact of the performance to the full extent. However, once the application moves to production and data accumulates over the time, then the same lines of codes will start taking more and more time to execute.

Check for memory Leaks 
Most Sharepoint developers will know that they have to dispose the SPSite object. But why doesn’t the garbage collector treat them also like any other variable?
The SPSite and the SPWeb object are created as managed property.  So ideally they should be disposed properly. However, they internally use large amount of unmanaged data. This will not get disposed properly. In general, any object that uses the IDisposable object in MOSS should be disposed properly.

The most common coding method used is as follows
using(SPSite mySite = new SPSite(http://server:portno)
{
using (SPWeb myWeb=mySite.open())
{
//My code
}
}

Word of Caution:
1.       Do not use this method when getting hold of the context web (SPControl.GetContextWeb(HttpContext.Current) because this will refer to current context and when the code moves out of scope, it will try to close the current context object.
2.       Another major pit fall is the below code
       using (SPWeb web = new SPSite(SPContext.Current.Web.Url).OpenWeb())

this will dispose the web object created. But the new spsite object will not be disposed and will take the precious memory.

BOOST Performance of the Code
1.       SPWeb.Lists(“MyList”)
This is a expensive method. It will load all the list metadata un the spweb and then string compares all the title and retrieve the required list.
Instead use SPWeb object to retrieve list using the url of the list
Web.getList(“http://site/list/allitem.aspx”);
This will make considerable resource saving when there is a large number of lists in the web object
2.       Iterating the list item
Another common performance drainer that I have come across.
For(id=0; item in list;id++)
{
Variable = list.items[id].fieldname;
}
This will create a item collection each time it loops. Imagine the number of collection it needs to create for a large list!! Simply initializing the item collection outside the loop will gain a lot of performance in this case.
3.       Retrieving the list item count
List.Items.Count method will retrieve all the items in the list and then count it. A huge list means huge resource wastage. Instead of this method, use list.ItemsCount method. ItemsCount is part of the list metadata. That means that you already have this information in memory and don’t have to burn any more cpu cycles to get this.
4.       Retrieving list items using itemQuery
Query is a better way to retrieve the list items than simply opening the list item object. This can be further optimized by setting item limit to the retrieval. Smaller the batches that is retrieved, lesser the load on machine.
5.       Getting list item by GUID
SPList.items[GUID / Int32] or SPList.Items.GetItembyID(Int32)
This will retrieve all the items in the list to the memory and then search for the required item. Instead use the below syntax
SPList.GetItemByUniqueID(GUID)/SPList.GetItemByID(Int32)  

MOSS Central Admin / SSP does not open link

MOSS installation though is a very simple installation, some times can lead to lot of headaches.Recenlty on one of the fresh single server installations, the SSP simply refuses to open any link within the SSP page.or the central admin. After a full investigation, i found the reason to be very silly and had nothing to do with the installation. The solutions?
I simply added the site to the trusted sites in IE. And presto, the site is fully working.The Javascripts were being blocked by the IE that prevents the page from opening.

A lot of research for a simple problem. Such is usually the problem.

Monday, January 25, 2010

Search PDF files in MOSS


Search is one of the powerful features of MOSS Portal. It allows the user to retrieve data seamlessly showing the right data to the right people. The Search also spreads its wings to all the office suite. Many a times the office documents are stored as PDF files and are uploaded to Portal.
Adobe has also provided filters that will enable searching the PDF files. the below steps describes the process to index within PDF files
Getting Adobe IFilter 9 to work with SharePoint
Download the Adobe IFilter. If you are using the Adobe 8, then you will need to download this from the adobe site. If you are using version 9.0, the IFilter is already installed on the machine.
Enable the PDF File Indexing
  • Download Adobe Reader 9.0, which includes IFilter 9.x.x.x, from http://www.adobe.com/products/acrobat/
  • Download the Acrobat PDF Picture. This will be used to display the pdf file icon. http://www.adobe.com/misc/linking.html
  • Add the PDF file type to the Extensions List for WSS search by editing the registry
    • Start regedit
    • Open the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Applications\{Random GUID}\Gather\Search\Extensions\ExtensionList
    • Add PDF to the list as a new String Value. Use a new high value e.g. if 37 is the highest value, use "38" as the key with the value "pdf"
  • Add the Acrobat PDF picture to the SharePoint templates directory. Copy the Acrobat PDF picture called pdficon_small.gif in the 12 Hive\TEMPLATE\IMAGES folder, e.g. %programfiles%\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\IMAGES.
  • Bind the Acrobat PDF picture to the PDF file type
    • Open the 12 Hive\TEMPLATE\XML\DOCICON.XML file
    • Find the part
    • Add the following mapping:
  • Set IFilter mapping in registry
    • Start regedit
    • Open the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Search\Setup\ContentIndexCommon\Filters\Extension\
    • Add (or modify) the .pdf key
    • Add a Multi-String value with value {E8978DA6-047F-4E3D-9C78-CDBE46041603} or modify if another GUID value already exists.
    • Open the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\12.0\Search\Setup\ContentIndexCommon\Filters\Extension\
    • Add (or modify) the .pdf key
    • Add a Multi-String value with value {E8978DA6-047F-4E3D-9C78-CDBE46041603} or modify if another GUID value already exists.
  • Add the Adobe Reader folder to the environment path variable
    • Right Click on My Computer
    • Open Properties
    • Open the Advanced tab
    • Go to the Environment variables
    • Edit the Path variable
    • Add your Reader folder to the Path list, e.g. C:\Program Files\Adobe\Reader 9.0\Reader
  • Restart the Search service by restarting your server or executing the following commands:
    • Run: net stop osearch
    • Run: net start osearch
  • Crawl the PDF documents
    • Existing PDF documents that were crawled before the Adobe PDF IFilter has been installed are not indexed during an incremental crawl. You have to edit each existing PDF file to trigger the crawler to reindex the file during an incremental crawl. It´s easier to run a full crawl after you have installed the Adobe PDF IFilter.
With this, the MOSS crawlers will crawl the content of the PDF files also, enabling the users to retrieve data from the  PDF files also

Saturday, January 23, 2010

Display PDF File in MOSS Portal

Steps to display PDF file in a MOSS / Sharepoint Portal
Usually, when i get down to write a blog, i tend to get creative and put a lot of language around it. This time, i am going to cut the crap and get straight to it.
I want to display a PDF file in my MOSS Portal. So how do i go about it?
Following are some simple approach that your dev team can take.
1. Upload the pdf to a doc library
Add a Content Editor Web part to your web site
Copy paste the below code to the HTML mode in the content editor
< embed height=”500px” width=”500px”
src=”http://siteurl/test.pdf” type=”application/pdf”>
2. Use a simple page viewer web part and give the path of the pdf file in the document library
3. Many a case, the user will want to dynamically pick the pdf file based on some parameter. This was my case too. A simple web part will do the trick for this. Create a custom web part that spins out the HTML mentioned in approach 1. With a difference that the url of the pdf file will be generated at the run time based the business requirement.

Friday, January 22, 2010

Site Definition Vs Site Template

Choosing the Site template is the first decision that the developer makes while designing the SharePoint / MOSS portal. But What is really a site template? Is it same as the site definition? Time to take a deeper look into this.

Site Definition as well as the site template defines the content of a the portal. This specifies what all the web site will contain. This may include content types, lists, features, Web parts, event handlers, Navigation elements etc.

In a layman's term, site definition is nothing but a xml file that defines what all are the items that needs to be included in the new site that is being provisioned. In contrast with Site template is built on top of the site definition, recording the changes on the site dentition.

When to Use Site Definitions

Customizing portal sites or SharePoint sites using site definitions is apt for third-party developers and server administrators. Site definition requires access to the file system of the Web server. The

Administrator should always be involved in the deployment of site definitions.

Although deploying a site definition requires more work, site definitions typically perform better when cached on the file system instead of in the database. In addition, you can achieve a higher level of customization by directly editing all the schema files without depending on the existing site definition as a site template does. Also, if you want to introduce new file types, view styles, and drop-down edit menus, you need to edit the schema files that make up the site definition.

Custom site definitions are upgrade independent. Subsequent upgrades to MOSS Products and Technologies may overwrite existing default site definitions. Using custom site definitions excludes your sites from potential upgrade issues.

However, there is no easy way to modify site definitions once they are deployed. There is always the possibility of breaking existing deployed sites derived from the site definition once you modify an existing site definition. You can only add to the site definition once it is deployed.

When to Use Site Templates

Site template when compared to site definitions, are easy to create and deploy. You can make all customizations through the user interface. Also, you do not need to be a server administrator on the Web server to create and deploy site templates. Modifying a site template will not create issues in existing sites created by the template. It also eases the deployment as the template data is stored centrally in the configuration database.

Site templates are slower than the site definition as they are stored in the database. Templates in the database are compiled and executed every time a page is rendered. WSS does some performance optimization whereby it stores templates on the local Web server and a ghost of the page in the configuration database. However, you can easily prevent WSS from using a copy of the page by using Web Folders to open, modify, and save it. From this point forward, the database is used to render the page.

Site templates only work on SharePoint sites that are not portal sites (not based on the SPS templates). Furthermore, site templates are not ideally suited for a development environment. In effect, they are still customizations of a site definition. If the site definition does not exist on the server, the site template fails.

Generally, site templates are not as efficient as site definitions in a large-scale environment


Here is the list of the site definitions available on the MOSS 2007


ID Name Type
STS#0 Team Site WSS
STS#1 Blank Site WSS
STS#2 Document Workspace WSS
MPS#0 Basic Meeting Workspace WSS
MPS#1 Blank Meeting Workspace WSS
MPS#2 Decision Meeting Workspace WSS
MPS#3 Social Meeting Workspace WSS
MPS#4 Multipage Meeting Workspace WSS
CENTRALADMIN#0 Central Admin Site WSS
WIKI#0 Wiki Site WSS
BLOG#0 Blog WSS
BDR#0 Document Center MOSS
OFFILE#1 Records Center MOSS
OSRV#0 Shared Services Administration Site MOSS
SPS#0 SharePoint Portal Server Site MOSS
SPSPERS#0 SharePoint Portal Server Personal Space MOSS
SPSMSITE#0 Personalization Site MOSS
SPSMSITE#0 Contents area Template MOSS
SPSTOPIC#0 Topic area template MOSS
SPSNEWS#0 News Site MOSS
CMSPUBLISHING#0 Publishing Site MOSS
BLANKINTERNET#0 Publishing Site MOSS
BLANKINTERNET#1 Press Releases Site MOSS
BLANKINTERNET#2 Publishing Site with Workflow MOSS
SPSNHOME#0 News Site MOSS
SPSSITES#0 Site Directory MOSS
SPSCOMMU#0 Community area template MOSS
SPSREPORTCENTER#0 Report Center MOSS
SPSPORTAL#0 Collaboration Portal MOSS
SRCHCEN#0 Search Center with Tabs MOSS
PROFILES#0 Profiles MOSS
BLANKINTERNETCONTAINER#0 Publishing Portal MOSS
SPSMSITEHOST#0 My Site Host MOSS
SRCHCENTERLITE#0 Search Center MOSS


Time to see how it maps to 2010

Thursday, January 15, 2009

Preview into Azure Services

Microsoft has stormed into the Cloud Computing environment with its release of 'Azure Services' into the air. This blog provides a preview into Azure Services. The CTP version of Azure was launched in the PDC 2008. Ever since, it has caught the attention of many of the Organizations. Before we rip open Azure, we need to understand what the Cloud computing is all about. Why is there so much buzz around it?





Technically, Cloud computing encompasses any subscription-based or pay-per-use service that, in real time over the Internet, extends IT's existing capabilities.

In simple words, it is a service that allows you to host your application in their environment, provide you with the required hardwares, softwares and services on a subscription / pay per use basis. At the same time, they reduce the upfront investment on planning, purchase of hardware and basic softwares. Thus lowering the initial investment cost and turning it into maintenance cost.

Microsoft Azure is a cloud computing solution, that encompasses a number of servers (The count keeps increasing by 10,000 every month) bound together the 'Azure Fabric'. Azure takes care of all the updates/ maintenance for the server, data back up, logging and other tasks. This allows the user to keep focus on the business requirements and leave the scalability / availability / server maintenance tasks to Azure.

A number of services are provided on top of this fabric

  • .NET Services
  • SQL Services
  • LIVE Services
  • Sharepoint Services *
  • Dynamic CRM Services *
* These services are not available in the CTP version.

You can opt for the services that you require, thus you will be paying only for the services that you use. Some of the other advantages that Azure brings to the table are


  • Dynamic Provisioning

    • Increase/ decrease the resource used at run time


  • Lower cost

    • Pay as you grow. Will be billed only for resources used.
    • No Upfront cost on building / planning infrastructure


  • Reduced Administration Overhead

    • Easy and quick deployment for Azure hosted application
    • Server maintenance are already taken care of.


  • Developer benefits

    • Azure supports .NET, IIS, VS08
    • Does not require extensive training to gain expertise

From a developer perspective, the main advantage that Azure brings to the table is that, it allows the dev team to focus on the core business requirement and not on the administrative / extensibility or other hardware issues. Azure provides a platform for a host of the next generation applications.

Azure forms a platform for a new breed of application. But does that mean you need to jump into azure? Following are some of the key factors that needs to be considered before making any decisions. If these signatures exist on your application, then Azure definitely stays on the table.

  • Potential to grow many folds in terms of data / usage?
  • Use social networking type of application?
  • Use highly resource intensive functions from time to time?
  • Require a environment to test the market?
  • Require safe and secure mechanism to communicate (Internet service bus ) outside organizations network.
  • Want to lower the initial cost involved in infrastructure planning and purchase
  • Want to lower the administrative cost of maintaining the servers ( Data backups, audit, connectivity and other server issues)
Migrating an application to Azure does not mean that the investment made on the traditional on premise application will no longer be used. In fact Azure can work hand in hand with traditional application. The traditional application can be extended to move the resource intensive functions to the cloud.

Based on the customer requirement, a cloud application can be


  • Completely hosted in the cloud



  • A part of the application can be hosted in the cloud while the data resides on premise.



  • The application resides on Premise and the data stored on Azure.


Having said all this, we still have to understand that Azure as well as the cloud computing environment is still in a evolving stage. With all the advantages that cloud brings, it also brings a dependency to the service provider. Some of the common concerns that have bubbled up are the in terms of SLAs, maintenances charges etc which can change as times change.

Taking into consideration the Microsoft branding and the kind of investment that has been put into Azure, one thing is certain, Azure is here to stay. It is time to get the creative juices to make the best use of Azure.