Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - WWF - Cancels an activity execution when an exception occurs

Reply
 
Old 03-23-2009   #1 (permalink)
Cesar


 
 

WWF - Cancels an activity execution when an exception occurs

Hey folks.

This question is about Windows Workflow Foundation and exception handling.

I have a HandleExternalEventActivity activity that runs some code when the
user clicks an "Accept" button on my form. The activity includes several
tasks that involves database and eventually filesystem.

The problem is, when an exception occurs within that activity, the workflow
is set to Terminated. That ruins the flow, because even if I can trap the
exception (throw to the host)
, the user will not be able to click the Accept button anymore, because the
workflow state will be erased.

In short, is there a way to catch the exception inside the activity and
return it like if it was never called? (same as a rollback).

I tested FaultHandlers, not good. And I have searched a lot, but can't find
this "activity rollback" behaviour.

I appreciate help.

*Ps*.: just to know the way of working, I wish this:
1. user clicks accept button;
2. wwf throws an exception;
3. the host application traps and tells user to fix whatever data is wrong;
4. user clicks accept again;
5. wwf continues to trhow exception till everything is ok. If all ok, commit
the regular way long.


Cesar



My System SpecsSystem Spec
Old 03-24-2009   #2 (permalink)
Norman Yuan


 
 

Re: WWF - Cancels an activity execution when an exception occurs

You can look into compensation that work with or without
FaultHandlerActivity: CompensatableSequenceActivity and CompensateActivity
(but do not confuse the two).

Or even just FaultHandler would do it (assume it is a sequencial workflow):

you place the EventDrivenActivity's container (a ListenActivity?) in a
WhileActivity loop, and set a flag in the workflow to indicate whether
"Accept" process is done successfully or not, the workflow will be in a loop
to listen the "Accept" event until "Accept" process is done. If the
exception happens, the FaultHandler catch it (so that your workflow is not
terminated), the ListenActivity is done, but the "Accept" flag is not set,
so the workflow will loop back due to WhileActivity. Of course you may want
to have some sort of notification if the "Accept" process repeatedly throws
out exception (or the user knows to whom he/she should report for this
failure), so that your workflow would not be stuck there.

"Cesar" <nospam@xxxxxx> wrote in message
news:%238XOp8%23qJHA.4592@xxxxxx
Quote:

> Hey folks.
>
> This question is about Windows Workflow Foundation and exception handling.
>
> I have a HandleExternalEventActivity activity that runs some code when the
> user clicks an "Accept" button on my form. The activity includes several
> tasks that involves database and eventually filesystem.
>
> The problem is, when an exception occurs within that activity, the
> workflow is set to Terminated. That ruins the flow, because even if I can
> trap the exception (throw to the host) , the user will not be able to
> click the Accept button anymore, because the workflow state will be
> erased.
>
> In short, is there a way to catch the exception inside the activity and
> return it like if it was never called? (same as a rollback).
>
> I tested FaultHandlers, not good. And I have searched a lot, but can't
> find this "activity rollback" behaviour.
>
> I appreciate help.
>
> *Ps*.: just to know the way of working, I wish this:
> 1. user clicks accept button;
> 2. wwf throws an exception;
> 3. the host application traps and tells user to fix whatever data is
> wrong;
> 4. user clicks accept again;
> 5. wwf continues to trhow exception till everything is ok. If all ok,
> commit the regular way long.
>
>
> Cesar
>
My System SpecsSystem Spec
Old 03-25-2009   #3 (permalink)
Cesar


 
 

Re: WWF - Cancels an activity execution when an exception occurs

Hmmm... I was trying to escape from setting a loop to fix that, for the
reason not turning the workflow too complex (I have about 8 ListenActivities
on it).

But since it seems there are no simpler manner to do it, then I'll go for
it.

Thanks!
Cesar

PS: Btw, its a confuse logic to follow. The expected way to work would be:
"if something was wrong, lets cancel it". And not "if something was wrong,
lets continue the work, as it was not important". Any way to suggest an
improvement to wwf team?



"Norman Yuan" <FakeName@xxxxxx> wrote in message
news:eygGZ2IrJHA.1748@xxxxxx
Quote:

> You can look into compensation that work with or without
> FaultHandlerActivity: CompensatableSequenceActivity and CompensateActivity
> (but do not confuse the two).
>
> Or even just FaultHandler would do it (assume it is a sequencial
> workflow):
>
> you place the EventDrivenActivity's container (a ListenActivity?) in a
> WhileActivity loop, and set a flag in the workflow to indicate whether
> "Accept" process is done successfully or not, the workflow will be in a
> loop to listen the "Accept" event until "Accept" process is done. If the
> exception happens, the FaultHandler catch it (so that your workflow is not
> terminated), the ListenActivity is done, but the "Accept" flag is not set,
> so the workflow will loop back due to WhileActivity. Of course you may
> want to have some sort of notification if the "Accept" process repeatedly
> throws out exception (or the user knows to whom he/she should report for
> this failure), so that your workflow would not be stuck there.
>
> "Cesar" <nospam@xxxxxx> wrote in message
> news:%238XOp8%23qJHA.4592@xxxxxx
Quote:

>> Hey folks.
>>
>> This question is about Windows Workflow Foundation and exception
>> handling.
>>
>> I have a HandleExternalEventActivity activity that runs some code when
>> the user clicks an "Accept" button on my form. The activity includes
>> several tasks that involves database and eventually filesystem.
>>
>> The problem is, when an exception occurs within that activity, the
>> workflow is set to Terminated. That ruins the flow, because even if I can
>> trap the exception (throw to the host) , the user will not be able to
>> click the Accept button anymore, because the workflow state will be
>> erased.
>>
>> In short, is there a way to catch the exception inside the activity and
>> return it like if it was never called? (same as a rollback).
>>
>> I tested FaultHandlers, not good. And I have searched a lot, but can't
>> find this "activity rollback" behaviour.
>>
>> I appreciate help.
>>
>> *Ps*.: just to know the way of working, I wish this:
>> 1. user clicks accept button;
>> 2. wwf throws an exception;
>> 3. the host application traps and tells user to fix whatever data is
>> wrong;
>> 4. user clicks accept again;
>> 5. wwf continues to trhow exception till everything is ok. If all ok,
>> commit the regular way long.
>>
>>
>> Cesar
>>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Exception stack is corrupt when catching and storing the exception .NET General
Vista Install Error: Exception Unknown Software Exception Vista installation & setup
Installation cancels becasue of system volume Vista installation & setup
Gathering Files Cancels @32% Vista General
Upgrade Check incorrectly reports McAfee exists and cancels upgrad Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46