复制器活动内的 InvokeWorkflow 活动
我在复制器活动中有一个调用工作流活动。 我尝试调用的工作流需要向其传递 2 个参数,一个整数和一个字符串参数,并且这些参数应由复制器活动传递给工作流。 关于如何做到这一点有什么想法吗?
谢谢。
I have an invokeworkflow activity inside a replicator activity. The workflow that I'm trying to invoke requires 2 parameters to be passed to it, an integer and a string parameters, and these should be passed to the workflow by the replicator activity. Any ideas on how this could be done?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个完整的示例(请注意,构造函数中包含的任何内容都可以在设计器的属性窗格中设置): Workflow3 是仅包含 CodeActivity 的目标工作流,后面的代码如下:
Workflow2 是托管工作流仅包含 ReplicatorActivity。 ReplicatorActivity 仅包含 InvokeWorkflowActivity,其 TargetWorkflow 设置为 Workflow3。 隐藏代码如下:
预期结果如下:
希望这会对您有所帮助。
Here is a full example (note that whatever is included in the constructors can be set in the properties pane of the designer): Workflow3 is the target workflow that contains only a CodeActivity and the behind code is the following:
Workflow2 is the hosting workflow that contains only a ReplicatorActivity. The ReplicatorActivity contains only a InvokeWorkflowActivity which has the TargetWorkflow set to Workflow3. The code-behind is the following:
The expected outcome is the following:
Hope that this will help you.
我意识到这篇文章已经过时了,但对于那些在 Google 上发现同样问题的人来说,这就是您需要做的:
然后,在 InvokeWorkflowActivity 中,将 TargetWorkflow 的属性映射到 InvokerActivity 上的依赖项属性,如 Panos 上面建议的那样。 注意:为了显示省略号,对象必须是具体类型。 如果您的对象是接口,您将无法映射它。 工作流不知道如何实例化接口对象。
ReplicatorActivity 公开了一个名为 ChildInitialized 的事件处理程序。 为此事件创建您的处理程序,您将在其中收到一个 ReplicatorChildEventArgs。 在其中,您可以通过事件参数接收 Activity,如下所示:
现在,当您运行它时,ReplicatorActivity 将为集合中的每个项目调用此方法一次,并将传递它将生成的每个 InvokerActivity 的参数。
e.InstanceData 将是 Replicator 迭代的集合中的下一个对象。
I realize this post is old, but for those finding this on Google with the same question, this is what you need to do:
Then in the InvokeWorkflowActivity, map the properties of the TargetWorkflow to the dependency properties on the InvokerActivity, as Panos suggests above. NOTE: in order for the ellipsis to show up the objects MUST be concrete types. If your object is an Interface you will not be able to map it. The workflow will not know how to instantiate an interface object.
The ReplicatorActivity exposes an event handler called ChildInitialized. Create your handler for this event and in it you will receive a ReplicatorChildEventArgs. In it, you can receive the Activity through the event args as such:
Now when you run it, the ReplicatorActivity will call this method once for every item in the collection and will pass along the parameters for each of the InvokerActivities it will spawn.
e.InstanceData will be the next object in the collection that the Replicator is iterating through.
您可以在目标工作流中声明两个属性,如下所示:
之后,如果您检查
InvokeWorkflowActivity
的“属性”选项卡,您将在Parameters
类别中看到这两个属性。您可以提供常量值,也可以将它们绑定到托管工作流程的任何属性。
You can declare two properties in the target workflow like this:
After that, if you check the Properties tab of the
InvokeWorkflowActivity
you will see the two properties in theParameters
category.You can either provide constant values or you can bind them to any property of the hosting workflow.