Monday, October 17, 2011

Configuring SharePoint 2010 to return pdf files in search results


If you’ve configured PDF for Search in SharePoint 2007 then you are certainly almost there in getting it to work with SharePoint 2010. The process is almost identical with some minor changes due to service name change and directory changes. Below are the steps to get iFilter working and configuring pdf files search in a SharePoint 2010
IFilter Install
1.       Download PDF iFilter 9.0 for x64 platformshttp://www.adobe.com/support/downloads/detail.jsp?ftpID=4025
2.       Stop the IIS Admin Services by issuing IISRESET /Stop
3.       Install the iFilter (this needs to be on the index server)
4.       After the installation is complete restart IIS.
Add PDF icon to SharePoint.
1.       Find your favorite PDF icon and size it to your requirement if you don’t have one you can download one from
2.       Copy the icon to SharePoint 2010 Images directory C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES
3.       Add the icon mapping into SharePoint icon mapping DOCICON.XML file located in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML
As follows 
4.       Add pdf as a new search file type in SharePoint Search Services in yourApplication Management in Central Administration.
5.       If the installation and mapping were performed correctly, a pdf icon should appear after adding the File Type
Making changes to the registry
1.       Add the following registry entry as shown below, and then set the registry entry value to pdf HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Search\Applications\\Gather\Search\Extensions\ExtensionList\
To add this entry, follow these steps:
1.       Click Start, click Run, type regedit, and then click OK.
2.       Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Search\Applications\\Gather\Search\Extensions\ExtensionList
3.       On the Edit menu, point to New, and then click String Value.
4.       Type 48, and then press ENTER.
5.       Right-click the registry entry that you created, and then click Modify.
6.       In the Value data box, type pdf, and then click OK.
2.       Verify that the following two registry subkeys are present and that they contain the appropriate values. If they are not present, you can manually create them
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Search\Setup\ContentIndexCommon\Filters\Extension\
Verify .pdf subkey exists, if it doesn’t right click on Extensions and create aSubkey
3.       If the subkey exists, verify that it contains the following registry entries if not you can mod them to the subkey.
(StringValue) – Entry type when creating a new one
Name: Default
Type: REG_MULTI_SZ
Data: {4C904448-74A9-11D0-AF6E-00C04FD8DC02}
Verify these entries also exists, if not you can create them manually also.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Search\Setup\Filters\.pdf
This registry subkey must contain the following registry entries:
(StringValue) – Entry type when creating a new one
Name: Default
Type: REG_SZ
Data: (value not set)
(StringValue) – Entry type when creating a new one
Name: Extension
Type: REG_SZ
Data: pdf
(DWord) – Entry type when creating a new one
Name: FileTypeBucket
Type: REG_DWORD
Data: 0x00000001 (1)
(StringValue) – Entry type when creating a new one
Name: MimeTypes
Type: REG_SZ
Data: application/pdf
4.       Once this process is completed, upload pdf documents on your SharePoint 2010
5.       Stop and start the SharePoint Search Service using the following commands fromthe command prompt. Remember administration privileges are required to perform this step.
Net Stop OSearch14
Net Start OSearch14
6.       Perform a full crawl, and your pdf files should be available in search results.

How to modify a DateTime value of AfterProperties in ItemUpdating/ ItemAdding Events in SharePoint


Issue Description:
  1. When you change the value of the DateTime column of Custom List in SharePoint's SPItemReceiver AfterProperties/BeforeProperties you need to set it to a specific DateTimeFormat string or else it throws the Error
  2. Error "Invalid date/time value. A date/time field contains invalid data. Please check the value and try again."
Steps to REPRO the Issue:
  1. Created a SharePoint Customer List
  2. Add a new custom Column of type DateTime (Example: ApprovedTimeStamp)
  3. Created a Feature Receiver Event Handler Assembly implementing ItemUpdating/ ItemAdding event.
    (Note: EventHandler sample showing ItemUpdating code is attached in the blog)
  4. Try to assign value to the Datetime Column of After Properties in ItemUpdating/ ItemAdding event. If you assign value either of the below mentioned way it throws Error: "Invalid date/time value. A date/time field contains invalid data. Please check the value and try again."
  5. properties.AfterProperties["ApprovedTimeStamp"] = DateTime.Now ;    //Generates Error
    properties.AfterProperties["ApprovedTimeStamp"] = DateTime.Now.ToString();   //Generates Error
    properties.AfterProperties["ApprovedTimeStamp"] = new DateTime(2008, 11, 08) ;   //Generates Error
    properties.AfterProperties["ApprovedTimeStamp"] = DateTime.Now.ToLongDateString();   //Generates Error 
    properties.AfterProperties["ApprovedTimeStamp"] = DateTime.Now.ToShortDateString();   //Generates Error
Resolution / WorkAround:
When setting a DateTime value in AfterProperties you have to convert the the DateTime to an ISO8601 string format. Either of the below mentioned line can be used to assign value to DateTime Column of Afterproperties in ItemUpdating/ ItemAdding Event:
  1. properties.AfterProperties["ApprovedTimeStamp"] = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ");    // Works Fine
  2. properties.AfterProperties["ApprovedTimeStamp"] = Microsoft.SharePoint.Utilities.SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now);    // Works Fine

sharePoint 2010 – Enable & using Developer Dashboard


How to enable Developer Dashboard and how to use this?
Enable / Disable over stsadm:
stsadm –o getproperty –pn developer-dashboardget the current setting from developer dashboard (On |Off | OnDemand )
image
stsadm –o setproperty –pn developer-dashboard –pv “OnDemand”set the setting from developer dashboard (On |Off | OnDemand)
image
Enable / Disable over powershell (functionality has changed in beta time)
OLD: Turn On: Set-SPFarm –DeveloperDashboardEnabled
OLD: Turn Off: Set-SPFarm –DeveloperDashboardEnabled $false
NEW: Turn On: for onDemain Mode
$service = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$addsetting =$service.DeveloperDashboardSettings
$addsetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::OnDemand
$addsetting.Update()

NEW: Turn On
$service = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$addsetting =$service.DeveloperDashboardSettings
$addsetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::On
$addsetting.Update()

NEW: Turn Off
$service = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$addsetting =$service.DeveloperDashboardSettings
$addsetting.DisplayLevel = [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::Off
$addsetting.Update()

Details see here: SPDeveloperDashboardLevel EnumerationDeveloperDashboardSettings
Mode of developer dashboard:
On – creates everytime the output at the end of the page content
Off – switch off developer dashboard and nothing is rendered
OnDemand – creates a DeveloperDashboard icon to make dashboard output visible as needed
image
example of an oob publishing page
Now with the next Page Load, the troubleshooting output is created:
DeveloperDashboard Icon is displayed at the upper right side
image(exist only in OnDemand-Mode)
image
How to use the Developer Dashboard?
Developer dashboard is designed to find performance bottleneck during the page load.
To get an overview about the whole page load performance take a look in the upper right side  on category “web server”. On my test environment the total time of page rendering  is 438.79 milli seconds.
image
At the left side you will see the ASP.NET rendering process of all involved controls with their time to render. Here is makes sense to focus only on long running controls.
image
In this case the longest operation is “EnsureListItemsData with 293,34 ms)
Because sharepoint controls will request data from database, the developer dashboard lists also corresponding sql requests with their execution time.
image
If you click on the sql command than a popup windows display more details. The long running sql request on my test environment is “Declare @…”
image
During this request i see the complete SQL query and the corresponding call stack to identify the correct control. Additionally at the end we see the IO Stats in case of a slow running SQL server based on too many IO-operations. 
One additional category exist for webparts to identify the slow running ones. In this case the ListView-Webaprt of the “Shared Document Library” is the slowest one.
image