Using Multiple WaitOnFile Steps

Jan 27, 2009 at 12:52 PM
Apparently this is not possible, because when the second step executes an exception is thrown as the waitedForFileName property is added to the context again.

A quick fix would be to use the Add overload with the updateIfExists flag, but this would still prevent me from using multiple WaitOnFile steps, which I'd like to do...

Any views on this?
Jan 27, 2009 at 1:37 PM
Fabio,
Can i ask what outcome you are looking for ? If you want multiple waitOnFile steps but dont really care about the file name, then, updateIfExists should do fine. You could also try using ContextManipulator to delete the key.

If you want multiple names stored against that key, then one thing you can do is write a custom step based on WaitOnFile which will hold a List<> of file names against the "waitedForFile" key.

let me know if this works or if theres something else you need to see happen ...

HTH,
Benjy
Jan 28, 2009 at 9:41 AM
Hi Benjy,
Thanks for your reply.

The intent of my first post was to suggest an enhancement to the WaitOnFile class and I wanted to see other people's opinions. Apologies for not making it very clear.

As you know, currently, if you use two or more WaitOnFile steps in the same test, this fails with an exception when the property waitedForFileName is added to the context again.

If this behaviour is by design, then fine, but I think it should be documented. If it's not, I suggested to change the implementation of Execute() to use the context Add() overload with updateIfExists = true.

This would overwrite the waitedForFileName property and I could use mutliple WaitOnFile steps with no exceptions, if I didn't care about the name of the file waited for.

Hope it's clear now.
Fabio
Jan 28, 2009 at 11:06 AM
Hi Fabio,

Ok, thats clear. The thing that got me confused was when you said

"A quick fix would be to use the Add overload with the updateIfExists flag, but this would still prevent me from using multiple WaitOnFile steps" ..

The overload flag would allow you to use multiple steps wouldnt it!

Yes, it would be good to have it documented. I can also add an enhancement to the WaitOnFileEx step in BizUnitExtensions to do this. (currently this WaitOnFileEx step allows files to already exist, not only check for new ones because sometimes in some scenarios, the files would get output very quickly by Biztalk and if you are doing various checks on the data of each file, then by the time you get to a specific folder, the file would already be there, so WaitOnFile will fail. )

cheers
benjy
Jan 28, 2009 at 11:44 AM
Hi Benjy,
I have posted some code here.

Fabio