简体   繁体   English

编写一个简单的工作流程系统

[英]Write a simple workflow system

As a part of our application I need to write "simple" workflow system which will be used for supporting document creation life-cycle. 作为我们应用程序的一部分,我需要编写“简单”工作流系统,该系统将用于支持文档创建生命周期。 It should support: - different activities: edit document, verify document (approve, reject), publish document... - assign this activities to different people/users - "parallel split and join". 它应支持:-不同的活动:编辑文档,验证文档(批准,拒绝),发布文档...-将这些活动分配给不同的人员/用户-“并行拆分和合并”。 For example I want to support workflow like this: 例如,我想支持这样的工作流程:

- begin
1.) Create document
2.) Translate document
2.1) Translate into English
2.1.1) Translate document into English
2.1.2) Verify English translation
2.2) Translate into Italian
2.2.1) Translate document into Italian
2.2.2) Verify Italian translation
3.) Verify complete document
4.) Publish document
- end

It will be used in an asp.net application (C#). 它将在asp.net应用程序(C#)中使用。

The final part: I would like to know if there is any pattern, library or article which would help me to get started with this task? 最后一部分:我想知道是否有任何模式,库或文章可以帮助我开始执行此任务? Would WWF be appropriate for this? 世界自然基金会对此是否合适?

There is some material (even on stackoverflow) but I don't know how to deal with the parallelism? 有一些资料(甚至在stackoverflow上),但是我不知道如何处理并行性?

A workflow engine is a deceptively simple concept. 工作流引擎是一个看似简单的概念。 Creating a robust, administerable implementation is much more works than it appears. 创建一个健壮的,可管理的实施工作比看起来要多得多。 Strongly favour off-the-shelf rather build it yourself. 强烈支持现成的,而不是自己构建。 WWF (Windows Workflow Foundation) looks to fit your needs. WWF(Windows Workflow Foundation)看起来很适合您的需求。

Play around with the WF Virtual Labs . WF虚拟实验室一起玩耍。 Once you get your hands on the technology, you will have a much better understanding if WF is appropriate or you should roll your own. 一旦掌握了该技术,便可以更好地了解WF是否合适或应该自己开发。 Also, you can check out K2 , but that is much more heavyweight. 另外,您可以签出K2 ,但这要重得多。

I would just use Windows Workflow for this it should be relatively easy to model the workflow, and you wont have to worry about issues you dont care about about, like keeping track of workflow state, and things like that, that are outside of your business domain problem. 我将只使用Windows Workflow,这样就可以相对容易地对工作流进行建模,并且您不必担心自己不在意的问题,例如跟踪工作流状态以及诸如此类的事情,这些事情不在您的业务范围内域问题。

http://msdn.microsoft.com/en-us/library/aa480214.aspx http://msdn.microsoft.com/en-us/library/aa480214.aspx

Few years back i had worked on a project that implemented a workflow system.It was a home grown solution as the database already existed.Basically we provided a web interface to a cocoa based solution. 几年前,我参与了一个实施工作流系统的项目,由于数据库已经存在,这是一个家庭开发的解决方案。基本上,我们为基于可可的解决方案提供了Web界面。

You can use an open source BPM solution ( i had seen JBPM for java, you can search a good ASP based open source solution).Mostly these solution are process based, in other words you define a process or workflow in an xml file.Each Approver is a node and next node in the tree comes into picture if only parent node has approved.You can get good documentation on this on the web. 您可以使用开源BPM解决方案(我见过Java的JBPM,您可以搜索一个基于ASP的优秀开源解决方案)。这些解决方案大多数都是基于流程的,换句话说,您在xml文件中定义了流程或工作流程。批准者是一个节点,如果只有父节点得到批准,树中的下一个节点就会出现。您可以在网络上获得良好的文档。

Also ASP would not be a problem.For your own solution, i would suggest create the database first.Basically you need a way to store a tree structure in the database.Parallel can be handled if two nodes have same parent, you can put an attribute like 'has_approved' and flow would progres further only if both the nodes have has_approved = 1. 同样ASP也不是问题。对于您自己的解决方案,我建议您先创建数据库。基本上,您需要一种在数据库中存储树结构的方法。如果两个节点具有相同的父节点,则可以并行处理,您可以放置​​一个仅当两个节点的has_approved = 1时,“ has_approved”和flow之类的属性才会进一步发展。

Its a broader topic , i hope i am clear in this post.Also if you take opensource BPM solution pick the one which is simplest, because you will have to make changes to the code to suit your particular solution. 我希望这是一个更广泛的主题,如果您采用开源BPM解决方案,请选择最简单的解决方案,因为您将不得不更改代码以适合您的特定解决方案。

While what you are asking is possible, there is nothing "simple" about rolling your own workflow host based on .NET 3.x workflow runtime. 尽管您的要求是可能的,但基于.NET 3.x工作流运行时滚动自己的工作流主机并没有“简单”。 Take this from someone who has done this. 从做过此事的人那里得到。 It will get much easier in .NET 4.0, so it is also worthwhile to consider that your solution will be obsolete in a few months. 在.NET 4.0中,它将变得更加容易,因此值得考虑的是,您的解决方案将在几个月后淘汰。

If your problem domain contains only document-based workflows, I strongly suggest that you consider a SharePoint solution instead. 如果您的问题域仅包含基于文档的工作流,强烈建议您考虑使用SharePoint解决方案。 Please see the following links for some information on this option: 请参阅以下链接以获取有关此选项的一些信息:

http://office.microsoft.com/en-us/sharepointdesigner/HA101005911033.aspx http://channel9.msdn.com/posts/RobertShelton/Building-an-Approval-Workflow-with-SharePointMOSS-2007-and-Visual-Studio-2008/ http://office.microsoft.com/zh-cn/sharepointdesigner/HA101005911033.aspx http://channel9.msdn.com/posts/RobertShelton/Building-an-Approval-Workflow-with-SharePointMOSS-2007-and-Visual -工作室-2008 /

It's not that difficult to implement. 实施起来并不难。 I found it simple enough it didn't need a huge packaged solution. 我发现它很简单,不需要庞大的打包解决方案。

You need to determine what items are to be monitored (documents). 您需要确定要监视哪些项目(文档)。 Then you need to determine what states (or statuses) those documents can be in. The statuses record what step a document is in your processing. 然后,您需要确定这些文档可以处于哪些状态(或多个状态)。这些状态记录了文档在处理中所处的步骤。 (Where it is in your "work flow"). (在您的“工作流程”中)。 You've already done that in your post. 您已经在帖子中做到了。

A state machine is an excellent pattern to handle movement of documents through various statuses: http://en.wikipedia.org/wiki/State_machine 状态机是一种出色的模式,可以处理各种状态下的文档移动: http : //en.wikipedia.org/wiki/State_machine

You still have to build a list of each state a document can be in and what happens to it to move it to a new state. 您仍然必须建立一个文档可能处于的每个状态的列表,以及将其移动到新状态时会发生什么情况。 You've done most of the work already. 您已经完成了大部分工作。 The code for your assignment shouldn't take more than a page or two. 您分配的代码不应超过一两页。

A sample implementation: 一个示例实现:

Assign each document a number so you can track it, and assign it a status that shows where it is in your process. 为每个文档分配一个编号,以便您可以对其进行跟踪,并为其分配一个状态,以显示该文档在处理中的位置。 Usually both of those are done with a number, but don't have to be. 通常,这两者都是用数字完成的,但不一定要这样做。

Something like this: 像这样:

public class document
{
  public int documentId;
  public String documentStatus;
}

// create a new document to track
document doc = new document();
doc.documentId = 42;       // arbitrary id#
doc.documentStatus = "1";  // document is at the start of the process

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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