Wednesday, April 21, 2010

How to Deploy a VSTO Word Template Application

I recently had to build a word macro that read an Excel spreadsheet and produced a series of PDF files that were then sent out to an email that existed within each row.

The approach that I took was to develop a VSTO Word Template application that would step the user through the process of selecting the spreadsheet, reading the data and finally processing the data.

Step One - Creating the Application
To create a Word Template application is relatively straight forward. From the New Application dialog browse for Office > 2007 > Word 2007 Template. You should now be presented a .dotx file that you can now customise to your hearts content.

Step Two - Adding the Controls to Template
Not having worked with a VSTO application before I simply copied the RichTextContentControl from an example application I found. However, like any .Net application all the controls that can be utilised in the Word Template can be found in the toolbox. (Thanks Mr Obvious!)

Here's what mine looked like...

Step Three - Adding the Actions Pane Control
Just having some controls embedded in a template isn't going to do a lot, you need some way for the users to interact with the template. This is where the Actions Pane Control comes in play.

Here's what mine looked like...


So you can basically added all manner of controls to the Action Pane and treat it like a Windows Form.

Step Four - Deploying
Developing all of the above is fairly straight forward, just like developing a web/win app, F5 and away you go. But how to deploy that was a little different.

Googleing "How to deploy a VSTO word template application" and the like continued to give me information on the problems people were having. Not very helpful! Thankfully due to the awesome resources available from Readify I was eventually pointed to the following links:




These links are your one stop shop for deploying VSTO applications.

Enjoy!

[Edit]
I also came across these screencasts yesterday. They provide an awesome walk through of the deployment process.
VSTO: Deployment via ClickOnce screencast and VSTO: Deployment via SharePoint

Next: Installing Pre-Requisite Assemblies For VSTO Applications

Friday, April 9, 2010

A New Beginning

Well last Wednesday, 7th April 2010, marked a new beginning for me as I started at Readify as a Senior Developer.

I hadn't been 100% happy at my previous employer and so I had begun priming myself for my application as soon as my 12 months was up. Unfortunately for my previous employer I started attending Sydney's ALT.NET User Group and told Richard Banks of my intent. His response was as simple as "well... we're looking for approximately 10 developers right now." and he left it at that.

Needless to say the rest is history and here I am now a proud Readifarian.

But wait! There's more!

Readify are still looking for more developers (2 for VIC and 5 for ACT/NSW plus a SharePoint guru for WA) who can also experience the awesome benefits of working for Readify.

Enjoy!

Monday, March 15, 2010

Aggregate Functions in Linq Group Statements

I was refactoring some of my linq queries in my budget app today and was having some difficulty with some of the grouping statements especially when I wanted to sum up the values in a decimal field.


Without showing you the code I'm refactoring (that would be way too embarrassing), here's a particular query that I was working with.

from mc in MthCategories
from s in (from s in Spendings where mc.MthCategoryId == s.MthCategoryId select s).DefaultIfEmpty()
where mc.Mth.Month == 3 && mc.Mth.Year == 2010
group s by mc.MthCategoryId into g
select new {
    MthCategoryId = g.Key,
    AmountSpent = (from s1 in g select s1.Amount).Sum()
}

This looks fine, however, when executed you will get the following InvalidOperationException

"The null value cannot be assigned to a member with type System.Decimal which is a non-nullable value type."


What gives!


Now I was initially thinking that this had something to do with the inferred type that was being applied to "AmountSpent", so I had a look to see what g was.


I really wasn't thinking clearly and all sorts of things were going through my head. I tried checking if the FirstOrDefault() value was null and then doing the Sum, but that didn't work. A little while later it occurred to me that "g" was actually comprised of a key and a collection and regardless of how many items were in the collection it was still there and that my initial thinking was screwed up. The problem had nothing to do with the inferred type but was caused by the fact that my sub query (from s1 in g select s1.Amount).Sum() was selecting a null value and it was the act of trying to apply Sum to a null object that was causing the problem.


The resulting query was:


from mc in MthCategories
from s in (from s in Spendings where mc.MthCategoryId == s.MthCategoryId select s).DefaultIfEmpty()
where mc.Mth.Month == 3 && mc.Mth.Year == 2010
group s by mc.MthCategoryId into g
select new {
    MthCategoryId = g.Key,
    AmountSpent = (from s1 in g select s1 == null ? 0 : s1.Amount).Sum(), 
    Spendings = g
}

Of course all of this could have been avoided had I clicked the Activate autocompletion link in LINQPad.


I hope this has helped.


Enjoy!

Tuesday, March 9, 2010

fsBudget - A Small Budget Application Built with jQuery, Ext-Js, C# and WCF

Finished! My first OS project.

Built using C#, jQuery and Ext-Js, it utilises WCF to consume the business layer.

Feel free to have a look.

Enjoy!

Tuesday, March 2, 2010

Time Well Spent

Well this morning provided some time to find out a bit more about a guy by the name of the Joseph Albahari.

Firstly, listed to Talking Shop Down Under where Richard chatted with Joe regarding a range of stuff primarily on C# 4.0 and LINQPad.

Secondly, being prompted by the podcast I went and had a look at Joe's site and found reference to a webcast that he'd done for LIDNUG. This was absolutely awesome! If you've got approx. 1.5 hours free definitely worth a watch as Joe takes you through some of the new features of C# 4.0 and explains some of the pros and cons and offers some explanations as to the why's.

Enjoy!

Wednesday, February 24, 2010

Sydney's ALT.NET User Group Gathering

Yesterday was my first time at the ALT.NET User Group and it was a lot of fun.

Apart from Richard Banks (who I'd worked with before) it was a sea of new faces, which is cool as one of the reasons I wanted to go was to get to know other people in the industry.

So for those who haven't been before, here's my little run down on the night.

The night started at 6pm so people were rocking up from around 5:30.

Not know anyone, most of my time was walking around shaking hands and saying, "Hi my name's Matthew. How you doing?". There seemed to be a great variety of people with even a C++ developer amoungst us. :)

Richard kicked things off with general question to everyone about anything cool they'd seen/read/done etc, then we continued with two presentations, one from James Crisp on Automated Builds and another by Romain Prieto on Automated Deployments.

Automated Builds
James started off his talk by implying that all the xml based build systems were crap, and introduced nRake.
nRake removes the dependency on a huge amount of xml configuration and introduces Ruby's OO scripting in-order to programmatically generate a build. Very interesting.

Automated Deployments
Next came Romain who introduced the concept of automating the deployments. Romain has put together a little tool he's called psDeploy (which he informs us he'll be putting up on Github soon), which is a library of cmdlets to assist with the deployment of applications. He highlighted how this tool works well with TFSDeployer and psake.

Besides the talks being enjoyable, the sarcasm was great.

Overall an enjoyable and interesting evening which I'd recommend.

Next month => hands-on-lab in a coding dojo.

Enjoy.

[Edit] psDeploy is now up on GitHub.

Friday, February 12, 2010

Great Scrum Resources

I just read a nice little post on Richard's Braindump regarding a new Professional Scrum Developer Course being offered at Scrum.org. Rather parrot what Richard said go read his post.

Anyway, while having a look through the site I came across some awesome Scrum Instructional Videos. Even if you've worked with Scrum, or maybe you think you've worked with Scrum, these are worth a look.

Enjoy!