Showing posts with label SharePoint 2010. Show all posts
Showing posts with label SharePoint 2010. Show all posts

Friday 4 June 2010

SharePoint 2010 Developer dashboard

Overview: Developer dashboard allows you to see all calls made from a page under the page in the browser. This allows you to identify poorly performing code & bottle necks. You can see the call stack and the time it takes to perform each call.
OOTB the developer dashboard it turned off. Turn it on using an stsadm cmd or powershell cmd.

Developer dashboard can be setup to allow only certain users to view the stats, this means other users don't suffer the additional resource calls but the developer/administrator can view poorly performing code & page statistics.

Stsadm Method:
1.> Open a cmd prompt running as an administrator
2.> go to: c:\program files\common files\microsoft shared\web server extensions\14\bin and
3.> run the following cmd:
stsadm -o setproperty -pn developer-dashboard -pv ondemand
Cmd prompt to turn on the developer dashboard
4.> In the browser click the developer dashboard icon in the top right of the page, as shown below. On the page you can now see the page call information.

Web Services Using the Object Model (Web Serives) Method:
SPWebService cs = SPWebService.ContentService;
cs.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.On;
cs.DeveloperDashboardSettings.Update();
 
Powershell Method:
$db =[Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;
$db.DisplayLevel = 'On';
$db.TraceEnabled = $true;
$db.Update() 

Linq to SharePoint overview

Problem: Access data in SharePoint Lists.
Hypothesis:
1.> LINQ for SharePoint is a data access mechanism that allows developers to create SQL like syntax against a data sources. Linq improve performance by allowing the back end data source to be queried using CAML to solve the query. SharePoint 2010 fully supports LINQ for lists so that developers can query SharePoint easily and quickly.
2.> LINQ for SharePoint is also know as SPMetal.
3.> The SPMetal utility generates C# or vb.net code to allow you access to existing SharePoint lists.
4.> You can automate you VS environment using the prebuild cmd prompt to regenerate your Linq data access class for builds.
Steps to work with Linq for SharePoint:
1.> Using the stsadm cmd, create the API to your existing SharePoint App

2.> Import the created Data.cs file into the Visual Studio solution. Fix the namespaces on the file.
3.> Begin Using LINQ to SharePoint.
DataDataContext dc = new DataDataContext(http://intra);
// TODO! - retrieve from the web.config
EntityList Assets;
Assets = dc.GetList("My Assets");
var assetQuery = from asset in Assets
where asset.Id == Assetid
select new{
asset.Title,
asset.Description
};

// Bind to a Grid view

More Info:
Getting started with LINQ for SharePoint 2010
Channel 9

SharePoint Session State

Problem: Building a composite application in SharePoint 2010 I need to store information for a user. A basket/shopping cart like feature is required.
Initial Hypothesis: Store data against the user profile, or a custom list and retrieve using Linq/CAML or use session state. Session state is not supported by SP2010 OOTB and it can have severe performance implications.
Resolution: enable ASP.NET session state. This stores the session state in a SQL Server database. Start the Powershell cmd prompt:

Enter the following PowerShell command in the SharePoint 2010 Management Shell window:
or
Enable-SPSessionStateService -DatabaseName "ASPNet_State" -DatabaseServer "spdemo.dev" -SessionTimeout 30Each web application for which you want Edit the web.config file and set the enableSessionState property of the pages element as follows:

More Info:
http://social.msdn.microsoft.com/Forums/en/sharepoint2010general/thread/3145fd29-2315-42f7-8f9d-cf6d52dc3c95
http://www.kajanmoorthy.com/2010/05/enable-session-state-in-sharepoint-2010.html
http://todd-carter.com/post/2010/04/30/A-Session-State-By-Any-Other-Name.aspx