Importing data from Excel to SQL Server using LightSwitch

I have been working to get some data imported from Excel to a SQL database. Preferably I’m looking for a solution so that end users can perform this themselves. One option that came up on the SQLDownUnder mailing list was to try using LightSwitch.

LightSwitch is a wrapper around .NET that makes it easy to create data centric apps with little or no code. In my case to LightSwitch drag and drop took me about 2 minutes once I knew what I was doing and I had to write one line of code.

My test table was just a simple product and category table with data from AdventureWorks

Table Diagram

Through the magic of drag and drop LightSwitch produced a functional screen that allowed me to add and edit records:

It automatically recognised my foreign key relationship and gave me a category dropdown which was nice.

Next I grabbed the excel import plugin for LightSwitch. I couldn’t get the extension to show in VS 2012 but it worked fine in VS 2010.

I enabled the extension, added a button and in the code behind put my one line of code:

ExcelImporter.Importer.ImportFromExcel(Products);

I had a spreadsheet with a new product including the name of its category:

The import plugin gave me a mapping screen that even mapped the category name and filled in the correct foreign key:

Overall I’m pretty impressed with what I could in such a short amount of time. The instructions I followed are on the LightSwitch blog.

There are even user friendly validations based on the SQL fields:

Simple interactivity with Raphael.js and Paper.js

Demo Screenshot

Demo Screenshot

As a prototype for some features we have planned at picnic software I wanted to prototype some very simple interactivity using either canvas or svg.

The prototype is simple resizable moveable circles on a page.
The Web-Drawing Throwdown from smashing magazine gave me a head start but didn’t really address the kind of interactivity I was looking for. Based on the discussion there I elected to use paper.js for canvas and raphael.js for svg (vml in older versions of IE).

You can see the demos here: Rapael.js and Paper.js

Both libraries gave me high level abstractions for working with the shapes and capturing mouse events. Paper.js seemed to be lacking really rich support for high level objects. You can create a circle like this:

new Path.Circle(new Point(x, y), radius);

But once created the circle is just a geometric path. You cannot alter the radius of the circle - you have to work with each of the four segments individually.

My code to change the size of the circle:
circle.segments[0].point.x = centre.x + radius;
circle.segments[1].point.y = centre.y - radius;
circle.segments[2].point.x = centre.x - radius;
circle.segments[3].point.y = centre.y + radius;
In contrast Raphael knows that my shape is a circle and lets me modify the radius directly:
circle.attr("r", newSize);
Both libraries offer an API to react to mouse click and drag events. Raphael allows you attach event handler directly to objects:
circle.drag(onMove,null,onEnd);
Where as Paper.js monitor for clicks anywhere on the canvas and then relies on hit testing to help you interpret what the user clicked on:
var hitResult = paper.project.hitTest(event.point, hitOptions);
Over all the motion in Raphael feel more responsive. I need to look into any simple optimisations I can make in the Paper.js code. The Raphael circle is also drawn more nicely. I need to revisit my Paper.js smoothing code to see why my circle there is wonky.
You can see my code as it evolves on github.