tags:

views:

216

answers:

2

After evaluating off-the-shelf products (MSBRE, Drools etc) we are writing our own rules engine (this decision has been made, please don't suggest other rules engines - but parts of them that will do the specifics I want are most welcome).

What I would like is to give the users a simple GUI that would allow them to take one of our domain "object"s and make a rule in the GUI that can be translated to Xml or (ideally) .net code.

So, for example the user might choose a StaffDuty, and wants to say "If the staff member is in the Management Group and today's Duty is longer than 8 hours make sure tomorrow's sign on time is after 08:00". The StaffDuty object will have Groups, DutyTime and NextDuty properties and the NextDuty will be a type that has a SignOn property.

I want to be able to display that somewhat graphically with the user "filling in the bits" then saving it so that we can then turn that into code (perhaps via interpreting xml).

I've left this fairly open to interpretation as I want to not exclude anything at this point by being more specific.

Any ideas appreciated!

A: 

I did this a while ago for a large government business rules engine.

Using XML schema to describe the data, I used XML schema annotations to add in all of the rules engine specific bits, ensuring that the schema remained valid.

The GUI provided a traditional Explorer-style view with a treeview showing the structure and the right-hand pane displaying the detail for the selected tree node.

I used some fairly complex XSLT (with some custom extensions) to generate a small XML document representing a form and a small engine that would render the controls dynamically from that form definition.

The code behind the form updates an XML fragment which is then translated back into an XML diffgram by another piece of XSLT and used to update the in-memory representation of the schema.

Once the annotated XML schema was built, a compiler then generated two .NET assemblies, one containing a code representation of the schema and the other the implementation of the business rules.

It was a fairly complex piece of code, but one that was very flexible and dynamic and the vast majority of the UI could be customised through XSLT alone. Indeed, some users required different views which were handled entirely through an additional dynamically loaded assembly that included the XSLT.

Cost around 2.5M GBP and took over two years to develop, mind (the whole thing, not just the UI). It remains the development that I've been most proud of in my 28 years in the business!

Happy to discuss further if you want.

Steve Morgan
Sounds awesome Steve but I'm hoping for a simpler solution (fingers crossed!). Thanks!
Mark
+1  A: 

Take a look at the rules and expressions designers of the rules engine in Windows Workflow Foundation. They are both meant to be hostable outside of Visual Studio. In particular, I saw an example where the rules designer was passed a given type as its context, and was able to create rules and expressions based on the properties of that type and those of the types referenced by those properties. In fact, it was possible to pass it a type at the root of an object graph, and the engine could then work with the properties of all the objects in the graph.

John Saunders
Thanks John I will look at this again. One of my problems I had with this Rules Engine was that I thought I *couldn't* walk the object graph. In my case I wanted to set a condition like StaffDuty.NextDuty.StartTime < 08:00. But becuse NextDuty was a complex type I couldn't do it. Perhaps I was mistaken.
Mark