Archive

Archive for the ‘Development’ Category

The basics of a Lync 2010 & SharePoint 2010 Web Part

July 28, 2011 1 comment

Lets make a web part that’s extremely simple to show you the basics of Lync 2010 and SharePoint 2010 development.  The web part will use Lync Controls (link) to display the current logged-in user’s picture, status, and allow them to change their status.  Lets get to it!

 

To Start, make sure you have the Lync 2010 SDK, UCMA 3.0 SDK, SharePoint SDK, SharePoint 2010, and Lync 2010 installed on the same server…its pretty ridiculous that you need all of that just to build this…I wish it was a little more simpler that that.

 

You will be building a Silverlight application using the project template provided by the SDK.  You can develop your .XAP file in that solution, and when you are finished, add it using the OOTB Silverlight Web Part (or add to your Visual Web Part).

 

For your first try at a Lync 2010 Web Part, I would use the controls that have a prefix of “MYxxxx”.  Drag the MyStatusArea Control onto your canvas for your first web part.  This is a good sample, because it will automatically match up your sip address (required for Lync Controls to show people info).  If all goes well, you should see your info in the control below.  Oh yea… don’t forget to add it to a Silverlight Web Part for the full effect =)

 

MyStatusArea Control

 

That’s all good…but I’m sure you want to do something a little more dynamic.  To do that, you will need to understand the concept of a SIP address as it relates to Lync 2010.  That address is the “key” that binds your Lync Control to a Lync Object (person, or asset) so that you can see the status and interact with that object.  The sip address is formatted in a specific way…but can vary between implementations.  Its usually in the form of an email address.

 

You can use another control, called a “CustomContactList” to display a custom amount of users in a list.  This control is great, because we can bind it to a collection of objects and bind properties of that object to the properties of that control (so…have a property called sip and bind it to the SOURCE property of the CustomContactList).  This is what it looks like when completed.

 

CustomContactList Control

 

So however you get your list of users…you can bind them to the source property and easily see those users in your custom application.  Theres about 20 controls that work with Lync and I’m sure there are more… endless possibilities for custom applications.  The final piece to this puzzle is to use the Silverlgiht Client Object Model to query data from SharePoint.  Thats for the next post… =)

Categories: Development, Lync 2010, SP 2010

Just completed 70-573 & 70-667!

February 10, 2011 Leave a comment

Well, its been a while since I’ve posted. I do have news though… I’ve completed 70-573 & 70-667 MS Certification exams =).

I started studying those with the intention to post up a quick study guide. But as I was writing away…I thought that there must be a better way to help others study. So I searched on the internet and found what other people thought was the best way to study for these exams. In this post, I’d like to talk about how I studied for these exams.

First of all, schedule your exam first. That way, there is a clear deadline and force you to study.
Second, make sure you have a SharePoint environment to play with. You will want to test examples, play around in the environment, and get that experience that the exam is testing.
Third… get hands-on experience. Search for legit study guides. Also…take a free trial or two and see some questions!
Fourth, take the exam under the right mind-set. Get a good night sleep and eat before you take the exam. Also, remember your test-taking skills!

Bonus: 70-573 study guide…seriously…check this out, its awesome!
http://blog.beckybertram.com/Lists/Exam%2070573%20Study%20Guide/AllItems.aspx

Hopefully this mini-guide was helpful! Good luck on any future exam!

—–

update….passed 70-668 using the same steps.  I would approach the 70-668 exam the same way I approached the MCTS ones….however the MCITP & MCPD ones seem to be a more experience based questions.

—–

-Matt

Manage SPSite and SPWeb programmatically by using Visual Studio 2010

November 17, 2010 10 comments

This one seems pretty easy…but there are some caveats. I think whats most important here is the use of the many properties and methods. You can view each class by going to these links: SPSite & SPWeb.

Here is the Skill Measured: This objective may include but is not limited to: creating sub webs, referencing SPFiles, manipulating property bag, when to call Update, referencing SPContext, SPSite, SPWeb, SPSite.OpenWeb, SPWeb.Webs, feature activiation and deactivation

Note from MS: This objective does not include: trivial cases such as setting title and other loose properties of the objects

Lets start off by looking at each class. Lets start with SPSite, as you will instansiate this prior to instansiating SPWeb (if instansiating).

SPSite

This is the way, in the object model, that we get information about collections of sites in SharePoint. Since our farm (from a content perspective) is built into many, many site collections, this is the appropriate method for manipulating and building context around a site collection.

You can instantiate an SPSite object by using many of its constructors. Here are some examples:

Using absolute URL signature:


SPSite site = new SPSite("absoluteUrl");

Using an SPContext object:

string siteUrl = SPContext.Current.Site.Url;
using(SPSite site = new SPSite(siteUrl))
{
//code
}

In my opinion, the most important part of using an SPSite object is disposing of it properly. In summary, disposing of this object will call garbage collection and free resources up in memory. This also prevents memory leaks…which is a very real possibility with using SPSite objects with other objects. Below is an example of how to dispose of your SPSite object:

Guid guid = SPContext.Current.Site.ID;
Using(SPSite site = new SPSite(guid))
{
	My code
}

There are A LOT of members in SPSite. I’m not exactly sure it’s a great use of your time to know all of the members in SPSite. Here is a small table of some of the SPSite members I think are important. **I think you should definetly check out the remaining SPSite Members…I’m just not going to list them all…http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite_members.aspx**

Methods

CheckForPermissions Checks the permissions for a given set of rights and throws an Unauthorized Access exception if the permission check fails.
Delete Overloaded. Deletes the site collection from the server.
Exists Returns a Boolean value that indicates whether the specified site collection exists.
OpenWeb Overloaded. Returns the specified Web site from the site collection.
Rename Changes the URL of a host-header-named site collection to a new URL.

Properties

All Webs Gets the collection of all Web sites that are contained within the site collection, including the top-level site and its subsites.
Features Gets the collection of SPFeature objects that are associated with the site collection.
ID Gets the GUID that identifies the site collection.
Owner Gets or sets the owner of the site collection
PortalName Gets or sets the name of a portal
PortalURL Gets or sets the url of a portal
ReadOnly Gets or sets a Boolean value that specifies whether the site collection is read-only, locked, and unavailable for write access.
RootWeb Gets the root Web site of the site collection.
Solutions Gets the collection of user solutions (sandbox solutions) that have been activated for the site collection
Url Gets the full URL to the root web site of the site collection, including host name, port number, and path.
WebApplication Gets the SharePoint Foundation Web application to which the site collection belongs to

SPWeb

From SPSite, we can then traverse into SPWeb. This class represents each web in a site collection (I’d say site…but not to be confused with SPSite). This class lets us change properties of webs and build out more context (so we can use SPList and so on).

Like SPSite, you instantiate SPWeb objects but use an SPSite object to build it out…like so:

Using SPSite.RootWeb (returns the top web of a site collection)

SPWeb web = SPSite.AllWebs["webName"];

Like SPSite, properly dispose of SPWeb objects with a using(){} statement. Like so…

using(SPWeb web = SPSite.RootWeb)
{
}

SPWeb has many members just like SPSite…but important to this exam is that it gives access to the Property Bag. Each SPWeb object has a couple of methods that allow you to get/set properties. Additionally, you can enumerate through each property in the Property Bag. Think of the Property Bag as a hash table for keys/values of settings in a SPWeb. An example of such a property is the default permissions groups for a web. The Property Bag stores which group is used as the Visitors, Members, and Owners group. Another one I’ve used in the past is to set the search center scopes.

Whenever you update a setting on a SPWeb object, you must call the SPWeb.Update() method to commit the changes.

Use the SPContext.Current.Web (or SPContext.Current.Site.RootWeb) to manipulate the current web settings. Don’t forget to call the Update() method to commit your changes.

Methods

CustomizeCSS Customizes the specified style sheet for the site. Use this method to apply an overriding style sheet for SharePoint branding.
Delete Deletes the Web site
DeleteProperty Deletes a property from the property bag
EnsureUser Checks whether the specified login name belongs to a valid user of the Web site, and if the login name does not already exist, adds it to the Web site.
GetFile Overloaded. Returns the file object with the specified GUID or the file object that is located at the specified URL.
GetList Returns the list that is associated with the specified server-relative URL.
GetProperty Gets a property from the property bag
SetProperty Sets a property in the property bag to a value
Update Updates the database with changes that are made to the Web site.

Properties

Alerts Gets the collection of alerts for the site or subsite
All properties Gets a hash table that contains metadata for the Web site.
CurrentUser Gets the current user of the site.
Features Gets the collection of Features that are currently activated in the Web site.
Lists Gets the collection of all lists that are contained in the Web site.
MasterUrl Gets or sets the URL of the master page that is used for the Web site. Use this property to set a custom master.page url in SharePoint Branding
Title Gets or sets the title for the Web site.
Webs Gets a Web site collection object that represents all Web sites immediately beneath the Web site, excluding children of those Web sites.

To programatically create a new subweb, create your context (I.E. which web you would like to create the web under. Then call the following code:

SPWeb newWeb = web.Webs.Add("overloads here");

newWeb.Update();

You can programatically add/remove Features from the feature list by calling SPWeb.Features.Add() or SPWeb.Features.Remove().

Feel free to post comments below on what you think of this write-up. Thanks!

-Matt Huber

Categories: 70-573, Development, SP 2010