Wrox Programmer Forums
|
BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio
This is the forum to discuss the Wrox book ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solution by Vincent Varallo; ISBN: 9780470396865
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2009, 07:06 PM
Authorized User
 
Join Date: Apr 2009
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
Default Workflow Validate Method Question

The workflow engine is giving me quite a few headaches currently, but I'm peeling away the layers to try and figure out what's going on and where I (most likely) went wrong.

One thing I've run across, and don't understand, is in the ValidateWorkflow method.

Early in the method, there's a check to see if OriginalItem is equal to null. If it is, the program throws an exception.

Based on the explanation in the book, OriginalItem is only of concern if the item has already been submitted and is in the workflow process. I can understand the null check on it - but why throw the exception?

Wouldn't it be easier to simply do a not equal to null check - if true, do the checks against original items, if not true nothing to worry about?

Tim
 
Old April 20th, 2009, 10:59 PM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

Hi Tim,
The ValidateWorkflow uses the OriginalItem object to check that the read only fields were not changed. It is true that this only applies when a request has already been submitted. I'm checking this in the ValidateWorkflow method so it forces the UI to pass in this property so if at a later time I needed this when submitting a request I would have to change all the UI pages that use a workflow object.
I throw and exception because if the code reached that path then it is a coding error and the user can not correct the problem. An email is sent to the administrators whenever an exception occurs so the developer would be notified. I like to throw exceptions when the developer has to change something and it is out of the user's control. I send back validation errors when the user can take action themselves and correct the problem.
The Following User Says Thank You to varallov For This Useful Post:
Corsair (April 21st, 2009)
 
Old April 21st, 2009, 12:31 PM
Authorized User
 
Join Date: Apr 2009
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
Default

Hi Vince -

Thanks for the reply. Your approach makes sense.

I was stumped because I couldn't find out where OriginalItem was being set - it wasn't being set at the business layer or the data layer. Your reply prompted me to look in the UI, which is where it is set.

I'm using my own pages in my application, basing the first one on PTORequest.aspx. I looked at the code-behind for your page this morning, and get this portion of the picture now. I ommitted the OriginalItem portion of the code from my page, thinking I didn't need it. The hazards of jumping in half-baked :) (but I learn much better by doing then just by reading).

Tim





Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about the clone() method ianni Java Basics 1 December 26th, 2007 05:14 AM
SysCmd method question... cjudd VBScript 2 July 22nd, 2005 11:59 AM
Sort Method question rgalehouse Javascript 1 February 10th, 2004 07:03 PM
Question on using the CONFIRM() method savoym Javascript 5 September 11th, 2003 10:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.