My first Windows Phone 7 application: MySite for WP7 - Part 1

A few weeks ago, my employer, Avanade Germany, announced an internal “Windows Phone 7 Contest”. The goal is to create a (business) app for Microsofts new Windows Phone 7 (WP7) system. I just had some ideas and decided to go with “MySite for WP7”. At least because I’m working in the “Portals & Collaboration” Service Line and I really like the new SharePoint 2010 MySite. That, and because the price for the best three apps is an Xbox 360 with Kinect. Winking smile

Overview

If you have no idea, what the SharePoint 2010 MySite is, here is a short introduction: Think about a “little” Facebook (social network) within your company. You can write status messages, see a newsfeed about your colleagues, post comments on the note boards of your colleagues, upload pictures, etc.

I know, that WP7 comes with SharePoint integration, but without a cool client for the MySite. I will try to build one (and hopefully win the Xbox).

Start with WP7

I will not give you an overview what you need to start, because there are a lot of resources to learn WP7 development. I already know .NET, C#, SharePoint and Silverlight and that’s everything you need to start. Download the Development Toolkit (for free) and start up Visual Studio.

First of all I decided to go with the Panorama Template, because it is easy to use and looks really nice. Also it supports my idea of different MySite tasks. The design-time support is great as well. If you click on the panorama page in the XAML code, the designer shows the corresponding page.

image

But before I go into much UI details, we should thought about the backend.

How to connect to SharePoint?

SharepPoint 2010 provides a web services API (WCF and legacy ASMX) to access most of the SharePoint functionality. Therefore I tried to access these services directly from the phone, but that did not work, because of two main points:

So obviously a workaround is required. Here is my idea of a “proxy service”:

image

That means, the WP7 app connects to an SSL secured WCF (silverlight-enabled) proxy service (without authentication) in the cloud. The service then connects to the SharePoint service with the provided credentials. For privacy reasons, a company that do not want to transmit sensitive data over the cloud service can host their own proxy service within their secure environment to make it accessible by their employees.

The proxy service can for example get the current status message from your MySite:

public string GetStatus(AccountCredentials credentials)
{
  var client = GetProfileServiceClient(credentials);

  string fqnUsername = credentials.Domain + "\\" + credentials.Username;
  var data = client.GetUserProfileByName(fqnUsername);

  var statusProp = (from d in data
                    where d.Name == "SPS-StatusNotes"
                    select d).FirstOrDefault();

  return statusProp.Values[0].Value.ToString();
}

I defined a class AccountCredentials which contains username, domain, password and SharePoint MySite URL. This data is entered in the WP7 app by the user. Now the proxy service is called with this data and calls the SharePoint profile service (with the URL provided) to get the current status message.

This approach is not only for communicating with SharePoint, but can also be used with other services which cannot directly be called from the phone.

Alternative to a Proxy Service: UAG

Another fairly new (at least for me) way is the Forefront Unified Access Gateway (UAG). See also this video from TechED. In the video you can see, that Microsoft requires a company to have a UAG in place to use the build-in SharePoint features of WP7. So it seems, that also Microsoft cannot use NTLM on WP7.

WP7 with UAG uses HTTPS for all communications and what is know as basic authentication. One problem why I’m currently not supporting UAG in my App is, because there are no developer resources how to integrate it in your own application. The only info you got from the video is to use signUrl.asp to get the token after authentication. If anyone has more info, please add a comment.

Learn more in part 2 of the series in a few days where I will talk about the User Interface.

Proxy Switcher meets Facebook, Twitter and SharePoint 2010 MySite

I was on vacation the last two weeks so I had some time for some funny things. For Proxy Switcher I thought it would be a nice idea to have an AddIn to set the status message of social networks on a network change. The two major players are Facebook and Twitter. Personally I’m not using Twitter, but that’s another story. Additionally, at Avanade we have our MySites on SharePoint 2010 with the new feature enabled to add status messages there as well. (See also our Avanade SharePoint Blog)

image

Your TODO now: Download Proxy Switcher (if its not already installed), then go to the More AddIns page to download the “Social Media Update Action AddIn”.

SharePoint Designer ab sofort kostenlos

Der SharePoint Designer 2007 wird seit dem ersten April (nein kein Aprilscherz) kostenlos angeboten!

Kunden, die den SharePoint Designer gekauft haben, dürfen nun kostenlos auf Expression Web upgraden.

Auch wenn ich übrigens durchaus der Meinung bin, dass der SharePoint Designer einen der oberen Plätze bei Dreckstool.de verdient hätte, ist er manchmal ja leider doch ganz nützlich. ;-)

The file is not checked out. You must first check out this document before making any changes.

If you ever got this message and don’t know where it came from, here is the solution.

I got it if I click on “Edit Page” on a publishing page. So after some investigation it seems to be a problem with the web parts on the page.

My page layout contains some EditModePanels, so the user have different views in display and edit mode of the page. Therefore we also have one web part in a web part zone which is in one of the EditModePanels for display only.

<PublishingWebControls:EditModePanel PageDisplayMode="Display">
  <WebPartZone ID="zone1" ...>
      the web part added through the onet.xml site definition

The same web part zone “zone1” does not exists for editing, because I do not want the user to edit the web part. There is another web part zone “zone2” which lives outside of any EditModePanel.

Now comes SharePoint.

If you check out the page and then click on “Edit Page”, everything is working. Except of, that the web part from zone 1 has moved to zone 2! Automatically! Thank you SharePoint…

It seems that SharePoint think it has to show the web part in edit mode. And because the original web part zone is not visible, SharePoint moves the web part to the next available zone which is visible also in edit mode.

So remember:

Never put a web part zone in an EditModePanel which is only visible in display mode.

Maybe the solution is to make the web part not editable, but I didn’t tested this. My fast workaround hack is to create a div instead of the EditModePanel and makes it “runat=server” and give it an ID. Then I wrote this code on top of the page:

<script runat="server">
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    this.navleftdiv.Visible = (this.SPWebPartManager1.DisplayMode == WebPartManager.BrowseDisplayMode);
}
</script>

Now it works like a charm.

Publish a page with onet.xml as “published”

If you ever tried to publish one or more pages with your site definition (by onet.xml), you see in Visual Studio (with the SharePoint XSD schemas selected) only one valid value for the “Level” attribute which is “Draft”:

image

But for this attribute you can choose between every value of the SPFileLevel enum. So for publishing the page automatically, set the Level to “Published”. Thats it.

If you already know how to enable XSD schema validation and IntelliSense support stop reading here.

Enable Schema Validation:

  1. Open your xml file, e.g. onet.xml (works with all SharePoint related xml files)
  2. In the property pane, click the ellipsis next to the “Schemas” property
  3. Add the wss.xsd. This file is located in the 12\Template\XML directory
  4. Now add the following xml Namespace attribute to the root element (here Project in onet.xml):
  5. <Project xmlns="http://schemas.microsoft.com/sharepoint/" Title="" [...]
    

Now you should have IntelliSense and schema validation enabled.

SharePoint Page Version History without Web Parts

Today I found a version history “bug” in SharePoint publishing pages:

The version history system of SharePoint covers only Page Fields, but not Web Parts.

In detail:

  • Create a new page (e.g. “Blank Web Part Page”) within a publishing web.
  • Now add text and a Web Part. Save changes and check-in.
  • Check out and change the text and some properties of the Web Part.
  • After that, check-in again, and open the “Version History”

If you now try to recover the first version, it seems to work, but only the page fields are recovered. The Web Part is always the latest version, because the Web Parts are saved in a totally different location, so they are not covered by the version history system.

Lets have a look on a cool solution:
Garry Lapointe created a web feature which replaces the version history system and saves a whole page with all Web Parts on every check-in through an Event Receiver on the Pages list.
The version is Alpha 0.0.1 but it is working very well, so download it from codeplex.

Telerik RadEditor for SharePoint: Problem with custom tools

The RadEditor for MOSS 2007 version 4.5.3.0 has a Bug, which is very annoying...

You create a new custom tool in the ToolsFile.xml and set the “showtext” property.

<tool name="CustomToolName" showtext="true" /> 

Then you create a corresponding javascript method in the RadEditorCommandList.

RadEditorCommandList["CustomToolName"] = function(commandName, editr, oTool)
{
  (...)
}

If you now click on this new Tool Button, the RadEditor shows the message “Could not find the command xxx. Please update your command list.”

radeditor_error

The solution for that: Remove the “showtext” property from your tool in the ToolsFile.xml and everything is working as expected.

Error creating a new SharePoint Site through the Object Model

I have an issue creating a new Web Site programatically. Sometimes, the following exception occurs:

Content type '0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE811' not found in web 'xxx'

Live Search has no solution (by the way: Google has no solution as well ;-)). The only thing you can do is re-run the SharePoint Products and Configuration Wizard. After that, the error disappears and the site creation process is successful.

The weird thing is, that the content type ID is the ID from the “PageLayout” Content Type... If anyone found another solution I would be very interested.

Microsoft Windows SharePoint Services 3.0 – Application Development

Nachdem ich ja seit einiger Zeit MCPD EA bin, habe ich letzte Woche eine weitere Prüfung, die 70-541 abgelegt und bin nun also: MC Technology Specialist: Microsoft Windows SharePoint Services 3.0: Application Development

MCTS SharePoint Application Development

Mein Transcript wie gehabt hier zu finden: http://www.microsoft.com/learning/mcp/transcripts

ID: 761136
Kennwort: marcowiedemeyer