如何使用 C# 创建基于规则的功能(如 Outlook 中)

发布于 2024-09-15 23:19:43 字数 500 浏览 1 评论 0原文

我想为应用程序开发一项功能,可以像在 Outlook 中一样创建动态规则。我希望每个用户都可以创建规则来自动化流程。这些规则必须在操作之前、操作之后以及特定时间/日期执行某些操作。

可能的规则可以是这样的:
- 如果进程>= 99% ->设置为完成
- 在用户插入新项目之前 ->发送邮件至“[email protected]”并等待批准< br> - 用户更改项目状态后 ->更改具有相同名称的所有项目的状态
- 每个星期日凌晨 4:00 将所有项目的状态设置为“旧项目”状态

我尝试使用 Workflow Foundation 规则引擎执行此操作,但我不知道如何实现所有要求。
是否可以使用 WF 来完成此操作,还是应该使用其他工具?

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 "[email protected]" 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

待"谢繁草 2024-09-22 23:19:43

我曾经使用纯OOP设计过这样的系统。规则由一个或多个条件和一个或多个操作组成。每个条件类型和操作类型都是类。条件类知道如何检查外部世界。动作类知道它们是如何“执行”的,即应该做什么来采取动作。每个类都知道如何在视觉上表示自己(对于视觉规则设计者)。

如果您希望简单的条件仅通过 AND 或 OR 运算连接,那么您可以在规则属性中设置此运算。如果您想要更复杂的条件表示,我建议使用一些布尔求值器引擎并将条件文本中的每个规则表示为其 ID。例如。 “(规则 A_ID 和规则 B_ID)或规则 C_ID”。

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".

和我恋爱吧 2024-09-22 23:19:43

开源规则引擎。您可以使用它们或查看它们的源代码来获取灵感。
规则引擎

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文