Loading...

Saturday, October 29, 2011

Sharepoint 2010 REST API to get the List and Library Data


1)What is REST?
Representational State Transer

2)What we can do with it?

i) Query Service Application  like excel services
 and display the excel Charts.
 ii)Query  List Data and Display data with Jquery or Silverlight(/_vti_bin/listdata.svc)

Wednesday, October 19, 2011

Sharepoint 2010 Social Features:Tag Cloud By AccountName


In OOB tag cloud, we get tag cloud only by Current user or By All tags.
To Customize tag cloud by accountname or profile ,
1. Add the reference of /_layouts/1033/styles/socialdata.css in page layouts or masterpage.

2. Add dll reference C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\microsoft.sharepoint.portal.dll
3. In Visual studio, Right click solutionAdd service reference click on ‘Advanced’ buttonAdd web referenceclick link Web services on local machine.
4. Search for socialdataservice.asmx.

public class TagWP : WebPart
{

localhost.SocialTermDetail[] details;

localhost.SocialDataService objSocialDataService = null;

long tagCount = 0;

protected override void CreateChildControls()

{

objSocialDataService = new localhost.SocialDataService();

int maximuItems=10;
int intstartIndex=1;
objSocialDataService.Credentials = System.Net.CredentialCache.DefaultCredentials;
string accountname= SPHttpUtility.HtmlEncode(Context.Request.QueryString["accountname"]);
details = objSocialDataService.GetTagTermsOfUser(accountname, maximuItems);
}
protected override void Render(System.Web.UI.HtmlTextWriter writer)

{
writer.Write("DIV id='tagCloudDatatagCloudByProfile' class='ms-TagCloud ms-TagCloudLink


");

writer.Write("DIV id='tagCloudByProfile'

");

Sunday, October 9, 2011

Sharepoint 2010 Social Features: Rating Publishing Pages/Blog pages

1)Enable the publishing features in site collection/site level

In Page Library Settings-->Rating Setting -->Enable the Contents to be rated.
Edit the Page in Sharepoint Designer or modify the Pagelayouts.

2)Add the namespace
%@ Register TagPrefix="SharePointPortalControls" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %

3)Make sure that User Profile Service application is running in CA-->Manage Service applications
Add Rating Control  in Page Layout
SharePointPortalControls:AverageRatingFieldControl FieldName="Rating" runat="server"

Make sure that Field Name matches the Rating Column Name in Page Library.
4) To view the quick effects
CA > Monitoring > Timer Jobs > Review Job Definitions > look for 'User Profile Service Application - Social Data Maintenance Job' and 'User Profile Service Application - Social Rating Synchronization Job'.
Run the jobs.
5)If You get the Error 'Object reference not set to an instance' on viewing rated publishing Page
cmd-->inetmgr ->Restart SharePoint Web Services under Sites

6)
Include the reference of JS file in Page Layouts
script type='text/javascript'
$(document).ready(function() {
var pathname = window.location;
var soapEnv ="soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>\
soap:Body>\
GetRatingOnUrl xmlns='http://microsoft.com/webservices/SharePointPortalServer/SocialDataService'>\
url>+ pathname + /url>\
/GetRatingOnUrl>\
/soap:Body>\
/soap: Envelope>"
alert (soapEnv);
$.ajax({
url: "http://servername/_vti_bin/SocialDataService.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset=\"utf-8\""

});

});

function processResult(xData, status) {

var result = $(xData.responseXML).find("Rating")
//get rating value from webservice
var avg = parseFloat(result.text());

$(".ms-currentRating img").addClass(getClassNameForRating(avg));

}
function getClassNameForRating(rating) {
//apply class according  to ratings
if(isNaN(rating)

rating = 0)

return "";

if (rating < 0.25)

return "ms-rating_0";

if (rating <; 0.75)

return "ms-rating_0_5";

if (rating <; 1.25)

return "ms-rating_1";

if (rating < 1.75)

return "ms-rating_1_5";

if (rating < 2.25)

return "ms-rating_2";

if (rating < 2.75)

return "ms-rating_2_5";

if (rating < 3.25)

return "ms-rating_3";

if (rating < 3.75)

return "ms-rating_3_5";

if (rating < 4.25)

return "ms-rating_4";

if (rating <; 4.75)

return "ms-rating_4_5";

else

return "ms-rating_5";

}



/script>