Page 1 of 1

Quickly validate a repository item does not exist

Posted: Fri Jan 24, 2014 11:53 am
by BobertyY
Hi there,

I was wondering if there was a quick way to determine if a repository item does not exist on the UI. I have a validate step that searches for the item with the condition 'NotExists', however due to the read-only property of the effective timeout this action takes ~1 minute. So I was wondering if there was a way to configure this timeout or if I should be using another technique. Any insight would be great :D

Thanks in advance!

PS. Sorry if this is a repost, I'm not sure my topic successfully posted last time :S

Re: Quickly validate a repository item does not exist

Posted: Fri Jan 24, 2014 2:34 pm
by krstcs
You can't directly change the "Effective Timeout" value. It is actually a combination of all of the Timeout values of the object itself and all parents.

What I do is have a standard short duration time set in my Program.cs file that I then use in UserCode to change the timeouts temporarily to a very short wait instead of the default (30s).

So your UserCode would have a method that looks like this:

Code: Select all

private void Validate_MyObjectNotExist() {
  Duration newDuration = new Duration(100);  //duration is set in ms, so this is 1/10 of a second
  Duration oldDuration = repo.MyApplication.MyObjectInfo.SearchTimeout; //temporarily saves the old timeout

  repo.MyApplication.MyObjectInfo.SearchTimeout = newDuration;

  if (!repo.MyApplication.MyObjectInfo.Exists()) {  //you can take out the "!" if you need to check for existance
    //do your stuff here
  }

  repo.MyApplication.MyObjectInfo.SearchTimeout = oldDuration; //reset the original duration here
}
You could make your own method in Program.cs (or in a library) that does the duration stuff for each object you pass it, but it might be more difficult than just adding these few lines to your UserCode.cs files.


EDIT TO ADD: Also, you may need to set the search timeout for each parent object. So, for my example, you might want to add another set of lines for setting the duration for MyApplication as well.

Note that folder object search timeouts are set in a different property than standard repo object search timeouts.