My Bing Maps and SharePoint Mash up – Part 3: C# Development

 

Now comes the exciting part, we actually get to write some code and make some things happen. Prior to this has been a lot of plumbing to give us a strong foundation on which to build upon, but now we are ready to finally put all the pieces together and get it up on SharePoint along with our Lists we created way back in Part 1.

Open up MainPage.xaml.cs this is the code behind to the canvas we developed in Part 2.

To save time later the first thing we will do is include the references we need, so at the top with the other similar statements add the following using statements:

This is one for the SharePoint Client Object Model, one for the Bing Map SDK and finally the Windows Imaging one to assist in displaying the logo’s we saw back in part one.

We also need a global object of ListItemCollection as we are going to use this in a few methods. So add this line before the MainPage() function starts.

The next method we need can be automatically generated if you switch back to our xaml file and double click on the map. You will end up with an empty function like so:

The first objective of this function will be to get into SharePoint, open the current Web and select the FastFood list we created back in Part 1. This can easily be achieved with the following code:

If you want to have the Map on multiple Webs instead of getting the Current web your going to have to get one by URL instead.

The next objective, now that we have the list, is to actually get the items we want. For this we need to write a small bit of CAML and populate a CamlQuery object.

This piece of CAML simply gets all items where the column Show is equal to Yes. This is done so we can toggle certain list items on or off without having to edit any of our application. Finally we finish off with the following code to execute our query asynchronously in another Thread.

This method is going to attempt to get our items from SharePoint. If it succeeds it will call requestSucceeded if it fails requestFailed. Therefore we need to generate these methods.

In my application I have left requestFailed blank, but you may want to add more code to help troubleshoot any problems you may be experiencing. In requestsucceeded we need to call the Dispatcher to invoke a function to populate our PinLayer with PushPIns. So add the following line of code to requestSucceeded:

As well as defining a method for AddFastFoodPins:

The objective of this method is to add the actual pins to the PinLayer for each list item our query retrieved.

First thing we are going to need is a foreach loop to cycle through our collection of ListItem’s in our ListItemCollection fastfooditems:

We then need to create a new Pushpin:

I then set the following options on the pin:

I chose to Tag the pin with the ID column from our FastFood list so that each Pin had a unique identifier. This will help us grab more data for particular pins later on. There are several events that can happen to a pin i.e. MouseEnter, MouseDown, MouseUp etc. Intellisense will give you a good idea of what’s available. In this example we will be using the MouseEnter event, if you allow intellisense it will even create the appropriate method for you.

The last line of code, we need to get this Pin on the Map, is just adding it to our PinLayer:

So all together your function should look something like this:

Note: in addition I added a try/catch and used the Description textblock we added to our XAML in Part 2 to assist with any troubleshooting that might be required.

So last but not least is the pin_mouseEnter event receiver. The objective of this method is to retrieve the Pushpin we have invoked the event with and get its pin.Tag, remembering this is where we stored the unique value from our fastfooditems list collection. Then find the ListItem in that collection with the same ID. Finally we can use this ListItem to populate the rest of the panel next to our map. There is some extra code there to create an image so we can display it on our Image Component as well as convert the Website column into a URL to use on the HyperLinkButton:

Now we must upload the project to SharePoint. To do that go to Build and BuildFastFoodMaps fixing any errors that it highlights. Once the build process has completed successfully head over to the project directory in windows explorer and locate the .xap file. This is the Silverlight file we need.

2011-05-27-BingMapsSPMashUp-Part03-01.png

Upload this file to any document library on your SharePoint Site and navigate to the page you where want to insert it.

Simply edit the page as normal, and go to Insert on the ribbon and then Web Part and insert the Silverlight Web Part which is found under Media and Content.

2011-05-27-BingMapsSPMashUp-Part03-02.png

As soon as you click add you’ll be prompted to the location of your Silverlight .xap file, so point it to the location you’ve uploaded it to.

2011-05-27-BingMapsSPMashUp-Part03-03.png

The last thing to do is edit the Web Part and set the width and height to match the size of the canvas we defined in our xaml in Part 2. Once you’re done you should end up with something like this:

2011-05-27-BingMapsSPMashUp-Part03-04.png

Mouse over the variety of pins to see the content change in the right pane like this:

2011-05-27-BingMapsSPMashUp-Part03-05.png

Hope you have enjoyed this three part tutorial on how to get a Bing Maps and SharePoint mash up operational. Just in case you’re still having trouble I have uploaded .stp files for both the Logos and FastFood list as well as the xap and source code.

If this was for production you could obviously package it up to be deployed as a SharePoint feature and create the lists automatically in list definitions.

Mark Smith on CRM integration with SharePoint 2010

 

2011-05-25-OneThingYouNeedToKnow-Part13-01.png

One of the more interesting presentations at the New Zealand SharePoint Conference 2011 this spring was a presentation by CRM consultant Mark Smith (@magnetismnz) on the combination of the Dynamics CRM platform with SharePoint 2010. His comments around planning and best practices have been added to the community video series ‘The One Thing You Need to Know About SharePoint 2010.’

With SharePoint 2010 comes deeper integration with the Dynamics CRM 2011 platform. As Mark points out, this combination of two very powerful platforms allows you to build powerful line of business (LOB) applications for your business, allowing you to handle both the “unstructured” nature of business data, and the sometimes highly structured nature of customer interactions, which can be very transactional.

Dynamics CRM 2011 caters to the very relational data that you may have in your system – combined with SharePoint data, Mark states that CRM and SharePoint together gives you “the best of both worlds” by helping you to manage your customer interactions – and the underlying data surrounding these interactions – much more efficiently, streamlining business processes and improving the overall user experience through the flexibility and extensibility of the SharePoint interface.

Dynamics CRM is a popular tool within many organizations because it leverages technologies that are already in place, including Exchange, the ubiquitous Outlook, and (increasingly) mobile access. Following the New Zealand SharePoint Conference, Moya Radley captured this quick table outlining the strengths of each platform:


SharePoint

Structured and semi-structured data

Social engagement and collaboration

Information evolution and storage

CRM / xRM

Structured relational data

Interactions, activities and tasks

Information generation and analytics

SharePoint

Information rules

Enterprise search

Works across teams and domains

CRM / xRM

Business rules and formalized processes

Data query and filtering

Within teams

Some additional resources that may be of interest to you on keeping things simple in SharePoint 2010 include:

Quality of Content at SharePoint Events

​Shadeed Eleazer at SharePoint Careers has posed an interesting question: Should there be a different standard for quality of content at free SharePoint events vs the paid events such as SPTech, Best Practices, or even the major SharePoint Conference sponsored by Microsoft? What are your expectations when attending these events.

I left a comment on Shadeeds article, Should SharePoint Speakers’ Content Increase in Value from Free Community Events to Larger Conferences, and I’d like you to join that discussion. It’s an important topic because it’s getting more and more difficult for people to choose to put down money for a paid conference if there is no differenciation between that and a free event. For those of us who are speakers, are we expected to provide added value at paid events, or do we present the same material at SharePoint Saturdays and user groups.

Shadeed has provided a real service to the community by bringing this into the light. I hope you’ll participate in his discussion to let us know YOUR expectations when attending both types of events.

SharePoint Resource Booking System

 

Some of the day to day activities within an educational institution include the booking of open ICT classrooms, loaning IT Hardware such as camcorders and digital cameras and booking meeting spaces. At Twynham School even though we use SharePoint heavily I can honestly say until this year we have used three different non-SharePoint solutions to deal with all these three tasks. An ICT technician manually booked computer rooms for staff and displayed them on the Learning Gateway, hardware was checked in and out on a whiteboard by the Systems Team and the Headteacher’s PA was in charge of recording the use of meeting rooms. In total over 200 hours of labour per year were spent on a process which was still cumbersome for the end user.

During the 2009-10 academic year we were convinced there must be a SharePoint solution tailored for booking resources within an educational environment. Unfortunately the research showed there was nothing that met the unique needs of education and so we approached an external development team to see if they would make one! Having successfully used the SharePoint Resource Booking System for 9 months now I thought would complete a write up on what has been a revolutionary resource for our school.

The SharePoint Resource Booking System for ICT rooms

When we began to create a specification for the system the primary focus was the ease of use and instant booking capability for end users. The SharePoint Resource Booking site when shown in an ICT room booking mode can be seen below. An administrator is able to input those activities which take place throughout the year and count as permanent bookings. Those open bookings which are left can quickly be found and booked by staff.

2011-05-24-SPResBookingSys-01.png

The end user is faced with a simple interface where they can select dates from the calendar and then look at the range of computer rooms to see which are free. In the image above the computer rooms which are free display a simple phrase (in this case ‘Book Me’). By clicking on the room and period the user is simply prompted to type their initials and the class they are planning to use the resource with.

When the end user clicks ‘book me’ booking of the room or resource takes places within the page as shown below:

2011-05-24-SPResBookingSys-02.png

The end user can then instantly see their booking as shown below:

2011-05-24-SPResBookingSys-03.png

We took a long time to think about instant booking using the logged on user. This however would lead to other users being unable to book rooms for colleagues. So for example a Head of Department or administrator would not be able to easily book a set of rooms for a cross curricular theme day or whole department activities.

The SharePoint Resource Booking System has been well received, being an instant hit for staff who get an immediate booking and ICT technicians who do not need to maintain a manual system. Whereas staff would normally receive an email confirmation within 4 hours from the ICT technician they can now book a room in just a few seconds. Its impact in other schools which have used room booking sheets on doors or in the staff work room (which is the majority of schools) is even greater.

When we worked with a development team to produce this resource we initially saw it as just a SharePoint Room Booking System. Since this time we have found it really useful as a way of booking hardware resources. The system is now used in a number of schools and universities and the variety of uses mean the team have now called it a SharePoint Resource Booking System. Many schools are using if for booking meeting rooms and some have even used it to manage their mini bus fleet.

If you want further details about the SharePoint Resource Booking System please get in touch with the developers at admin@sharepointforschools.co.uk

You can also try out a demo of the SharePoint Resource Booking System at www.sharepointforschools.co.uk in their Live Labs.

Active Directory Groups vs. SharePoint Groups for User Management: The Denouement

 

2011-05-23-ActiveDirectoryGroups-Denouement-01.pngLast week I did a post here at EUSP about when you might decide to use Active Directory groups versus SharePoint groups. It was less about managing the security, but more about understanding the membership of the groups.

As when I originally published the post on my own blog, I got a lot of comments, emails, tweets, grumbles, and groans about the post. This seems to be a really common question, and while there are some possible answers, they aren’t all straightforward or cheap. Here are a few of the suggestions that I received:

These two suggestions let you do quick checks on group membership and AD, but don’t solve the interactive info for users need:

  • Use net group "group name" /domain for quick checks on group membership
  • Use a script to run reports on group membership

And the warnings:

  • Watch out for performance
  • Nested Active Directory groups means that you could get into infinite loops in expanding them (This seems like it would be the developer’s fault for not handling the possibility to me, though.)
  • Issues with the information in SharePoint groups and Active Directory groups being out of synch
  • and on and on…

So what did we decide to do in my client’s case? We chucked the idea of using Active Directory groups in favor of the ease of use of SharePoint groups. No, we didn’t like this answer, either. I would posit that there needs to be a SIMPLE way to expand an Active Directory group within SharePoint that doesn’t involve custom coding. While there are many third party tools out there that sort of tackle this, they are mostly overkill and in most cases, it’s not even clear if they would do the simple thing we were looking for.

My client may at some later point decide to buy one or more of the third party tools for other reasons, which may give them a solution for this as well. It just didn’t make sense at this juncture.

So the score of the game for this one was SharePoint: 1, client requirements: 0. I feel that it was an unfortunate outcome, but one that we couldn’t improve upon.

p.s. At least I got to use the word denouement in a post about SharePoint. There’s always that.

Charting for SharePoint using Google Visualization API: Update 05.05.2011

 

I have posted a new version of the “Charting for SharePoint using Google Visualization API” – v2.8.5. The changes are described here, but the background story and the code is found in original article. This post describes the new features and changes from v2.8.

You should read the original post found here, and the update for v2.8 posted here.

Changes from v2.8:

  1. Removed option to “listen to” specific list filter columns using “{list:FieldInternalName}”
  2. Added option to “consume” a list view web part filter (read from the URL). You can now have the chart “connected” to a list view. Further details below. This new feature requires existing users to manually add one column to the configuration list: “ConsumeFilterFromListView”.
  3. Fixed a bug regarding the use of “&” in a custom filter field which broke the CAML
  4. Added a “counter” to display the total number of items below the chart
  5. Added a few “options” to be set in the CEWP code: “showFilterInfo”, “showItemCount”, “itemCountPrefix”, “itemCountSuffix”, “labelIfEmpty”. All these have a default value and are optional.
  6. Added option to pull the CAML from an existing list view to use as “Custom CAML”

Details on item number 2:

In v2.8 i introduced an option to “hook into” the list view veb part filter for specific columns. In this release this is removed and replaced with an option to “connect to” a list view web part and consume all filters applied to any column.

This has a few limitations:

It reads the filter values from the URL and therefore only one list view webpart can coexist with the chart. If more than one list view web part is placed alongside a chart, it would not know which list the filter came from.

To use this option, check this box:

2011-05-19-ChartingForSharePoint-01.png

This requires existing users to add one column to the configuration list: “ConsumeFilterFromListView”. For new users this field will be added automatically when creating the configuration list. The chart configuration list should look like this:

2011-05-19-ChartingForSharePoint-02.png

Details on item number 4:

I have added a “counter” to display the total number of items below the chart:

2011-05-19-ChartingForSharePoint-03.png

This counter can be switched off – see next item.

Details on item number 5:

These variables can be added to the CEWP code:

  • showFilterInfo: true [default] or false. Controls the visibility of the “filter label” below the chart when using a filter.
  • showItemCount: true [default] or false. Controls the visibility of the item count below the chart.
  • itemCountPrefix: A string to put in front of the item count. Default empty string.
  • itemCountSuffix: A string to add after the item count. Default ” items”.
  • labelIfEmpty: A string representing the default label for empty values. Default is “(empty)”.

Example CEWP code:

<div id="MyChart1"></div>
<div id="MyChart2"></div>
<script type="text/javascript">
/*****************************************************
		Address all containers
*****************************************************/
// All charts must be represented by a container with a unique id. This container  must be present in the page
arrOfChartContainers = ["MyChart1","MyChart2"];

var showFilterInfo = true;
var showItemCount = true;
var itemCountPrefix = "A total of ";
var itemCountSuffix = " items";
var labelIfEmpty = "(no value)";

</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="/test/English/Charts/Javascript/v2.8.5/ChartUsingGoogleVisualizationAPI.js"></script>

Details on item number 6:

Use this link to pull the CAML from the list view:

2011-05-19-ChartingForSharePoint-04.png

Select a view in the “View selector” and click this link to pull it into the textarea.

Please post a comment if you have questions.

Alexander

Creating a NuGet Package to Automate the SharePoint Solution Creation Process

​In this blog post I will talk about how to automate the SharePoint solution creation process by making use of NuGet. As an example I will use NuGet to automate the SharePoint Branding process in Visual Studio.

NuGet is a package management system for your development environment. NuGet makes the process of importing .NET libraries into your current project a lot easier. You can find more information about NuGet on: http://www.nuget.org

The idea to automate some processes came from the fact that, for me, every branding project starts with the same manual operations to prepare my Visual Studio project. These steps include:

  • Adding a SharePoint Module for the masterpage and theme;
  • Adding mapped folders to the "Images" folder and "Styles" folder.

Requirements

Before you can start, you will need to download the following files:

  1. NuGet Visual Studio add-in: http://www.nuget.org
    • Install this to your Visual Studio environment.
    • Make sure to add the NuGet.exe to your path.

Creating a NuGet package 

Creating a NuGet manifest file
 

The first thing you need to do is create a “nuspec” or NuGet manifest file. This can be done by opening a command console, and running the following command:

 



This command creates the "nuspec" file in the current path.

051711_1620_CreatingaNu1.png
 
When you open the file you have something like this:


This is my cleaned up version:


Adding  SharePoint Content

 

When the NuGet manifest file is created, your next step will be to build the NuGet package by adding the SharePoint Content. An easy way to do this is by creating a new Visual Studio Project and adding the necessary SharePoint Modules, Mapped Folders, etc.

My branding project looks like this:

051711_1620_CreatingaNu2.png

Go to the location where you created your NuGet manifest file and create a folder with the name “content”. This folder will be used to add the SharePoint content (Modules, mapped folders), so that it can automatically be added when installing the package to your project.
 
In my example I have copied the “_catalogs” module, the mapped “Images” folder, and the mapped “STYLES” folder to my NuGet “content” folder. Be sure that you also copied the “*.spdata” files. If you did not copy them, Visual Studio will recognize the content as common folders.
 
051711_1620_CreatingaNu3-300x105.png
 

Building the NuGet Package

When everything is added to the content folder, you are ready to build your package. Go back to the command console, and run the following command:




When the command is complete, you end up with a new file named: EStruyfSP2010Branding.1.0.nupkg.

To check the package you can rename the “nupkg” extension to “zip” and open it.

Testing the NuGet Package

Adding a Package Source

 

NuGet allows you to add new Package Sources in Visual Studio. These sources can be linked to a local folder on your server/PC, so you do not need to publish them to the NuGet site.

To add a new Package Source, open Visual Studio with NuGet installed. Click "Tools" -> "Options" -> "Package Manager" -> "Package Sources".

051711_1620_CreatingaNu5-300x175.png
 

In this window you can add your local folder as a Package Source for NuGet.

051711_1620_CreatingaNu6.png

Testing the package

 

Start a new empty SharePoint project, and right click on "References" -> "Add Library Package Reference".

051711_1620_CreatingaNu7-300x105.png
This step opens the NuGet Package manager window.
051711_1620_CreatingaNu8-300x168.png
Under the official NuGet package source you can see your custom package source. Open your package source and install the package.
051711_1620_CreatingaNu9-300x59.png
This should have added your files to the project.
051711_1620_CreatingaNu10.png

Result

Here you can view a small demo: http://screenr.com/OJV

Download the files

EStruyfSP2010Branding.1.0.zipEStruyfSP2010Branding.1.0.zip

 

 

 

Active Directory Groups vs. SharePoint Groups for User Management: A Dilemma

 

I’m working with a small municipality and, like I always do, I recommended that they manage user groups in Active Directory as much as possible. Then they can add those AD groups as “users” to their SharePoint groups and inherit all the AD goodness.

In doing some research on this, I found a nice post by Alexander Brütt that does a good job in painting the differences between the two approaches in a nice little table, which I’m lifting and showing below. Note the bullet that I’ve highlighted; I’ll talk about it more below.

2011-05-19-ActiveDirectoryGroups-Dilemma-01.png

Source: SharePoint Groups vs. Active Directory Groups by Alexander Brütt

But wait a second. It’s not that simple. In thinking about this, I’ve been blessed in the past by IT inability to manage AD effectively. What I mean is that I’ve always recommended that groups from AD be used for things like department membership. However, in EVERY SINGLE CASE that I can remember, the answers were things like “But all of the data in AD is wrong” or “IT won’t let us do that”. So I suggest that they fix the data: “Too hard – we’d rather maintain our own data.” (What??? It’s easier to create your own data than fix what’s basically already there?) Talk to IT about making this work: “Forget it, that’ll never happen.” (What??? That’s your IT department’s service message?)

Listen up, IT folks: making your AD a walled fortress doesn’t serve you at all well. You don’t want people saying things like “those idiots in IT can’t manage data” (someone really said this to me once). Active Directory is supposed to be the one place that manages user identity and demographic data. At least that’s its intent. In most cases, there are 3 or 4 or even a dozen other systems stitched together to manage some aspects of user information instead because AD or its guardians are seen as too hard to work with. As much trouble as the User Profile Service seems to be to work with in SharePoint 2010 (see Spence Harbar’s articles before you even think about setting up UPS), AD is still the best source for user information.

So, the reason for the bit of a rant above is that now that I’m in an environment which is small enough and smart enough that AD is in great shape, we’re trying to use AD groups and there’s one hitch. SharePoint doesn’t give us a way to display the members of an AD group in any straightforward way. (I know, with code all things are possible, but we’re trying to go as out of the box here as possible.) A simple example is that we’d like to display the site members on each departmental site. Basically, it’ll be a department directory of sorts. You can easily do this with a SharePoint group using the Site Users Web Part. However, since SharePoint sees the AD group as a “user”, you just get one “user” listed when you’ve added the Site Users Web Part and asked it to “Show people in this site’s member group”.

I turned to Twitter and #SPHelp on this one and the responses I’ve gotten are more of the “tell me how you do this when you figure it out because we need it, too” variety. I’ve had some suggestions that seem too convoluted to me. This seems like it *should* be such a common thing, but apparently it’s not. Maybe my prior experiences with AD are indeed the norm and no one ever really ends up using AD groups so this rarely.comes up.

So, no answers here to my actual dilemma. I’m wondering if this might be a nice little piece of functionality to wrap up as a jQuery plugin, but I’m not sure how to do it. I’d prefer to avoid deploying code to the server in this instance, but I’m open to it if anyone has anything useful.

I came up with an answer for my particular client, and you’ll be able to read about that in an upcoming post. In the meantime, I’d be interested in how *you* handle this dilemma.