Skip Ribbon Commands
Skip to main content

Tanmay Shahane | zevenseas | SharePoint Blog

:

Tanmay Shahane | zevenseas | SharePoint Blog > Posts > Getting Site usage info in SP2010 using Client Object model
August 07
Getting Site usage info in SP2010 using Client Object model

  Hey kind readers... whats up :)

There are times when we want to track the usage info report on our SharePoint site… now this can also be done using the new super wonder the client object model is making this task very much client side and efficient.
 

 

So if you want to build a simple client side interface to get the site usage report on a site you can use the Client Object model paired with JQuery to do the same as following,
 
function GetWebSiteData() {
       var context = new SP.ClientContext.get_current(); //get the current site context
       var site = context.get_site();  // get reference to current site collection
       context.load(site,'Usage'); // load the 'Usage' property for the current site (this does not give direct usage but an object)
       context.executeQueryAsync(function(sender, args)
       {
var usageInfo = site.get_usage(); // this gives the instance of SP.UsageInfo class which can be further used to get usage information
// Now this object can be used to get all the usage properties by doing usageInfo.get_storage()
 
Bandwidth
Discussionstorage
Hits
StoragePercentageUsed
Visits
 
       });
}
 
As simple as that...this can help in making a real easy client side storage monitoring system without have to wake up a visual studio from its sleep to take at least an hour to load on a slow machine and also is a efficient way when you want fast and efficient processing coupled with rich user interface for the end user.

 

Comments

Awesome!

Great Post Dude..
ZSHOSTED\vardhaman on 8/8/2011 12:09 AM

Great

Very nice post man....so helpful.

SC Vinod
 on 8/24/2011 7:02 PM

Thanks

glad was useful
Tanmay Shahane on 9/17/2011 7:11 AM

Add Comment

Title


Body *


Attachments

 

 Related Posts

 
 

 Statistics

 
Views: 1398
Comments: 3
Tags:Client Object Model
Published:649 Days Ago