Steven Nagy .NET

Sunday, 10 February 2008

Last Post Here - Subscribe to new location

Heyas,

So this is the last time I will post here. I've just uploaded a proper post to my new blog location. Please subscribe to it there because this is the last post I will ever make to this location.

New location: http://stevennagy.spaces.live.com/
Main Feed: http://stevennagy.spaces.live.com/feed.rss

I'll leave the old topics here for reference sake (since there are SOME references to it out there!). Hope to see you soon at the new blog.

Technorati Tags: ,,,

Tuesday, 29 January 2008

Getting Ready for 2008

A new year comes with a new job and a new perspective.

One of my personal goals this year is to increase my community involvement. There are lots of user groups in Brisbane, and similar opportunities Australia wide. I've filled in my Outlook calendar with all the upcoming events and thought I'd share the list with you as well (for the next month):

  • 30/1/08 5:30pm : BizTalk user group - Mark Daunt on RFID support in BizTalk
  • 01/2/08 7:30am : VSTS user group - Grant Holiday on securing TFS
  • 19/2/08 5:30pm : QLD MSDN user group
  • 28/2/08 5:30pm : SQL Server user group

Also, in April (26th and 27th) is CodeCampOz. Although I've never been before, I'm aiming to drive down this year. Want to car pool? CodeCampOz has been described to me as a mini Tech.Ed except without the advertising.

Readify provide presentations called RDNs which I hope to also get moved to Brisbane in the not-so-distant future. RDNs are like user groups, but the content can have more depth. Getting these in Brisbane will be great for the local development community.

My blogging will hopefully increase in both quantity and quality. Currently I am working with Notification Services, Visual Studio 2008 and .Net 3.5. All new technologies for me, which means more tidbits to learn and share with you.

I've also decided to move my blog to Windows Live Spaces. As portals go its not too shabby, and has a nice layer of extensibility. The official link is here. If you have a windows Live account then its easy for you to leave comments. Oh, and add me as a friend! I am currently cross posting to both old and new blogs for now, but you should definitely subscribe to the new version as soon as possible.

There's some projects I'd like to attack this year. I've found a podcast receiver that works on Vista called PrimeTIme Podcast Receiver, but am not wowed by it. So one of my plans this year is to build a podcast subscription tool. Could be a good candidate to learn some WPF as well.

I also want to work on a patterns web site that provides code examples in multiple programming languages.

Most importantly, this year I will get certified. I've delayed it for too long. I have a few certifications in mind long term, but currently I am aiming for MCTS in Web Applications.

Let me know if there is something you would like me to cover in my blog. Otherwise the direction will be random (as it has been). Also, if you would like to provide feedback on how to improve my writings/content, please feel free to be open and honest since it will only benefit you when my style gets better.

Watch this space.

Thursday, 24 January 2008

Sql Server Notification Services

Sql Server 2005 is more than just a relational database management system (RDBMS). It also contains a reporting engine called Reporting Services (SSRS), a data warehousing system called Analysis Services (SSAS), an engine for selectively pulling data from various sources called Integration Services (SSIS), and a subscription based notification engine called Notification Services (although I've not seen this notation, I presume we can say SSNS for short?).

Each of these items are a technology unto themselves and take time to learn and master. Recently I started with Readify and my first job was to do a proof of concept for an internal project. It involved Notification Services and I was able to learn some cool stuff to share with you.

SSNS is available in all versions of Sql Server 2005 ; all my development was done with Developer which costs around $80AUD. The core components of a SSNS instance are as follows.

Subscribers
Users must be in the subscriber list to add subscriptions. This is essentially a 'User' table in SSNS.

Subscriber Devices
Users can receive their notifications in different ways. For example I might get a full detailed notification in my email, just the 1 line title on my MSN messenger, and a summary of all of the days alerts on my PDA.

Subscriptions
A subscriber can subscribe to a particular field in an event. For example, they may want to receive notifications when someone posts a comment on their blog that contains swear words. So the subscription uses a SQL query to look for key words in the blog comment, and if it finds them, the user will be notified.

Events
Events are the things occurring that may or may not cause notifications to go out. In the above example, the Event is the comment being posted. Every comment that gets added to the blog causes an event in Notification Services, but only the events with swear words in the comment field will cause notifications to go out.

Notifications
These are the content that are sent to users. They occur as a result of an event matching a subscription. They are sent on a channel such as email, file, service, etc. The notification is formatted with XSLT, and can use event data as necessary.

How It Works
So there's no real programming involved here. Essentially its all declarative via 2 XML structures. The first simply specifies the applications; its kind of like a solution in Visual Studio. It specifies what applications will exist, and also allows you to specify parameters for your XML files. Then you need 1 XML file per application. This file will contain XML schemas of your Events, Subscriptions, and Notifications. It also allows you to specify how notifications can be sent, and how events can be submitted.

Don't I Get To Write Code?
Yes you do. The API is very open to fiddle with. When you upload your XML files to SSNS it will create 2 databases, with lots of tables and stored procedures. The good news is that you don't have to touch those items. If you maintain your schemas in your XML files, it will ensure the tables are created correctly.

However, some of the stored procedures are there for you to call; particularly around submitting subscribers, devices, subscriptions, and events. So you could call those sprocs, or you could use the managed API for Notification Services. This is just an assembly you can add a reference to in your application. For example, create a windows app that provides the interface for logging in and adding/removing subscriptions. With a few quick method calls you have connected to your SSNS application and not had to write any SQL! I can't stress enough how easy it is to use this API. You can do everything you need, and its very logical to use.

Pulling It Together
Ok so think about this example. I want to receive email updates whenever anyone adds a comment on my blog that mentions 'Notification Services'. So I create an event schema that allows for a comment ID and content to be sent to SSNS. Then I create my notification schema with just the comment data field (since I don't need the ID in my email). Thirdly I create a subscription schema where I specify a field called 'SearchPhrase' and an SQL statement that inserts data into the Notification schema by searching the Event comment data for the search phrase.

Now I just need to specify how the event data gets into the event schema in SSNS. I have lots of options here:

  • My comment code just calls a sproc, so I can change that sproc on the server to include a call to insert the event data into SSNS via a sproc
  • I could add a trigger on the comments table in my database such that when data is added, it will also add that data to SSNS via a sproc
  • In my .Net code I could just call the sproc to insert the comment data after I have added it to the database
  • Or I could use the API mentioned earlier to add the subscription so I don't have to worry about nasty sprocs!

Oh I need to add a subscription too; since I now know SSNS well enough, I can just insert this into the right table; I don't plan on subscribing/unsubscribing continuously.

More Resources
Check out the MSDN tutorial:
http://msdn2.microsoft.com/en-au/library/ms170337.aspx

Or here is the MSDN main stop:
http://msdn2.microsoft.com/en-au/library/ms172483.aspx

And the API reference:
http://msdn2.microsoft.com/en-au/library/microsoft.sqlserver.notificationservices.aspx

And please, no swear words in the comments. :P

Tuesday, 20 November 2007

Ready For Readify

Thought I'd post this before I go on vacation. Today I resigned from my position as a Lead Developer for Zap Technology. I've been offered an excellent position with Readify, a company I've viewed from afar for about a year and a half now.

One of the things that sold me on Readify was their attitude towards the development community. Most people who attend user groups (anywhere in Australia) will have seen a Readify presentation. They hold a large percentage of the Microsoft MVPs in Australia and empower their employees to do the same if they so desire. In fact they even give you incentives to get active in your community.

These are all the things I love to do: And they want to pay me to do it!

Well I start with Readify in mid January. I was planning to move this blog to Microsoft Live Spaces when I got back but I'll reconsider this move now. One thing's for certain is that my postings will increase in frequency and in quality. Hopefully they'll sound less like a letter written to my mother, and provide more technical information.

I also have a personal mission that I have challenged myself with: To drive the Brisbane/QLD development community, to the point where the other states get jealous. I hear so much about what's happening in other states on various blogs, but never Brisbane. This might be because I read the wrong blogs, but I'm a patriot none-the-less, and I want to see user groups with turnouts in the hundreds! I also want to see some deviation and expansion. Perhaps a Rich Web user group? Or a group dedicated to code quality (which fits with another idea I hope to act upon next year)? All ideas are welcome, and if you have any ideas for an open source project, I'd also be keen to hear.

I'll use my holiday to think through some strategies for how to achieve these meager goals.

I wonder if Readify have an indoor soccer team?

Sunday, 18 November 2007

Books Books Books

I'm sorry! I've been so busy, posting has suffered.

I am now the Lead Developer for our primary Business Intelligence product at Zap Technology. My 3 month review at Zap resulted in this promotion which I happily accepted. Those who know me know that I was in a Lead Developer position prior to Zap.

This post though is more of an encouragement to all you fellow Australian developers. The Australian dollar is doing quite well against the US dollar. Now is a great time to buy those technical/reference books you always wanted! My recent Amazon order went in when the dollar was at USD $0.92. Normally I purchase theory related books but saw this as a good opportunity to get some reference books as well. Here's my order, some of which have already arrived:

Hopefully you recognize some of the names. Kent Beck has been around the code quality scene for ages, and this new book of his is due out in January. Darren Neimke works for Readify, a Microsoft Gold-Partner consulting firm in Australia. Jon Skeet is a Microsoft MVP based in the UK. I respect Jon's commitment to the community and enjoy is writing style in news groups, and am looking forward to his first .Net related book in January.

So get those orders in! Create yourself a wish list and get your family to buy you some books for Christmas.

This will be the last blog post until after the Christmas season, so happy new year to you all!

Technorati Tags: ,,,

Sunday, 14 October 2007

Beta Central: Windows 2008 Server, TFS 2008, and VSTS 2008

Recently I decided I was going to upscale my home development environment. By this I mean introducing some Continuous Integration concepts, proper source control, etc. I already had a task management system (Gemini) but figured I could also integrate task management with check-ins. Originally I thought about using Subversion, Cruise Control, Nunit and Ncover. This is our work setup and it seems to do the job quite well. However lately we have been investigating Team Foundation Server from MS as a possible replacement, and being the MS fanboi I am, decided to give this a shot instead.

Being that I'm not licensed for any server technology or TFS, I figured this would be a good time to give the newer technologies a go (since I had already downloaded all the betas). This post will be about all the lessons I learnt in the process of setting this up. I am NOT a sys-admin and know jack about setting up windows server software. So if you want to avoid any of the traps I encountered, read on! Also, some of the stuff I did was stoopid, so you might also like to read on for a laugh.

So the architecture is this: AMD 1400Ghz with 512mb RAM, dedicated as my new build server.

Round 1.
My first mistake was that I didn't read any of the pre-install documentation from MS. I installed Windows Server 2008 Beta 3. This was easy. After it is installed you get to install certain components. The list is huge and I figured "Why Not!". I installed DNS, Domain Controller, Sharepoint, Deployment Services (I've seen this in action, its great), and practically everything in the list. Next, try TFS. It wants to be pointed to a database instance: I don't have one! Lucky I have a Sql 2005 Developer licence ($85 from Harris Technology) so on it goes. Try TFS again, this time it starts cranking through, and gets to the screen where it checks if the machine is up to scratch. My CPU and Ram are a little low, but its only a warning. The biggest problem is this: You can't install TFS on a domain controller.

So I uninstall DC, and DNS, and everything else domain related. Now the machine doesn't function properly: IIS stops working, and so does Sharepoint. Turns out that TFS wants Sharepoint and Sql Server Reporting Services working properly. Nothing for it now: have to rebuild.

Round 2.
This time I only install bare bones Win Server 2008 and add Sharepoint and IIS. Then I add Sql Server (and Reporting services): all good so far.

Then I realise something: I forgot to set my computer name! Its currently set to something like "win1203-543923443". This is unacceptable: I go and set it to the name I want. Guess what? IIS stops working (and thus Sharepoint) and everything goes to sh!t. Try as I might, I can't get it working again and TFS won't install.

Round 3.
So after rebuilding a 3rd time I am meticulous. Slow and steady, I ensure everything is done right. TFS makes it all the way to the end of the progress bar before spitting out an error about reporting services being unavailable. I spend a long time trouble shooting this and to make a long story short, here is a list of things you should know about:

1. IIS installs the usual "Default Web Site" (DWS). When you install Sharepoint, it adds a new web site to your sites and takes over port 80. The "Default Web Site" is stopped.

2. Reporting Services (RS) is connected to via a web service. This web service is installed on the DWS which as we know is stopped when Sharepoint is installed. So I assigned the DWS to port 88 instead and started it. After this, I could no longer use Sql Server Management Studio to connect to my Reporting Services.

3. Reporting Services has a .config file that allows you to specify what its Root Url is. Check in the ReportServer web application for this config file: rsreportserver.config. I needed to add the new port 88 to the Url. After this change (and IIS reset) I could then use Sql Server Management Studio again to connect to RS.

4. When TFS installs, it dumps some install logs here:
C:\Users\Administrator\AppData\Local
These logs will tell you what commands are being executed, and if they fail, a reasonably detailed error message (unlike the installer which tells you nothing useful).

5. When installing, TFS needs to connect to the Reporting Services web services. However you never get to specify what the URL is, and by default it looks on port 80. This was no good for me since Sharepoint was using port 80 and my RS was on port 88.

6. There is a tool installed with Sql Server 2005 called Reporting Services Configuration. This tool is awesome: it is extremely easy to use and most of the options make sense once you comprehend that RS is all web based services only. One of the options is called "Sharepoint Integration". This was not on by default. I found some help online about how to turn this on, but essentially you select the "Database Setup" option and create a new database in integration mode. This actually creates a new RS database on your Sql Server. After you do this, you will no longer be able to connect to RS via Sql Server Management Studio because of an error that states (in approximately these words) "Can't connect while RS is in Sharepoint integration mode". Don't worry, this is perfectly fine. You can still test your RS works by calling one of the web service methods directly.

7. Sharepoint Integration mode does NOT solve all your problems. In fact, looking back at the server now, its not even turned on for me. What I discovered with this tool is that you can change your RS virtual directory locations: you know, those guys on port 88 causing me so much grief? Well by creating a new Virtual Directory for the 2 RS sites, I was able to put them on the Sharepoint website (rather than DWS). This means they are on port 80, and my TFS installer runs through fine!

Server is done and dusted at this point. In your database instance you will see a whole swag of new databases for TFS (as well as your new RS database), and IIS has a "Team Foundation Server" site setup as well on port 8080.

Next step was to install Visual Studio Team System on my development machine (to my knowledge you can't use just VS2008 Pro). Then you also have to install "Team Explorer" which is on the TFS install disk. Finally, you connect to your new server with Team Explorer on port 8080 over http (you can do https as well but I'm not going to tackle SSL on the server at this stage: I'm just happy that its working). Finally, I could not connect to my TFS server using the machine name, it needed the full IP address. Oh well I can live with that.

Please, if anything here helped you install TFS, please leave me a comment saying so. Otherwise if you want further explanation or assistance, I'll do my best to help you of course.

Tuesday, 25 September 2007

Session - Where Is It Stored?

In an effort to increase my postings I've decided to just do some little "tidbits" here and there about random developer stuff. The technical level will be quite basic usually but may require some basic knowledge of .Net.

So for the first one I want to just talk about 'Session' in ASP.NET. You may have used it to store objects for a particular user so that the information is available between page requests. For example, before the Membership Provider, you might have had code in a login page that looks like this:

User user = User.FindByUserName(txtUserName.Text);
if (user.Password == txtPassword.Text) {
   // Valid login, put user in session
   Session["CurrentUser"] = user;
}

So where exactly is this being stored? Well session can be managed different ways. Out of the box, a new web project will store session in a process that comes with IIS. This means it sits in memory permanently, and if IIS gets reset, or the application pool gets reset, then the session is lost. I'm sure we've all experienced this when we rebuild our web app.

There are, however, other options. Via a configuration in your web.config, you can tell your application to store session objects in other locations. You can store them in a dedicated service running on the same, or a different, machine. Once again, this is 'in memory' which means if the service is restarted, the session is lost. However the advantage is that the service can be running on another machine, and if IIS or the app pool needs a reboot, the session is not lost. A third option is to store session information in a database like Sql Server. This is great because no matter what, session information is never lost (pending a corrupt database of course). However storing session objects in a database can have some overhead.

There is no "best" option. It really depends on what your app needs. But consider this scenario: your application is HUGE and is scaled across a web farm (several servers serving your website). Each server runs IIS. This means there are multiple in-proc session locations. Session objects in one server won't be available in another. This means if user X requests a page and logs in after being served from server A, they might then click on a page that gets served from server B where the session object doesn't exist; they get prompted to login again! This is where a dedicated state-server or database storage becomes extremely useful.

That's all I wanted to say. You can read more about it in this article from codeproject.com.

Technorati Tags: , ,