哪种设计模式适合此工作流要求? [英] which design pattern is suitable for this workflow requirement?

查看:32
本文介绍了哪种设计模式适合此工作流要求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,我需要在屏幕上执行一组作业(每个作业可能需要几个小时才能执行),我需要制定一些规则来执行这些作业.可以用图形表示.

I have a requirement where in I have a set of jobs to be executed from the screen (each job could take hours to execute) and I need to put some rules in place to execute those jobs. it can be represented using a graph.

  1. 每个作业都有一个序列号,作业应按顺序执行
  2. 然而,有一组可以按任何顺序运行的作业,每个作业都可能有自己的路径.例如,一旦A和B完成,D,E,F可以以任何顺序运行,但是可以有这样的规则,例如G只能在D完成后才能运行,H只能在E完成后才能运行.
  3. 如果任何先前的并行作业成功,则可以运行某些作业.如果作业是 A、B、C、D 和 A、B、C,则可以按任意顺序运行,并且只有在 A 或 B 或 C 完成后才能运行 D.
  4. 某些作业只有在所有前面的并行作业都完成后才能运行.例如,在上面的例子中,如果 A、B 和 C 完成,则可以运行 D 之类的规则
  5. 有一些检查点,这意味着一旦检查点作业完成,之前的任何一项都不能重新运行,包括检查点作业.

不知何故,我需要能够针对可以在运行时评估的作业表达条件.像 E = (A and B) OR (C and D);这意味着如果 A 和 B 成功或 C 和 D 成功,则作业 E 可以运行.

somehow I need to be able to express a condition against a job which can be evaluated at runtime. something like E = (A and B) OR (C and D); which means job E can run if A and B are successful OR C and D are successful.

这几乎总结了不同类型的规则,我的问题是,是否有设计模式可以用来实现这一点?理想情况下,我想将此工作流保留在数据库中,并基于此验证是否允许运行作业.Windows 工作流程对此可能有点矫枉过正,我正在寻找更简单的解决方案,它可能不是最好的,但需要更少的时间.

that pretty much summarises different types of rules and my question is, Is there a design pattern that I can use to implement this? Ideally I would like to persist this workflow in database and validate whether a job is allowed to run or not based on that. the windows workflow might be an overkill for this and I am looking for simpler solution that may not be the best, but takes less time.

要使用的技术:ASP.NET 3.5、C# 3.0、SQL Server 2008

technology to be used: ASP.NET 3.5, C# 3.0, SQL Server 2008

推荐答案

我通过将这些作业依赖项以树格式存储在表中并使用递归函数对其进行评估来解决此问题.可能不是最好的,但它有效且可配置.

I solved this by storing these job dependencies in a table in a tree format and evaluating it using a recursive function. may not be the best, but it works and configurable.

这篇关于哪种设计模式适合此工作流要求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆