Posts

Showing posts from January, 2014

Overloading vs Overriding in c#

Overloading Overloading is when you have multiple methods in the same scope, with the same name but different signatures. //Overloading public class test { public void getStuff ( int id ) {} public void getStuff ( string name ) {} } Overriding Overriding is a principle that allows you to change the functionality of a method in a child class. //Overriding public class test { public virtual getStuff ( int id ) { //Get stuff default location } } public class test2 : test { public override getStuff ( int id ) { //base.getStuff(id); //or - Get stuff new location } }

programmatically set a user as the Site Collection Administrator in SharePoint (RunWithElevatedPrivileges)

public void SetUserSiteCollectionAdmin ( string siteUrl , string strUserName , string strEmail , string fullName ) { SPSecurity . RunWithElevatedPrivileges ( delegate () { using ( SPSite site = new SPSite ( siteUrl )) { using ( SPWeb web = site . RootWeb ) { web . AllowUnsafeUpdates = true ; web . AllUsers . Add ( strUserName , strEmail , fullName , null ); SPUser spUser = web . SiteUsers [ strUserName ]; spUser . IsSiteAdmin = true ; spUser . Update (); web . AllowUnsafeUpdates = false ; } } }); }

CreatedBy name in SharePoint list item

private void btnGetDetails_Click(object sender, EventArgs e) { txtSiteUrl.Text = "http://SP2010:8080/sites/TestSite"; txtListName.Text = "Employee"; ListItemCollection itemCollection = GetData(txtSiteUrl.Text, txtListName.Text); DataTable table = new DataTable(); table.Columns.Add("ProjectNO");//projectno table.Columns.Add("CreatedBy");//Author table.Columns.Add("Primary Administrator");//Primary_x0020_Administrator table.Columns.Add("CreatedDate");//Created MessageBox.Show("Count:" + itemCollection.Count); foreach (ListItem item in itemCollection) { var Authorname = (FieldUserValue)(item["Author"]); var PrimaryAdmin = (FieldUserValue)(item["Primary_x0020_Administrator"]); string projectNo = item["Tit...

Service Applications in SharePoint 2010

Few SA Applications 1) Access Service – Allows viewing, editing and interacting with Access Database in browser 2) Business Connectivity Services – Allows interaction with LOB 3) Excel Services – Allowing viewing and interacting Excel files in browser 4) Managed Metadata Service – provides access to managed taxonomy hierarchies, keywords, social tags and content type publishing across site collections 5) Search Service Application – Provides access to manage Search Services 6) Secure Store Service – Provides capability to store data securely and associate with specific identity or group of identities 7) State Service – provides temporary storage of user session data for SharePoint Server 2010 Components 8) Usage and Health Data Collection – Farm wide usage and health data is collected by this service and provides ability to view various usage and health reports 9) User Profile Service – Enable creation and sharing of user profiles, Organization profiles and social t...

TimerJobs in SharePoint 2010

Image
Introduction: In this article we will be seeing how to create a custom timer job in SharePoint 2010 using Visual Studio 2010. A timer job runs in a specific Windows service for SharePoint Server and performs infrastructure tasks for the Timer service, such as clearing the timer job history and recycling the Timer service; and tasks for Web applications, such as sending e-mail alerts. A timer job contains a definition of the service to run and specifies how frequently the service is started. The SharePoint 2010 Timer service (SPTimerv4) runs timer jobs. In this article we will be performing the following steps Creating a custom timer job. Deploying the timer job. Registering the timer job Managing configuration data for timer jobs. Solution Overview:  I have a web application => Site Collection =>3 Subsites as shown in the above diagram. Each subsite has a custom list รข€“ "Projects" which has the following columns and values LN subsite: ...