Here are two new development best practices for SharePoint 2010 developers. If you’re at the SharePoint Conference or another hands on training event, make sure to explore these.
· Get to know the Sharepoint CmdLets in PowerShell. PowerShell is an enhanced version of traditional scripting and command line approaches to systems management and administration. The cmdlets offer greater control (but less familiarity!) than STSADM.EXE. You can register the SP- cmdlets using the Add-psSnapin PowerShell command, or use the preconfigured SharePoint PowerShell command prompt. The easiest way to learn is to try to develop your own. To give you a preview, here’s a sample script to add 3000 items to a test list:
[System.Reflection.Assembly]::LoadWithPartialName(”Microsoft.SharePoint”)
##
$siteUrl = "http://yourhost.yourdomain.com"
$webName = ""
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl)
$spWeb = $spSite.OpenWeb($webName)
$spList = $spWeb.Lists["YourList"]
##
##
for ($i=1; $i -lt 3000; $i++)
{
$spitem = $spList.Items.Add()
$spitem["Title"] = "Item"+$i
$spitem["Number"] = $i
$j = 1
if ($i % 4 -eq 0){ $j = 2 }
$spitem["Data"] = "datum"+$j
$spitem.Update()
}
· For new custom code, implement with the SPMonitoredScope block. In summary, this enables your code to generate logged counters for the new Developer Dashboard. Developer Dashboard gives detailed information on resource usage, performance, user interactions and error trapping.
Comments