Friday 31 December 2010

Closing a popup dialog after running server side code

Problem: A base page allows a user to perform additional logic such as inserting a a new row into a list via the Dialog Framework.  The new row is a custom page that is shown thru the Dialog framework.  The custom page contains a web part that allows the user to fill in a form, perform custom logic and insert the record.  You now need the dialog page/popup to close automatically after the server side code is run.  The problem is you need to run the server side code before closing the window.

Initial Hypothesis:  I have been using jQuery with a hidden server control to set a value on the server side after my custom server side actions.  Then after the page reloads due to the postback, on the jQuery $document ready I check if the hidden value has been set and if it has I use the dialog framework to close the page.  A fair amount of work and round trips to solve my problem.

I saw a post on the msdn forums which is much simpler & better solution.  I implemented this and it is much easier and better than my hidden variable approach.

Resolution:
Place the code snippet in the server side code i.e. in the button click after you have performed your server side logic.

More Info:
http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/ba06d5e5-8c4c-4bca-95f8-65f40c1b11fa

Wednesday 29 December 2010

LINQ to SharePoint by Example

Problem: Simple examples to perform CRUD operations using LINQ to SharePoint. 
Resolution:
Read Operation/Select (Get a single row) & Update Operation/Update (Update a row), this code uses the default context constructor to retrieve the customer, you can use less code to achieve the same result.
Create Operation/Insert (Add a new row to a list)
Delete a customer list item.

Connected Web Part Series - Part 1

Problem: There is a lot of information relating to web parts however this series is aimed at connected web parts in SharePoint 2010.  This 1st post deals with creating a custom connection between 2 visual web parts (a provider & a consumer).

Overview:  Create a Interface to enable communication between the provider and the consumer web part.  Create Visual User controls to connect to each other. 
Tip: Web Parts are easier to connect than Visual Web Parts, so only use Visual web parts if there is a heavy visual requirement.

Steps:
Create a new Web Part (it will be the provider web part)
 Create an Interface (contract between the provider and consumer web parts)
 Implement the Interface in the Provider web part
Create the Consumer web part as shown below
Deploy the solution and activate the feature that contains the 2 web parts
In a browser add the 2 web parts to a page (Provider & Consumer) 
 Connect the 2 web parts as shown below

Friday 24 December 2010

Connected Web Part Series - Part 2

Title: Creating a web part that is both a consumer and a provider.

Problem: I needed a web part that receives data from a provider web part.  The same web part then passes data onto a consumer web part.  I.e.  WebPartGetUser (Provider), WebPartShowWeeks (Consumer & Provider) & WebPartShowProductsOrderedinWeek (consumer). 

Hypothesis:
WebPartGetUser - Retrieve the user and passes the user id to the web part WebPartShowWeeks.
WebPartShowWeeks  - Consumes the UserId and show weeks where the user placed an order.  A drop down list show all the weeks, when the week is selected, the week is passed to the WebPartShowProductsOrderedinWeek web part.  This show all the orders placed in a specific week.

Wednesday 15 December 2010

SharePoint 2010 boundries and thresholds

I attended a suguk.org event in London about a week ago.  John Timney did the 1st presentation session and asked a couple of questions on SharePoint limits.  I didn't know the answers, tried to think back to MOSS and what I'd seen previously.  The simplest question that I should know the answer to:

Qu: What is the maximum content database size supported by SharePoint 2010?
Ans: Microsoft supports Content databases up to 200GB in size.  In MOSS it was 100GB.  It is fairly common to see content databases considerably bigger than 100GB in MOSS that work.   The issue is how long does it take to perform operations on these content DB's such as backups moving content db's.  If you have a dedicated SAN, there is no reason not to go to much larger content databases however, they are not supported by MS.

More info on SharePoint's boundaries and thresholds from MS

Qu: What I/O speed does MS recommend for your SharePoint 2010 SQL database?
Ans:  I/O operations per second (IOPS).  The faster that SQL can handle request, results in faster return time and reduced que requests, so pretty important and a fairly common bottleneck.  This is often a reason why people choose not to virtualise SQL Server, it I/O intensive in SharePoint and really important to be fast.  Tip: Ensure VM's are thick provisioned for SQL Server. 

To determine you IOPS  use SQLIO Disk Subsystem Benchmark Tool (http://go.microsoft.com/fwlink/?LinkID=105586).

I guest the answer is as fast as possible but you can determine your IOPS requirement using the tool and you usage.  I go with ldf files on the fastest disk on the TempDB followed by ldf files for the content dbs on spinning disks.

Update 09/06/2011
Qu: Should I using seperate disks for mdf (data files) & ldf (transaction logs)?
Ans:  On small SQL server farms ensure that the transaction logs are stored on a different physical drive to the content databases as this will reduce contention and increate performance signigicantly.  Larger SQL instances like SANS have multiple disks so there is no need to seperate the files as this is already done by the nuber of disk readers.  You can also check the performance of a drive by watching the "disk seconds per read/write counters" which should be less than 20ms.  If the disk seconde per read/write is approachiing 20ms consider improving the disk speed or increasing the number of read points.
Update 22/08/2012 - Bigger architectures may use SSD/Flash memory as opposed to disks.  The IOPS are hugely improve as the is no disk search time.  http://technet.microsoft.com/en-us/library/cc298801.aspx#Section1_5a

Qu: What is the default SQL Server database growth setting sizes?
Ans: SQL Server 2008 will grow data files by 1MB and transaction logs by 10% increments.  I would start with an initial content database size of 100MB(adjust according to your anticipated demand) and autogrowth to be 50MB (adjust according to your system).  This general prinipal will result in the growth to the db's being infrequent so the associated performance hit is reduced, unused space being optimised as the percentage growth in the transaction log has huge incremental hit that are generally never reached after initial growth and less fragmented databases results in faster performance. 

More Info:
Summary of limits and thresholds
http://blah.winsmarts.com/2010-5-How_big_can_my_SharePoint_2010_installation_be.aspx
SQL Checklist for SharePoint 2013

Tuesday 14 December 2010

ULS Viewer

Problem:  The ULS log generated by SharePoint 2010 are difficult to read and review as the logging is store in flat text files.

Initial Hypothesis: ULS Viewer allows the administrator/developer to track, understand and solve issues on your SharePoint environment.  The ULS viewer is not a supported product my Microsoft however, it is alot easier to discover errors than using notepad and opening each ULS log.  Logs are located at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS by default.

Resolution:
1.> Download the ULS Viewer
2.> Map a folder to the c drive on my UAT environment.
3.> Open the ULS Viewer.
4.> To view the logs as the are added, Click File > Open From > ULS, select the Logs location on your mapped drive.
5.> Add multiple WFE's log by using the File > Append From option.
6.> To view historic files, copy the log files from the server to your local machine and click File > Open From > File, select multiple ULS log files to see the server history.

How to use the ULS Viewer blogs:
Jie Li
Jeremy Taylor

Wednesday 8 December 2010

Uploading multiple files in a document library

Problem: In a SharePoint 2010 document library, the "Upload Multiple Document" option behaves differently in Internet Explorer (IE) in the User Interface (UI) on end user machines.  Either the "Drag and Drop" or the "multi tick tree view upload view" is shown in IE for multiple file uploads. 
Initial Hypothesis
1.> I originally thought Silverlight was responsible for the different displays, I remove Silverlight from the client machines and I still see the working drag and drop control.  Therefore the difference has nothing to do with Silverlight.  Additionally, this is not an IE version issue.
2.> Removing Silverlight and restarting the browser/machine has no effect, I still can use the drag and drop control. The ActiveX control that performs the upload must be responsible for the UI.  More info. 
3.> Only IE has the option to "Upload Multiple Document".   The "Upload Multiple Document" is not available in FireFox or Chrome.
4.> The Office ActiveX plug in is STSUPLD.DLL.  I found the file on my client machine located at  e:\Program Files(x86)\Microsoft Office\Office14\STSUPLD.DLL.  My version is obviously part of the Office 14/Office 2010 release. 
5.> Removing the  e:\Program Files(x86)\Microsoft Office\Office14\STSUPLD.DLL file and restarting IE results in the "Upload Multiple Document" option being disabled (greyed out).
6.> Replacing the STSUPLD.DLL with the Office 2007 STSUPLD in the Office14 or Office12 directory does not fix the issue it merely still greys out the "Upload Multiple Document" option.

Resolution:  The behaviour is part of the version of Office installed on the client machine.  The multi upload option is only available in IE if the client has the ActiveX control installed with Office.  I believe it comes down to the last office product installed so if you have Office 2010, you get the drag and drop UI however if you install SharePoint Designer 2007, you will see the tree view as you will be using the STSUPLD.dll from Office 2007.  Functionality is really out of your control as it comes down to the client machine setup.  You can do javascript to check the plug-in version and change default display if you need to.

Check your version by finding the STSUPLD.DLL (I think you can do it in IE also), the details of the 3 versions are shown below:
 
Office VersionDll VersionDll Size
Office 200311.0.5523.0?
Office 200712.0.4518.101422kb
Office 201014.0.4761.100078kb

Tip: The ability to use Windows Explorer to upload files to a SharePoint document libray relies on the Os being 32bit.  So on the x64 bit Windows Server, you can't upload files using Windows Explorer.


This control is currently disabled - Document library

Problem: Upload Multiple Documents is disabled with the message "This control is currently disabled.".  If the new documents and various other documents on the ribbon are disable and showing the same message.

Initial Hypothesis:  The Authentication provides have not been configured to Enable Client Integration.

Resolution: CA > Manage Web Applications > Select the WA > Authentication Providers > Select the zone > Enable Client Integration = Yes.