Thursday, May 17, 2007

Flight Data Button 0.5 for Outlook

I've spent a little time working on an Outlook add-in for putting flights in my calendar. A few weeks back, I took a trip and wanted to be able to pull up flight status on my phone, without keying in an address and surfing, or installing an app like Skip. (Skip is great, but was never fully implemented for Smartphone.)

 So I put my flight into Outlook as a calendar item, and put a link in it to FlightStats Mobile, for my specific flight. FlightStats is the premier flight data provider in the U.S. -- many airport flight boards actually get their data feeds from FlightStats. Now, when my phone syncs with Exchange, the flight item comes onto my phone along with a quick-click link for status.

I decided this is a useful thing to automate, since any system that syncs Exchange to a device (DirectPush, Blackberry Enterprise Server, Moto/Good) would carry the link. But I was frustrated that I needed to key in the flight times, and I realized that should be automated too. To top it off, I foolishly ended up booking an appointment during time I needed to be driving (but which showed "free" in my calendar) -- so I figured my "automation" widget ought to add the travel time to and from the airport, and the time waiting at the airport before departure.

Using OpenKapow, I built a web service that scrapes flight schedule data. Assembling a FlightStats link is almost straightforward (getting to the individual segment within a flight number turned out to be tricky). And integrating to Office is delightfully simple thanks to great templates that take all the work out of it so a lazy sod like me can just write business logic.

I've called the addin "Flightify" since, to use it, you select an appointment in your Outlook calendar (where you've previously stuck some basic flight info), click the button, and the plug-in "flightifies" the appointment.

Here's an example: you start with basic info like this:

Click the button, and select the additional calendar items you'd like:

And a few seconds later your calendar shows the sad reality of your travel day:

You can't see them, but the mobile links to realtime flight status are embedded in the body of the flight item, so it's ready-to-click on your phone.

Here's the project page with the download/install if you want to try it. Full source code is there too.

I wanted to make this more of a learning experience and use the Outlook Addin templates that ship as part of Visual Studio Orcas Beta 1. I could try out more of Orcas and easily produce both an Office 2003 and Office 2007 version of my button.

Unfortunately, the Orcas Beta includes project templates, but not all of the Interop Assemblies you need to build the project (Office COM libs are required as well). So to get it building I would have needed to install Office on the Orcas test machine (in my case a VM with limited resources, meant for testing VS CTPs). My recommendation to Visual Studio team? Ship stub DLLs that implement the relevant COM classes (perhaps they just log calls to a file) and all of the Interop Assemblies. That way, the machine where Orcas is running doesn't need to have Office installed and can still successfully build these Office project types.

A few final thoughts on the plug-in:

  • Since the web service calls run in the main thread, Outlook will freeze for a second or two while they're being made. Considering that Outlook freezes the UI thread all the time while doing its own built-in tasks, I didn't put a lot of time into a proper workaround.

  • I don't write a lot of Windows Forms apps, so I was pleasantly surprised that the snap-band positioning logic in the form designer allowed my dialog box to appear the same on both a standard and high-DPI display without my having to do anything special.

  • The automagical "Setup Project" builder was also great. I didn't really have to do anything, and it produced a nice exe/msi install, that includes registering my addin with COM via RegAsm.