Nov 1, 2011

SPLongOperation Class in SharePoint

 Hi All,

Recently  I worked with this class in one of my projects to show the user with useful message when a long operation/activity is taking place in the background..I thought to share with you...

Here is the sample to use this..a webpart with a button. On click of button I am calling this..

protected void btnLoad_Click(object sender, EventArgs e)
{
  using (SPLongOperation myOperation = new SPLongOperation(this.Page))
  {
    //main bold text when action is in progress
    myOperation.LeadingHTML = "Hey..! Connection established to the database server"; 
    //small text when action is in progress
    myOperation.TrailingHTML = "Please wait during the data fetch"; 
    //start the operation
    myOperation.Begin();             
    //our long running action here
    System.Threading.Thread.Sleep(120000);//2 mins 
   //end of the operation and it redirects to home page after end of the operation
    myOperation.End("/sitepages/home.aspx");             
           
  }
}

Here is the result of this..




Happy Reading..!

SharePoint 2010 PowerShell Basics


Hi guys,

In this post I am going to explain you what is powershell management tool  in sharepoint , how it will be used and how it is different from the classic stsadm tool.

What is Sharepoint 2010 Management Shell :

In Sharepoint 2010 , a new feature called sharepoint 2010 management shell is included to work with the administrative jobs as we can do with the stsadm.exe in prior(moss).

Generally we can say powershell is a task automation tool which is built on top of the .net frame work. to achieve the administrative tasks .Here we write the  cmdlets(Command lets) , as command in the cmdprompt/stsadm. And also along with the cmdlets, the powershell can  execute the scripts,functions and executable programs too.  Here I will give a basic idea on the cmdlets..

Cmdlet ( called as command let )  : Its like a command to performs the task, takes the input and generally returns the .net frame work objects. The cmdlet is a combination of verb and noun in syntax.

Syntax  : The syntax is like Verb-Noun

Eg : Get-SPSite  

Start working with Powershell :  

Open the sharepoint powershell  console

StartàAll programsàMicrosoft Sharepoint 2010 ProductsàSharepoint 2010 Mangement Shell-->Right click on it and run as administrator




Execute the above mentioned command Get-SpSite.It gives all the site collections as below






There are many pre defined cmdlets introduced with the SharePoint 2010, you can find here. Here  I am giving the basic cmdlets to know

1.Get-Command : It will list all the cmdlets 

In above cmdlet if we specify the command it will give the entire syntax like this 

Ex : get-command  enable-spfeature

This gives you the entire syntax of the enable-spfeature cmdlets like this

Enable-SPFeature [-Identity] [-AssignmentCollection ] [-Confirm []] [-Force ] [-PassThru ] [-Url ] [-WhatIf []]

2.Get-Help  : It gives you the help topics:

Like if you know the part/word of the command and want to know the full cmdlets then you can use this like

Get-help *feature*

This will list all the commands which contains the word feature


3. Get-command  –verb   : will list all the cmdlets which has the verb

Eg :  get-Command  –verb , lists all the cmdlets which has the verb ‘enable’



4. Get-Command  -noun   : will lists all the cmdlets which has the noun

Ex:  get-Command –noun spsite,
 list all the cmdlets which has the spsite as noun






5. Get-help -examples

If you want any cmdlet with a example use this cmdlet

Eg : get-help enable-spfeature –examples


This will give the example of the cmdlet which enables the  feature in a given scope level (site/subsite) like this



The below are the cmdlets we use at the time of deployment

Adding the solution :
Add-SPSolution -LiteralPath  c:\purna\ Mywebpcm.wsp
Installing the solution :
Install-SPSolution -Identity Mywebpcm.wsp -GACDeployment
Updating the solution :
Update-SPSolution –Identity Mywebpcm.wsp –LiteralPath “C:\purna\ Mywebpcm_v2.wsp” –GacDeployment
Uninstalling the solution :
 Uninstall-SPSolution –Identity Mywebpcm.wsp –WebApplication http://pcmweb  
Removing the Solution :
Remove-SPSolution–Identity Mywebpcm.wsp
How cmdlets are different from the stsadm commands ?
1.  Cmdlets are based on the .net Frame work they are the instances of the .net framework classes. (Ex : when we get the error it throws a object based error instead a simple text as in stsadm)
2 . You can sort /format the result this was not possible with the stsadm.

Here are the more cmdlets from the msdn  article..

Happy reading..!