SERVER OBJECT MODEL:
Can we integrate SharePoint 2010 objects with standard Desktop application created using WPF or WinForm?
Can we integrate SharePoint 2010 objects with standard Desktop application created using WPF or WinForm?
SharePoint 2010
provides the Server Object model using which SharePoint WebSite
Collection, WebSite, Lists and similar kind of objects can be accessed
and programmed in client applications like WinForm, WPF etc. For this
article, I am assuming that the readers know how to create a SharePoint
List. I have created a simple website where Sales information is stored
using the SalesInfo List as shown below:
In this article, I am targeting the SharePoint 2010 List Object. Shown below is the object model for the List:
The above object model clearly indicates that to program against the SharePoint ListItem (SPListItem) in the SharePoint, you need to iterate through the SharePoint SiteCollection (SPSite). The SPWeb represents the Web site which contains the SharePoint List (SPList).
In the scenario below, I
am using the SalesInfo SharePoint List for sales statistics of a
product across various regions. This allows various sales persons to
collect region wise sale data and update the List developed using the
SharePoint technology.
Creating a WPF Desktop client Application
Step 1: Open
VS2010 and create a WPF application called ’WPF_SPS_Server_Object’.
Make sure that it targets .NET 3.5 frameworks since the SharePoint 2010
object model currently targets .NET 3.5.
Step 2: In this project, add a reference to Microsoft.SharePoint.dll. You can find it on your machine on the following path:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI
Step 3: Design the WPF application as below:
Step 4: In the MainPage.xaml.cs, use the SharePoint assembly as shown below:
using Microsoft.SharePoint;
Step 5: In the Click event of the ‘Save List’ button, add the following code:
The above code works with SalesInfo List in the ‘http://shiva-pc/sites/Products’ site collection. Please read comments in the code carefully.
As you can see, the
code shown above makes easy use of the SharePoint 2010 object model.
Using this feature of SharePoint, a user can update the SharePoint
application without physically using/logging into a browser. This
feature is used by developers who are responsible to make new data entry
on the SharePoint portal from their desktop applications.
No comments:
Post a Comment