简体   繁体   中英

Customised business rules per customer…(asp.net mvc)

In a web application i'm working on, items can pass through multiple states (eg. workflow) and after each workflow a rule can be run after each step which can stop the process or display additional messages.

How should these rules be defined? I was thinking about a dll per rule (and hooking them up either with MEF or events) but one application could have 200-300 customers in it each with a few rules which becomes a lot of dlls.

Update:
These rules could be like the following. Say you submit an invoice but you only want to authorize it from your approver if its over a certain amount, then a rule like this would be invoked to return true or false and then proceed accordingly.

Cheers.

Sounds like an application that might benefit from using business rules written in a dynamic language like Ruby or Python. IronPython integrates nicely with applications written in C# or VB.NET. You could create a DLR ScriptEngine and ScriptScope in your web application, inject rules written in the dynamic language based on a client ID parameter to interact with your live Plain Old .NET Objects (PONO). You could keep your hundreds of rules in a database because they are just text (Python source code for example). Check out this blog post I wrote which shows how to inject dynamic business rules into a .NET application.

这可能是.Net Workflow Foundation的一个很好的候选者

Assuming your workflow engine is database driven, you can distinguish your workflow definition by adding a company id field. You will have to implement this in everywhere workflow is involved, checking what company id it is, and load workflow accordingly. You will also have to create the workflow for each company id separately.

This sounds tedious, but it is actually quite simple and easy to get right.

Then you can further define which user uses which company id. Or if you are certain each user will use different workflow packages, you can use user id instead of the intermediary company id.

I have found stuff linked from this post to be an interesting read on multi-customer systems:

http://ayende.com/Blog/archive/2008/08/13/Mutli-Tenancy--multi-tenant-apps-and-frameworks.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM