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

Thursday, April 28, 2011

SharePoint Object Model -Samples

There are several namespaces(around 50) that house the SharePoint object model. Out of these 50 namespaces we are using only 16 namespaces, rest of the namespaces are reserved for Microsoft internal use.

1. Document Library

image1.gif

Document libraries are a special type of list designed to store documents.To access a document library through object model we need to use Microsoft.Sharepoint namespace. To use this namespace in ASP.net we need to add a reference of Microsoft.Sharepoint.dll. This dll we can find from the below mentioned path:

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI

Let's take each and every class in this namespace:

  • SPDocumentLibrary Class:

    This class represents a document library in Windows Sharepoint Services.
    In C# code: SPDocumentLibrary obj = (DocumentLibrary)oList
    oList is an object for list. The above code will cast the list object into Document Library.

  • SPPictureLibrary Class:

    This class represents a picture library in Windows Sharepoint Services. Both classes are used in the sane manner. The only difference is: As the name indicates SPDocumentLibrary is used for Document Library and SPPictureLibrary is used for Picture Library.
2. Features:

image2.gif

For using the features through Sharepoint object model we need Microsoft.Sharepoint dll and you can get the dll from the above mentioned path.
  • SPFeatureDefinition Class: Contains the base definition of an SPFeature, including its name, identifier, scope, and version
  • SPFeatureScope Class : Specifies the scope to which the feature applies.
  • SPElementDefinition Class: Serves as the base class for implementing element types within Windows SharePoint Services
  • SPFeature Class: Represents the state of a feature at its corresponding scope
  • SPFeatureProperty Class: Represents a single Feature property.
Code Example:

SPSite oSpSite = new SPSite("http://YourServer");
SPFeatureCollection oSPfeatureCollection = oSpSite.Features;

foreach (SPFeature oSPFeature in oSPfeatureCollection)
{
SPFeatureDefinition featureDefinition = oSPFeature.Definition;
SPElementDefinitionCollection elementDefinitionCollection =
featureDefinition.GetElementDefinitions(System.Globalization.CultureInfo.InvariantCulture);

foreach (SPElementDefinition elementDefinition in elementDefinitionCollection)
{
Console.WriteLine(elementDefinition.Id);
}
}

Ref: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfeatureproperty.aspx

3.

image3.gif

For using meetings through object model we need to add Microsoft.Sharepoint dll as mentioned above. The classes under this category are explained as below:

SPMeeting Class:- Provides methods and properties that can be used to work with a Meeting Workspace. Suppose if you want to create a meeting workspace through object model then we need to use this class. There are different kind of meeting template that can be handled like Basic meeting, Decision Meeting, Multiple meeting etc.

MtgUtility:- Initialize a new instance of the MtgUtility class. To access the MtgUtility service and its methods, set a Web reference to http://Server_Name/[sites/][Site_Name/]_vti_bin/xxx.asmx.

Microsoft.SharePoint.Meetings.MtgUtility – System.Object

4.

image4.gif

Sites objects are used to access the sharepoint site, The classes under this category of Sharepoint Object model are explained as below:

SPSite: . Represents a collection of sites in a Web application, including a top-level Web site and all its subsites. Each SPSite object, or site collection, is represented within an SPSiteCollection object that consists of the collection of all site collections in the Web application.

SPWeb: Represents a Windows SharePoint Services Web site.

CODE Example:

using(SPSite oSite = new SPSite("http://Server_Name"))
{
using(SPWeb oWebsite = oSite.OpenWeb("Website_URL"))
{
using(SPWeb oWebsiteRoot = oSite.RootWeb)
{
...//Your Code
}
}
}

5.

image5.gif

Provides administrative types and members for managing a Windows SharePoint Services deployment. There are so many classes, delegates, interface under this namespace but only few classes I am going to explain.

SPSolution : Represents a solution on a farm.

Namespace: Microsoft.SharePoint.Administration

Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)

SPFeatureReceiver:

Base abstract class that can be overridden to trap the activation, deactivation, installation, or uninstallation of a Feature.

Namespace: Microsoft.SharePoint

Assembly: Microsoft.SharePoint

Use the SPFeatureReceiver class to trap events that are raised after the Feature installation, uninstallation, activation, or deactivation action has been performed.

It is not possible to cancel an installation or uninstallation through Feature events.

SPSolutionCollector:

Represents a collection of SPSolution objects.

Namespace: Microsoft.SharePoint.Administration

Assembly: Microsoft.SharePoint

6.

image6.gif

SPList object represent a List, SPListItem represent a List Item in the List and SPListItemCollection object represent a full item collection in the SPLIST.

Code Example:

SPList mylist_Name = myweb.Lists["Category"];
SPListItemCollection itmcln = mylist_Name.Items;
foreach (SPListItem itm in itmcln)
{
if (itm["ItemCategory"] != null)
{
ddlCategory.Items.Add(itm["ItemCategory"].ToString());

}
}

7.

image7.gif

8.

image8.gif

This is all about Sharepoint Object Model.

Monday, April 25, 2011

SharePoint Object Model - A beginner Overview

Introduction

SharePoint provides a solid framework for the .Net developers to write code against and extend sharepoint functionality. As sharepoint is done on ASP.NET 2.0 and have a power code base of .Net Class libraries, a lot of developers can now make use of them and create excellent applications utilizing sharepoint features and libraries. In this tutorial i will explain on how to open sharepoint site using Visual Studio and then connect with a document library inside sharepoint and get the creation date of the document library. This feature is not given in the sharepoint out of the box so we need to do custom development to find out this information.

Using the code

Lets get directly to the code. The first thing we need to do is to setup our development environment. This is a bit tricky. We can do couple of things.

  • Setup of development tools where sharepoint portal is installed
  • Create virtual pc of sharepoint and install sharepoint on that
  • copy sharepoint dlls to your development pc and reference those dlls in the visual studio but keep in mind that debugging will be very difficult

OK now in my scenario i used a virtual pc and sharepoint VHD boot it up and opened the visual studio. I referenced Microsoft.SharePoint dll and referenced it inside the code behind as well.

Collapse
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint;

I dropped a couple of drop down lists on the form and a text box where the user will give its portal name. Once typing portal address the user will click connect. This event will populate the drop down with all the sites created on the portal.

Collapse
private void cmdConnect_Click(object sender, EventArgs e)
{
cboLists.Items.Clear();
SPSite mysite = new SPSite(txtURL.Text.Trim());
foreach (SPWeb myweb in mysite.AllWebs)
{
cboSites.Items.Add(myweb.Title);
}
}

As you can see from above, i have used SPSite class to open a site and passed the url of the site as constructor. Once opened this site class has a web collection class. I looped through all the webs created and listed them in the drop down.

Now the user will select the site where the document library exists. On the selected index changed, i have populated next drop down with all the lists and libraries.

Collapse
        private void cboSites_SelectedIndexChanged(object sender, EventArgs e)
{
mysite2 = new SPSite(txtURL.Text.Trim());
myweb2 = mysite2.AllWebs[cboSites.SelectedItem.ToString()];
foreach (SPList lst in myweb2.Lists)
{
cboLists.Items.Add(lst.Title);
}
}

What happened just now is the most intresting part. Here we opened the site, got the web from the user selection of the drop down and put it in SPWeb class. SPWeb class now contains all the document libraries and lists you have in your site. As you can see we are looping through the list collection in the spweb.We are adding all the lists and libraries in the drop down as we loop.

Now once the user selects the library, he will see the creation date of the library in the label control.

Collapse
private void cboLists_SelectedIndexChanged(object sender, EventArgs e)
{
SPList mylist = myweb2.Lists[cboLists.SelectedItem.ToString()];
DateTime datecreated = mylist.Created;
lblDate.Text = datecreated.ToShortDateString();
}

As can be seen, we got the list in SPList class and utilized its created property to find out the list creation date.

Points of Interest

The main point of interest part here is to see how to connect to a site, open its web and iterate through its list and libraries. Then to see how to get the properties of the lists and libraries. SPSite, SPWeb and SPList are the major classes we used to achieve our goal. In my next writing i wil explain how to go beyond and access individual list items.

Hence the object models looks like

SPSite

SPWeb

SPList

SPListItem

Tuesday, March 1, 2011

Installing SharePoint Server-2010

Installing SharePoint Server-2010

1)How to install SPS2010 in Single Box Development Server?



2)Create a Sharepoint 2010 VM in 32 bits host machine
Download doc for details



1)How to install SPS2010 in Single Box Development Server?

1. After you have finished installing OS, start to add Active Directory Domain Service roles.
Complete the installation procedure and configure the roles.
2. Then, start to add Application Server and Web Server roles.
This installation is straight forward, and you will be easily get your Application Server and Web Server roles configured in the machine.
3. Install SQL Server 2008 SP1 + CU KB970315
Download SQL Server 2008 SP1 here: http://www.microsoft.com/downloads/details.aspx?familyid=66AB3DBB-BF3E-4F46-9559-CCC6A4F9DC19&displaylang=en

Download CU KB970315 here: http://support.microsoft.com/kb/970315

And here is the tricky part, installing SPS2010

4. Extract SPS2010 installer to a folder

/extract:e:\sps2010

That command will extract to folder e:\sps2010. Replace with your own distribution.

5. You will see that there is several sub-folder under Files folder in the extracted location. Each sub-folder represents different setup option. For example, SetupFarm contains configuration files for farm installation option etc.

6. Start the installation sequence by executing following command in the extracted location.

Setup.exe /config Files\SetupFarm\config.xml


Refer:

http://andreasglaser.net/post/2009/11/17/Installing-SharePoint-Server-2010-on-Windows-Server-2008-R2-and-SQL-Server-2008-R2-Part-1-Overview.aspx

http://www.ericharlan.com/Moss_SharePoint_2007_Blog/how-to-install-sharepoint-2010-guide-a166.html

Monday, February 14, 2011

How to Add STSADM in path using Windows Server 2008

I always keep STSADM in path, because it very useful. You can also create a shortcut for command prompt configured for STSADM.

For Sharepoint 2007
Usually STSADM.exe exist in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\.


For Sharepoint 2010

Usually STSADM.exe exist in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\

Click on ‘Start’
Right Click on ‘Computer’ and select Properties
Select ‘Advanced System Settings’
Click on the ‘Environment Variables…’
Now select the ‘Path’ from system variables
Click Edit

Their will be already may be some path available you just append this new path
first add ;(semicolon) then your path of BIN folder (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\
) where stsadm.exe will be.
Add this path (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN) in existing path seprated by ‘;’
Thats all, now you can use STSADM from anywherein command prompt.

Tuesday, September 28, 2010

What SharePoint Can Do ????


SharePoint is one of the most useful, versatile and beneficial technologies you can use. SharePoint can do many things for you, from managing data to document sharing to instant messaging. If you take a few minutes to think about the things SharePoint can do for you, you might just be pleasantly surprised.

On a basic level, SharePoint can provide you and your organization a way to share knowledge. Sharing knowledge benefits you on several levels. It helps to reduce the duplication of effort inside your organization. Users can become more efficient, building off one another’s work instead of creating everything they might need from the ground up.

In addition, the kind of knowledge sharing that SharePoint provides your business helps to streamline the knowledge sharing process. Rather than having to look in several places – such as a server, a personal computer and a filing cabinet – your employees can find all of the information in the SharePoint repository.

One of the best things about SharePoint is that it makes finding documents easier. While most companies have a way to share documents, SharePoint lets you do it in a uniform way. For example, attaching documents to email messages means that only the recipient of the email message has access to the document. In addition, to get any use out of the document in the future, that user has to be able to remember the particulars of the email in order to find the document. SharePoint puts the document in a central location where it is easily accessed.

In addition to easy access, SharePoint lets users have the latest and best information available. If you send someone a document via Email or burn a document to a CD, the recipient will only ever have that version of the document. If you update the document in the future, you’ll have to send an entirely new Email or burn a new CD. With SharePoint, you simply update the document on the SharePoint server and the user will have the latest version at their fingertips.

SharePoint can also reduce your overall need for Information Technology consulting or personnel. For example, SharePoint can empower your Human Resources personnel to make information available directly to employees via SharePoint, rather than having to place a request with your IT department and waiting for them to make the information available.

You can also use SharePoint to provide data and information across your organization to users without specialized knowledge or without specialized software. You could post accounting data to SharePoint, for example, which could then be used by other departments without having to install the accounting software and without having to make a formal request to the accounting department. In this way, SharePoint makes your company’s important data more accessible to the entire organization.

If you need a more effective way to share information across your company, consider implementing a SharePoint solution. SharePoint can make your business run smoother, and can do it in such a way that actually saves you money and increases productivity

Friday, September 24, 2010

Changing Face of MOSS 2007 To sharepont 2010

The SharePoint 2010 Microsoft has regrouped all the feature into 6 new Feature Area

Here is the Mapping between the Feature Areas from Office SharePoint 2007 to SharePoint 2010

1. Collaboration is now Communities


2. Portals is now Sites


3. Business Processes is now Composites

4. Business Intelligence is now Insights


5. Search is Search


6. Content Management is now Content






Popular Posts

Recent Posts

Unordered List

Text Widget