Introducing WunderLook: An Outlook Add-in for Wunderlist

This is my first attempt at writing both an Outlook Add-in as well as developing with Wunderlist. They don’t have an official API that I could find, but I did discover the .NET Wunderlist API by lerainieur on SourceForge which is a major component of this project. Many thanks to the developer for making this available.

Developing an Add-in for Outlook 2010

I had a difficult time just finding relevant and useful information on just how the heck you do this. I searched for hours on MSDN, as well as general searching on the internet for variations of “how to create an outlook add-in” that yielded pretty useless results.

So this blog post is meant to list some of the helpful resources I WAS able to find, as well as some of the things I learned along the way.

JustCode is JustSmart

I was doing some coding today when I discovered something very slick about Telerik’s JustCode tool I just had to share.

Telerik-Just-Code-Context-Menu

I needed to add a property to a class, and my coding style puts private properties and their public accessors in separate #regions. I added the private member to the “Private Properties” region, and decided to let Just Code stub it out for me, expecting it to generate the public property directly beneath my private variable. I figured I would just copy and paste it into the appropriate region.

Imagine my surprise when instead of generating the code beneath my variable, it popped up inside my “Public Properties” region!

Telerik-Just-Code-Property

I thought that this might be a fluke, so I added a few test regions in between to see if it was just grabbing the first one after it. Sure enough, however, it popped right back into the right region!

Telerik-Just-Code-Property2

It’s the little things, you know?

More about JustCode »

Sitefinity: Easy SP Upgrades with DiffMerge

As part of the process of preparing the Sitefinity Toolkit 1.1 update for release later this weekend, I needed to upgrade my sites to the latest Sitefinity SP3 update.

For those of you who’ve done this, you know it’s MOSTLY a simple process, but can get tricky when copying the /Sitefinity folder files, because, like me, many of you probably customize or modify these files to meet your needs. Sitefinity addresses a lot of this by supporting external templates, but sometimes it’s easier to just edit the files directly.

However, this becomes a problem with every SP release because these files can get overwritten by newer versions. Fortunately, there’s an easy way to ensure that you get the latest code files without sacrificing your customizations. And best of all it’s FREE!

Sourcegear is a company specalizing in Source Control for Small to Medium sized businesses. I’ve been using their Fortress software for some time now, and have been very satisfied. And recently, I discovered that it comes with their FREE DiffMerge tool, which is also available as a separate free download.

What I love about this program is that you can point it at two FOLDERS, not just files. So all you have to do is select your site’s /Sitefinity folder and the /Sitefinity folder from the update/patch:

diffmergefolder

And when the tool runs it will show you all the files that have changed:

diffmergelist

You can then go into each file and see exactly where the files differ. You can over write your file with the patch, or keep your changes if they are still required.

diffmerge

This tool has been a HUGE time-saver, as I have done literally dozens of customizations to core Sitefinity files, and there’s no way I’m going to remember them all. makes updates easy, and more importantly, SAFE!

That’s all for today, I’ll be working over the weekend to get the SP3-compatible release of the Sitefinity Toolkit up within the next few days. Thanks to all for your continued patience!

Note, although I do use SourceGear products, I am in no way affiliated with the company, and received no compensation or incentive for writing this article.

Inserting a Duplicate DataRow to a DataSet

While developing an online form, I came upon the need to insert two copies the results to a database, one for each of two options selected on the form. The only thing different between these entries would be this option, and of course, the autogenerated ID for the row’s primary key.

While I could simply call the Insert function of the TableAdapter twice, this method requires that each field be explicitly submitted as a parameter, and since the data is coming from textboxes, and there are about a dozen boxes on the page, that’s a whole lot of textbox.Text.Trim() arguments!

One alternative was to introduce a local variable for each textbox, assigning it the respective value, and only passing those locals as parameters, but being a HUGE fan of strong-typing, I would much rather use a class that maps these fields to a row, especially since the dataset I made for this Table already has one!

It was easy enough to instantiate the dataset, create the strongly-typed row and populate it with data and add it to the dataset:

var ds = new MyDataTable();

var app = ds.NewMyRow();
app.Option = OptionMenu1.SelectedValue;
app.foo = Foo.Text.Trim();
app.bar = Bar.Text.Trim();

Now I can add the first copy of the row to the datatable just fine. Unfortunately, since app is a reference variable, I can’t add it again, because it already belongs to the table. And even though the Add method will take an overload of the ItemArray, since it’s passing duplicate values, I’ll still get an error because the primary key (automatically assigned as -1) is being duplicated!

ds.Rows.Add(app);
ds.Rows.Add(app); // Throws Error, already in table!
ds.Rows.Add(app.ItemArray); // Throws Error, duplicate Primary Key! 

For whatever reason, DataRow does not include a Clone() method or any way to easily make a duplicate of the item. So the solution I worked out is to instead make a new instance of an object array from the DataRow.ItemArray property, setting the primary key (at index 0) to null before adding this new instance using the Add method. This forces the dataset to generate a new auto key so that the DataRow is unique. Then I can retrieve the reference to this new row (so I can have strongly-typed access to its properties) and change the option for this new row.

if (OptionMenu2.SelectedValue != "none")
{
    // duplicate row
var arr = app.ItemArray; arr[0] = null; ds.Rows.Add(arr); // update the option for the second row var app2 = ds.Rows[1] as MyRow; app2.Option = OptionMenu2.SelectedValue; } new MyTableAdapter().Update(ds);

Now all I have to do is call the update method on my table adapter and both rows are added from just one copy of the data. Not bad!

Rounding to the Nearest Ten

I’m not sure if the Microsoft .NET Framework has support for rounding to the nearest ten, hundreds, thousands, etc, so I built a quick snippet of code to accomplish this. The basic algorithm is to mod the value by 10 (can be modified to handle 100, 1000, etc), then if less than the median (in this case 5), subtract that from the original value. If the mod is greater than or equal to the median, we round up by adding the DIFFERENCE between the remainder and the rounding base (10 in this case). If there is a built in function, please feel free to link it to me in the comments section. If not, I might encapsulate this into my own SelArom.Math class and allow users to specify the base. Hope this was helpful to someone!

// get remainder

int rem = numToRound % 10;

if (rem < 5)

// round down, subtract remainder

rounded -= rem;

else

//round up, add diff b/t 10 and remainder

rounded += (10 - rem);

 

return rounded;

Editing The Datasource

Ahh it’s all coming back to me now… the headaches that is 😛

One thing that I would always forget how to do with the new asp.net 2.0 data controls is how to enable editing using the datasource. I set up the sql statements for select, insert, update, and delete, but only select would work. when I update something and save, it just reverts back…

the problem is that I forgot to set the Datakeys property for the control which I want to edit. It must be set to the primary key of the table in order to enable “out of the box” editing.

back to work

-SelArom