The Engine Room
The engine room is a place for people to contribute ideas on the development of Sharepoint, Visual Studio and information technology.

VSTS Team Chat

Last July (yes, this post has been in my “TODO” list for a long time), the VSTS Product team held a couple of chat sessions with NZ friendly times. Here are some of the most interesting bits:

·         Project server integration is going to be part of Rosario, which is more than welcome considering the lengthy list of steps required to integrate it with TFS right now

·         I was a bit disappointed that improvements to Team Build in terms of GUI support. But is good to hear that Rosario and even TFS 2008 will have some new features

·         Brendon will be pleased to hear that TFS 2008 supports WSS 3.0. This was known but it is nice to get a confirmation from the guys in Redmond.

·         There were quite a lot of questions in relation to time-outs, working off-line, etc. In TFS 2008 now you can work offline, and the connectivity has been improved.

·         A new set of power tools will be released around the same time TFS 2008 becomes available.

IronRuby: An Introduction

Ruby

 

Ruby was originally created in 1993.  Since then, it has maintained a small but active community of followers – growing rapidly after the introduction of the ‘Rails’ (or, Ruby on Rails) framework for rapid web development.

 

Microsoft have recently registered their interest in the language, by creating a version of Ruby for .NET - named IronRuby.  As this project is built on top of the Dynamic Language Runtime (DLR) – currently, a work in progress – it is still in a very early stage of development.  Nevertheless, Microsoft has released the source to the current implementation; currently described as a “pre-alpha” release. 

 

Eventually, it is hoped that the complete .NET framework will be available - as well a large number of ruby-specific libraries; however, the majority of these frameworks are currently unimplemented.

 

Despite these obvious caveats, it is likely that Ruby’s significant mindshare may attract a great deal of attention once it is released.

In the following weeks, I intend to explore the current IronRuby implementation, and document my initial thoughts on its use in a .NET centric environment.

 

Getting started

 

At the moment, the best way to get IronRuby up and running, is to download the source code: here.  Once you have downloaded and unzipped the project, open up the solution in VS.  You may need to open VS first, and then select "file-open" to open the solution.

 

Once the solution is opened, set the build target to 'release', right click on the solution, and 'rebuild all'.

 

Once the solution has built, take a peak in the bin/release directory; you will see a couple of executables:

 

# rbx

This is an interactive ruby shell, similiar to 'irb' on other platforms.

 

# RubyTestHost

This runs a series of unit tests against IronRuby, to show the current level of implementation.

 

Double click rbx.exe to open the interactive IronRuby shell.  The interactive shell is similar to the ‘immediate window’ in the VS debugger; it allows you to create and manipulate objects.

 

Simple Objects

 

You can easily create simple objects, by instantiating them dynamically:

 

For ie:

 

X = “Hello World!”

 

Simple arithmetic works as expected:

 

            2 + 3

 

            Or,

 

            4 + x.length

 

Likewise, arrays are specified as:

 

            A = [‘carrot’, ‘banana’, ‘apple’]

 

 

To print a string, use the ‘puts’ command:

           

            Puts x

 

Simple Collections

 

Ruby treats everything as objects; therefore, to repeat a given function we can use the ‘times’ method of a standard integer:

 

            X = “awesome”

            5.times do puts x end

 

Likewise, we can use the ‘each’ method to enumerate collections – similar to the foreach keyword in C#

 

            A.each do | e| puts e end

 

 

Simple .NET objects

 

A subset of the .NET framework is currently implemented; we can create and inspect a range of objects as follows:

 

.NET Example 1: Create a Simple messagebox

 

            # import the required libraries

 

require 'mscorlib'

require 'System.Drawing'

require 'System.Windows.Forms'

 

# Create a simple message box

MessageBox = System::Windows::Forms::MessageBox

MessageBox.show('awesome')

 

 

.NET Example 2: Create a Simple form

 

            # import the required libraries

require 'mscorlib'

require 'System.Drawing'

require 'System.Windows.Forms'

 

#create the form

form = System::Windows::Forms::Form

window = form.new

 

#set form properties, and show

window.show

window.text = 'awesome'

window.hide

 

 

Summary

 

Hopefully, you have seen how easy it is to get IronRuby up and running, tested a few simple language functions, and seen how simple it is to create simple .NET objects using the interactive IronRuby shell.

InfoPath 2007 Development Series

Microsoft InfoPath is a powerful tool for building rich interactive forms. The latest version (InfoPath 2007) adds the ability to host forms in a Windows application or in a browser using Microsoft Forms Server. Over the next few weeks I will be creating a series of posts to give a brief overview of InfoPath 2007 development options, provide links to relevant resources, and demonstrate some of the capabilities InfoPath provides as a development tool.


The topics that will be covered in this series are:

  • InfoPath Data Connection Options
  • InfoPath Hosting Options
  • Web Service Data Connections
  • Automatically updating InfoPath Web Service URLs
  • Advanced InfoPath Expressions


Resources available

If you are new to InfoPath, the following resources are good places to start.

  • InfoPath Developer Portal - Contains a huge range of information on customising InfoPath forms, and links to a wide range of resources that are available.
  • InfoPath 2003 SDK - Contains sample forms, tools, macros, code libraries, and documentation to assist with InfoPath form development. Many of these concepts also apply to InfoPath 2007.
  • InfoPath 2007 SDK - Contains information about new options for hosting InfoPath 2007 including Windows application, and Forms server
  • InfoPath Team Blog - Contains many useful articles on InfoPath development and links to the latest resources
  • Developing Solutions with Microsoft InfoPath - Great developer reference for creating InfoPath solutions. Sample chapters are available online.

Tech Ed 2007 - Things that you learn - part 2

The second day of Tech Ed 2007. And there are still things to learn. My first session was a deep dive into LINQ. I have heard a lot about LINQ but not really got my head around how it works or what it should be used for, but now I do.
So, an explanation from my point of view. LINQ is system that Microsoft has created that builds on functionality from all versions of the .Net Framework. LINQ standards for Language Integration Query and is NOT an object-relationship management technique. The presentation by Alex James showed how LINQ type functions can be built using standard .Net concepts. In short LINQ is built on

  • Delegates,
  • Iterators,
  • IEnumerable - yield keyword,
  • Predicates,
  • Extension methods - C# 3.0,
  • Lambda expressions,
  • Mapping functions,
  • Select functions,
  • Implicit typing - var keyword,
  • and Anonymous types

One of the core notions that these concepts provide is the use of functional rather than procedural programming. I have not seen functional programming since I was at University and it was interesting to see the possibilities of it being used within applications today.
LINQ is a not a small concept and as with all new concepts it will take a little time for the masses to pick up on it and use it in anger within applications.
I will post some more information on LINQ as I find it, especially LINQ for SQL and LINQ for XML.

Tech Ed 2007 - Things that you learn!

During the first day at Tech Ed 2007 I have attended a series of sessions that have been both informative and amusing. The keynote speech was delivered by American Lou Carbone, the author of 'Clued In'. His very interesting talk was about the Customer Experience. This seems to have set the theme for the rest of the conference, with other sessions focusing on the customer / user experience. It seems that people are taking an interest in what Provoke has been doing from the start. But this is not what this post is about. The penultimate session that I attended was 'IIS7 for Developers'. I was unsure about going, thinking that it might be too geeky for me, and the ‘UX – Interface Design Patterns’ nearly won out; however, I decided to brave the session and sit near the back. I have to say that I am glad that I went, and that it was probably the best session of the day.

 

Eric Woersching was a great presenter and provided an excellent session on the topic. As well as being introduced to PHP on Microsoft Windows Server, the best part of the talk was his implementation of an HTTP Module as a ‘footer’ to the bottom of all web pages within a site. This only took about 150 lines of C# code and worked brilliantly. Fortunately, Eric had provided all the source code and a description on his blog at www.iis.net.  Within 20 minutes, I had implemented the same code within a project on the laptop. It is these little gems of information and insight that make Tech Ed what it is. So this is thanks to Eric and IIS team at Microsoft.

Integrating VSTS with a real world application, Part IV

This is the easy party (after manipulating all those XML definitions, anything will be easy!). I used Howard van Rooijen's web services notifications templates as a base because, well, they just work :)
Once I had everything set up, and I had subcribed to the WorkItemChanged event, all I had to to is call my Time Tracking Application's web service to create the task under the module the user had selected in TFS.
In the "Notify" web method I used the following to create an instance of the WorkItemChanged event:
 
WorkItemChangedEvent workItemChangedEvent = this.CreateInstance<WorkItemChangedEvent>(eventXml);
 
"eventXml" is one of the parameters of the method and contains information about what event has been raised. Then I just used the properties of the workItemChangedEvent object to pass the information to my web service a create my task in my TRA application.

Integrating VSTS with a real world application, Part III

In this part I will describe how I modified the project template to include a field that listed and the modules from my time tracking application (TRA). To do this, I create a new global list with all the modules from the project, I create a new field for work items and I associate it with the list. Everytime a project in the TRA is associated with one in TFS, a new list is created using the unique ID from our data store as the list ID. There are some other routine tasks (like, checking if the list is not there, update the list items if they have changed in our data store, etc) which I won't describe in this post. First, get the global lists xml:
 
TeamFoundationServer tfs = GetTFSConn();
  TFSWIT.WorkItemStore wiDestStore =
(TFSWIT.WorkItemStore)tfs.GetService(typeof(TFSWIT.WorkItemStore));
XmlDocument xmlGlobalLists = wiStore.ExportGlobalLists();
 
Now we need a NameSpace Manager to navigate the nodes of this xml document:

XmlNamespaceManager
nsm =
new XmlNamespaceManager(xmlGlobalLists.NameTable);
nsm.AddNamespace("gl", "http://schemas.microsoft.com/VisualStudio/2005/
workitemtracking/globallists"
>);
 
No I can get the node with all the global lists:
 
XmlNode xnLists = xmlGlobalLists.SelectSingleNode("//gl:GLOBALLISTS", nsm);
 
From here it is just normal XML manipulation, check Microsoft page with information about the structure. Once I've added the new list and all the modules as list items I just re-import the xml using:
 
wiStore.ImportGlobalLists(xnLists.OuterXml);
 
Now that I have a Global List with the modules I need, I can create a field in my project and associate it with it. To perform this task I will export the xml from the Work Item, add the logical field, the UI field and then import everything back.
Remember that in my previous post I had a list of all the projects, once the user selects one, I can get the project ID.
 
 
TFSWIT.Project oProject = wiDestStore.Projects.GetById(iProjectID);
XmlDocument xmlType = oProject.WorkItemTypes["Task"].Export(false);
 
//Manipulate XML
 
oProject.WorkItemTypes.Import(xmlType.OuterXml);
 
While manipulating the XML I added a FIELD node with a ALLOWEDVALUES child. I then added a GLOBALLIST node with the name of the the global list I create before hand. For more info on the XML structure visit MSDN.

 

Integrating VSTS with a real world application, Part II

I know it has been almost a month since the original post, but here's the second one on the series about TFS integration.
In our TimeSheet tracking application (which I will call TRA), I've created a screen that allows users to associate a Team Project with one in the TRA. To start with, I reference the following namespaces:

using Microsoft.TeamFoundation.Client;
using TFSWIT = Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation.Server;

I also have a function I used to get an instance of TFS:
  private TeamFoundationServer GetTFSConn(string sServer, string sUsr, string sPwd)
  {
   TeamFoundationServer tfs = null;
   try
   {
    NetworkCredential credentials = new NetworkCredential(sUsr, sPwd);
    tfs = new TeamFoundationServer(sServer, credentials);
   }
   catch (Exception e)
   {
     //Handle
   }
   return tfs;
  }
When the page Loads I get a TFS object, get the list of all the Team Projects and add them to a list.

TeamFoundationServer tfs = GetTFSConnection();
  TFSWIT.WorkItemStore wiDestStore =
(TFSWIT.WorkItemStore)tfs.GetService(typeof(TFSWIT.WorkItemStore));
  foreach (TFSWIT.Project p in wiDestStore.Projects)
  {
   //Add them to the list
  }