Async web services the easy way

3/6/2009 4:50:58 PM Development Tony Comments

Source:Begin/End Async WebService Proxy Methods

Have you ever needed to kick off a long running process through a web service and immediately return control of the page to the user?  I have a process which takes about 10 minutes to run and I don't want to just set the page timeout really really high and make the user sit there and watch IE grind.  With the tweak to the project file described below, web service "begin" and "end" methods will be generated for the web service when you add it as a web reference to your project.  If you had a HelloWorld() method you would now have access to a "BeginHelloWorld()" method which can fire off the web service and NOT wait for it to complete before returning control to the user.

You can add WebReference_EnableLegacyEventingModel with a value of true to the first ProptertyGroup section in your csproj file.  You will have to close visual studio before doing that and update your web references to generate the updated class with the begin/end methods.

Comment


Hosting a project on an XP UNC share... again

3/3/2009 7:54:48 PM Development Tony Comments

I just upgraded to Vista 64 bit from XP.  6 gigabytes of memory and a velociraptor 300 gig drive make it wicked fast and responsive under the worst conditions. 

But wait... Bios command limit reached!  What?... ok, I wrote a blog about this.  No problem...

... Bios command limit reached... unable to monitor changes .... what?!?

Hours of searching later I ran this from the run prompt and it started working again.  This issue has been around since 2005 and it's still here even in Vista 64 bit.  What a sigh of relief to get my intellisense back!

Oh, the command:
Drive:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url "file:////\\computername\sharename\*" FullTrust -exclusive on

 

Comment


Browser war shifting?

2/25/2009 11:04:12 AM Development Tony Comments

This article at ComputerWorld says since the introduction of firefox to the market that IE's market share has fallen from 95% to 70%.  While that is still quite the majority it means that as web developers we have to start taking "standards compliant" browsers seriously.  With IE8, which microsoft asserts will be standards compliant by default, will hopefully usher in a new time of compatablity across all browers.  I know that's an unlikely scenario but we can hope right:?

In the past with most people using IE, I've pretty much ignored "alternative" browsers but with the recent shift I've started coding so my work is visible in firefox / safari / etc.  I actually feel a bit of pride when I see my creations work across multiple platforms.  I even tested my latest gadget on an iphone and it looks great.  I have to give a lot of credit to jQuery of course because it handles a lot of browser-specific functionality automatically, but their victory is my victory and I'll take it.

Does your app work in firefox?  Yes -  How about safari on a mac?  Yes - 

These are the questions we're going to be asked, and "yes" is the right answer.  A pool of 30% is a nice size group of potential customers to draw from, especially when the IE user pool is shrinking.

Comment


jQuery - a shot in the arm for web 2.0

2/13/2009 9:41:36 AM Development Tony Comments

In the development world you can't sit still for a minute.  There is always a new technology coming along to make everything you know obsolete. 
The never ending struggle to make user interactions on the web more like windows applications has gotten a little less never ending with jquery.  I happened upon this video from last year's PDC which showed me the light.  I actually went out and bought a jQuery book the next day.
jQuery is an open-source javascript library that takes a lot of the hassle out of writing javascript. It allows you to separate behaviors of controls on your page from the page from the markup (a technique called unobtrusive javascript) which among other things makes your behaviors reusable in the same way you can reuse CSS. 

You can also easily (and I mean ridiculously easily) build custom functions AS AN EXTENSION TO THE FRAMEWORK of jQuery.  Your functions are virtually indistinguishable from the core library.

One of the most exciting things I've learned (in the two chapters I read) is how the jQuery selectors work. It's much easier to get a list of DOM objects and perform [multiple] operations on them in a single line of code.  To give you an example, to select all of the TD tags on your page and put a new class on them you could write:

$("tr:odd td:contains(19)").addClass("wrappedElement")

This gave you a group of TD's inside odd numbered TR's and applied a new CSS class to them all.  NEAT!  You can also get a group of objects that are child elements of a div tag.  Think of how powerful that could be - Imagine having a div with input elements and when you clicked on a save button it grabbed all of the elements, put their names and values into a collection and sent it off to a web service for processing.  In the past you would have to write a getElementByID for each control and every time you added a new control to your form you would have to change your javascript.  Using a jQuery selector your behavior code is dynamic - go ahead and add your new controls.

This doesn't even scratch the surface of jQuery.  There are all sorts of plugins available including things like sorting tables and adding animation to your pages.  Go ahead and check it out and start writing more dynamic user interfaces.  Your users (and salesmen) will thank you.

 

Comment


@@Identity Crisis

12/12/2008 9:21:05 AM Development Tony Comments

A customer is experiencing a problem with piece of software I work with.  He's done some research and he's pointing at the use of @@identity in queries to get the ID of the last inserted value.  @@Identity is one of those SQL 101 things you learn and trust as an axiom - "If you need the id value of the most recently inserted record, select @@identity".   I have never had any problems with @@identity, but in case you do there are actually 2 other options: (source SQLAuthority.com)

SELECT @@IDENTITY
It returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value.
@@IDENTITY will return the last identity value entered into a table in your current session. While @@IDENTITY is limited to the current session, it is not limited to the current scope. If you have a trigger on a table that causes an identity to be created in another table, you will get the identity that was created last, even if it was the trigger that created it.

SELECT SCOPE_IDENTITY()
It returns the last IDENTITY value produced on a connection and by a statement in the same scope, regardless of the table that produced the value.
SCOPE_IDENTITY(), like @@IDENTITY, will return the last identity value created in the current session, but it will also limit it to your current scope as well. In other words, it will return the last identity value that you explicitly created, rather than any identity that was created by a trigger or a user defined function.

SELECT IDENT_CURRENT(’tablename’)
It returns the last IDENTITY value produced in a table, regardless of the connection that created the value, and regardless of the scope of the statement that produced the value.
IDENT_CURRENT is not limited by scope and session; it is limited to a specified table. IDENT_CURRENT returns the identity value generated for a specific table in any session and any scope.

To avoid the potential problems associated with adding a trigger later on, always use SCOPE_IDENTITY() to return the identity of the recently added row in your T SQL Statement or Stored Procedure.

Comment