是否可以将值注入到工作流程参数中?

发布于 2024-08-04 19:49:41 字数 108 浏览 7 评论 0原文

我有一个 .net 4.0 工作流程,我自己托管它(仅使用 WorkflowInstance.Run),当我重新水化工作流程时,我想初始化其一些内部参数,以便后续活动可以使用这些值... 我该怎么做呢?

I have a .net 4.0 Workflow, which I am hosting myself (just with WorkflowInstance.Run) and when I rehydrate the workflow I would like to initialize some of its internal arguments so that subsequent activities can use these values...
How might I go about doing this?

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

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

发布评论

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

评论(2

北斗星光 2024-08-11 19:49:41

使用参数(In/OutArgument)来定义工作流程(也是活动)的输入或输出..

这是示例语法..

Dictionary <string, object> input = new Dictionary <string, object> (); 
input.Add( "UserName" , userName); 
input.Add ( "UserName", userName); 
WorkflowInstance myInstance = new WorkflowInstance(
new WorkflowConsoleApplication2.Sequence1(),input); 

WorkflowInstance myInstance = new WorkflowInstance (
new WorkflowConsoleApplication2.Sequence1 (), input); 

在工作流程图中,定义输入参数,然后您将能够访问参数的值。

use Arguments (In/OutArgument) for defining input or output for the workflow (activities too)..

here is the sample syntax..

Dictionary <string, object> input = new Dictionary <string, object> (); 
input.Add( "UserName" , userName); 
input.Add ( "UserName", userName); 
WorkflowInstance myInstance = new WorkflowInstance(
new WorkflowConsoleApplication2.Sequence1(),input); 

WorkflowInstance myInstance = new WorkflowInstance (
new WorkflowConsoleApplication2.Sequence1 (), input); 

in your workflow map, define the input argument and then you will be able to access the value of argument.

厌倦 2024-08-11 19:49:41

通常,参数用于在第一次开始执行工作流程之前提供给您的工作流程。

例如,您可能有 InArgument 输入 1、InArgument 输入 2、OutArugment 输出,当您创建工作流时,您会传入所有输入,并为工作流提供一个用于存储所有输出的变量。

工作流运行后,它会有争论,它并不期望它们会因某些外部因素而改变。 (如果这是一个混淆点:它通常也不会在工作流程开始时恢复执行 - 它会在中间的某个任意书签处恢复。)那么您还能如何将数据传递到工作流程中在执行中期?

在这里我建议查看消息传递活动。数据通过 ReceiveMessage 的 Value OutArgument“进入”工作流程。它是怎么到达那里的?它是由接收活动设置的。但是接收活动是如何让它设置它的呢?好吧,首先服务主机告诉接收活动恢复,因为它有一条消息。然后接收活动会说“我收到了什么消息?”没有人神奇地将数据推送到其中,而是在活动激活后,它知道从某个队列中提取数据。

希望你能使用这个想法
1)有人存储工作流程所需的数据
2) 运行时或服务主机或任何重新激活工作流的东西
3) 活动在运行时提取所需的数据(重新激活后)
作为您的解决方案的模型。

Normally Arguments are for providing to your workflow before you start executing the workflow the first time.

For example, you might have InArgument input1, InArgument input2, OutArugment output, and when you create the workflow you pass in all the inputs, and a variable for the workflow to store all of the outputs in.

Once the workflow is already running, it has arguments, it's not expecting them to change from some external factor. (And in case this is a point of confusion: it's not normally going to resume execution at the start of your workflow either - it's going to resume at some arbitrary bookmark in the middle.) So how else could you pass data in to your workflow in mid execution?

Here I suggest look at the messaging activities. Data comes 'in' to the workflow on the Value OutArgument of ReceiveMessage. How did it get there? It was set by the Receive activity. But how did the receive activity get it to set it? Well, first the service host tells the receive activity to resume because it has a message. Then the receive activity says 'what message did I get?' Nobody magically pushed data into it, instead after the activity is activated, it knows to pull data from a queue somewhere.

Hopefully you could use this idea of
1) someone stores the data needed by the workflow
2) the runtime or the service host or whatever reactivates the workflow
3) activities pull in the data they need when they run (after reactivation)
as a model for your solution.

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