Windows 工作流程 动态、用户创建的工作流程

发布于 2024-08-08 02:13:04 字数 347 浏览 3 评论 0原文

我有一位客户有兴趣在 Web 驱动中利用 Windows Workflow Foundation (WF) 技术应用。我是一名 .NET 开发人员,但我没有 WF 或 SharePoint 工作流的经验。客户想要做的大部分事情似乎都很简单,只是他们希望最终用户能够创建/编辑自己的自定义工作流程。在我对 WF 的简短研究中,这似乎并不是典型的做事方式。允许用户自己创建工作流是否可行,或者这确实应该是自定义 ASP.NET MVC 应用程序,或者可能是 SharePoint 应用程序?

I have a client who's interested in utilizing Windows Workflow Foundation (WF) technology in a web-driven application. I'm a .NET developer, but I have no experience with either WF or SharePoint workflows. Most of what the client wants to do seems to be straight-forward except that they want the ability for end users to be able to create/edit their own custom workflows. In my brief research into WF, it doesn't seem like this is how things are done typically. Is it feasible to allow users to create workflows themselves, or should this really be a custom ASP.NET MVC application, or maybe a SharePoint application?

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

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

发布评论

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

评论(3

救星 2024-08-15 02:13:04

让用户能够更改工作流程应该是 WF 的优点之一。然而,对于 WF 3,整个模型非常适合代码生成而不是标记,因此很难做到。并非不可能,因为您可以使用纯标记工作流程,但这很难。

对于 WF 4,情况应该会好得多,因为所有工作流程都是纯标记,并且根本不涉及任何代码。所有代码都在预定义的活动中,这些活动被编译,用户可以根据需要更改工作流程。此外,WF 设计器更容易在您自己的应用程序中重新托管。

PS SharePoint 工作流是 WF 3 工作流,即使在新的 SharePoint 版本中也是如此,而 WF 4 是一个全新的产品,不共享任何代码。

Having users be able to change workflows is supposed to be one of the stron points of WF. However with WF 3 the whole model is geared very much to code generation and not markup so it is hard to do. Not impossible as you can use pure markup workflows but it is hard.

With WF 4 the story is supposed to be much better as all workflows are pure markup and there is no code involved at all. All code is in predefined activities, which are compiled, and the user can change the workflows as needed. Also the WF designer is much easier to rehost in your own application.

PS SharePoint workflows are WF 3 workflows, even in the new SharePoint version, and WF 4 is a completely new product that shares no code whatsoever.

鸵鸟症 2024-08-15 02:13:04

您可能想要构建一个可以接受用户触发器的状态机。 Nicholas Blumhardt 有一个非常出色的轻量级状态机实现,称为无状态。您可以使用简单的语句创建状态机:

var stateMachine = new StateMachine<TState, TTrigger>();

从项目站点:

var phoneCall = new StateMachine<State, Trigger>(State.OffHook);

phoneCall.Configure(State.OffHook)
    .Permit(Trigger.CallDialed, State.Ringing);

phoneCall.Configure(State.Ringing)
    .Permit(Trigger.HungUp, State.OffHook)
    .Permit(Trigger.CallConnected, State.Connected);

phoneCall.Configure(State.Connected)
    .OnEntry(() => StartCallTimer())
    .OnExit(() => StopCallTimer())
    .Permit(Trigger.LeftMessage, State.OffHook)
    .Permit(Trigger.HungUp, State.OffHook)
    .Permit(Trigger.PlacedOnHold, State.OnHold);

// ...

phoneCall.Fire(Trigger.CallDialled);
Assert.AreEqual(State.Ringing, phoneCall.State);

如您所见,代码非常简单。您可以通过一个项目完成所需的一切。

由于状态和触发器可以是任何类型,因此您可以从数据库(可能是步骤表)向状态机提供数据,并允许 Approve=1、Reject=2 的触发器。您可以提前与用户创建一系列步骤,并允许他们通过呈现一个步骤来选择触发器,然后允许他们根据他们选择的触发器分配下一步。

You may want to bulid a state machine that can accept triggers from the users. Nicholas Blumhardt has a really great, lightweight state machine implementation called stateless. You can create a state machine with a simple statement:

var stateMachine = new StateMachine<TState, TTrigger>();

From the project site:

var phoneCall = new StateMachine<State, Trigger>(State.OffHook);

phoneCall.Configure(State.OffHook)
    .Permit(Trigger.CallDialed, State.Ringing);

phoneCall.Configure(State.Ringing)
    .Permit(Trigger.HungUp, State.OffHook)
    .Permit(Trigger.CallConnected, State.Connected);

phoneCall.Configure(State.Connected)
    .OnEntry(() => StartCallTimer())
    .OnExit(() => StopCallTimer())
    .Permit(Trigger.LeftMessage, State.OffHook)
    .Permit(Trigger.HungUp, State.OffHook)
    .Permit(Trigger.PlacedOnHold, State.OnHold);

// ...

phoneCall.Fire(Trigger.CallDialled);
Assert.AreEqual(State.Ringing, phoneCall.State);

As you can see the code is pretty straight forward. You can accomplish all that you need with a single project.

Since the State and Trigger can be of any type, you can feed the state machine from a database, maybe a Step table, and allow for the triggers of Approve=1, Reject=2. You could create a series of steps ahead of time with the users and allow them to select the triggers by presenting with a step, then allowing them to assign the next step based on the trigger they pick.

心病无药医 2024-08-15 02:13:04

在使用 WF(包括 4.0 在内的任何版本)之前,我会仔细检查向后兼容性/版本控制,特别是如果您将有长时间运行的工作流程。

一旦工作流实例“运行中”,对组件(代码活动)进行更改可能会很困难。我见过几种版本控制方法来解决这个问题,但您可能会发现在现实中这两种方法都不实用。

The thing I would be careful to check out before going with WF (any version including 4.0) is backward compatability/versioning, particularly if you will have long running workflows.

Making changes to the components (code activities) once you have workflow instances "in flight" can be difficult. There are a couple of approaches to versioning I have seen to deal with this problem but you may find neither are really practical in reality.

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