Xiao Han
Xiao Han

Reputation: 1024

BizTalk Business Rule Engine Compare DateTimeNow within a range of dates?

I try to use Between predicate to compare the current datetime with a range of date time.

I reference mscorlib assembly and use get_Now() within DateTime class in the assembly to get DateTimeNow. I have problem to compare this current datetime with the range.

my condition is like:

It seems for some reason my DateTimeNow does not work. Anyone has any idea?

Upvotes: 1

Views: 1056

Answers (2)

Charles Young
Charles Young

Reputation: 159

There is an impedance mismatch between the way facts are logically modelled in the engine and the way objects are modelled in .NET code, and one effect of this is the problem of calling static methods. If you set the StaticSupport flag as described by Xiao Han, the engine changes its behaviour, treating static methods much as if they were built-in functions or predicates. By default, however, the engine treats static methods as behaviour of facts. Physically, a fact is an object in the working memory of the engine, and each fact has to be asserted to the engine before it's methods can be used. So, to call the static Now property getter on DateTime, you first have to assert a DateTime object to the engine. Of course, DateTime is a value type (structure), but that's OK because, when you execute a rule set, you assert a single fact as an Object or a collection of facts as an Object array. .NET will automatically box a DateTime (internally wrap it as an object) passed in this way.

It seems mad, I realise, having to assert an object to the engine in order to call a static method (or, in this case, a property getter, which is really a method, of course) on the type of that object. It would probably have been better if the engine had been built to treat static methods as built-ins by default. However, that was not the case. In addition, it would have been much better if Microsoft had implemented the StaticSupport flag at the level of individual rule sets, or even individual rules. Implementing it in the registry (machine-level), or alternatively configuring it in the .config file (application-level; use ) in this way can pose real problems because it can break rule sets that were written to use the opposite value of the flag.

Another point to bear in mind in that the Static Support can also be set to '2'. In this case, if you call a static method with no parameters, or if you call it with constant values only, and if you call it as a predicate in a condition or as an argument to another function, then the engine will evaluate the static member just once and cache the result.

Upvotes: 0

Xiao Han
Xiao Han

Reputation: 1024

I found to use Get_Date() function in .net mscorlib assembly, you have to modify your machine registry

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\BusinessRules\3.0\StaticSupport (DWORD), give value 1

Details in:

http://blogs.msdn.com/b/richardbpi/archive/2005/11/14/492489.aspx

http://kinnaribhute.blogspot.co.nz/2008/04/some-interesting-stuff-about-biztalk.html

I am not sure how this will affect the production server, if the production server environment is not clustered with multiple node, there will be an outage for reboot the server.

Upvotes: 2

Related Questions