开发者

How to create a rule based feature (like in Outlook) with C#

开发者 https://www.devze.com 2023-01-12 17:28 出处:网络
I want to develop a feature for an application, that make it possible to create dynamic rules like you can do it in Outlook. I want that every user can create rules to automatize precesses. Those rule

I want to develop a feature for an application, that make it possible to create dynamic rules like you can do it in Outlook. I want that every user can create rules to automatize precesses. Those rules must do something before an action, after an action and to a开发者_高级运维 certain time/day.

Possible rules can be like:

- If process >= 99% -> Set it as finished

- Before a user insert a new Item -> Send a mail to "local@localhost.com" and wait for the approval

- After a user change the state of an item -> Change the state of all items with the equals name

- Set every sunday on 4:00am the state of all items to the state "old items"

I try to do this with the Workflow Foundation rules engine but I don't know how can I realize all requirements.

Is it possible to do this with WF or should I use another tool?


I once designed such system using pure OOP. Rule consists of one or more conditions and one or more actions. Each condition type and action type are classes. Condition classes know how to check external world. Action classes know how they are "executed", i.e. what should be done to take an action. Each class knows how to represent itself visually (for visual rule designer).

If you want simple conditions to be joined by only AND or OR operation, then you can set this operation in rule properties. If you want more complex condition representation, I'd suggest using some boolean evaluator engine and represent each rule in the condition text as it's ID. Eg. "(RuleA_ID AND RuleB_ID) OR RuleC_ID".


Opensource Rule Engines. You can use them or look at their source codes for inspiration. Rule Engines

0

精彩评论

暂无评论...
验证码 换一张
取 消