如何从自定义代码活动访问全局变量?
刚刚开始接触 WF4。
将一些文本从本机代码活动(位于顺序工作流程的中间)传递到序列中的下一个(基于 xaml 的)活动时遇到了问题。
以下是一个快速概要:自定义本机代码活动进行数据库调用,并需要将结果传递给标准“SendReplyToRecive”活动(这是此工作流程中的最后一个活动)。在顶级序列级别定义了一个全局变量“reportValue”,但我很难从该自定义本机代码活动中获取它。
此工作流程的设计界面不提供参数,仅提供变量和导入,因此,我什至不确定是否可以使用 OutArgument。
这是怎么做到的?
Just getting started with WF4.
Ran into a problem with passing some text from a native code activity (located in the middle of a sequential workflow) onto the next (xaml-based) activity in a sequence.
Here is a quick synopsis: a custom native code activity makes a DB call and needs to pass the result to a standard "SendReplyToRecive" activity (which is the last activity in this workflow). There is a global variable "reportValue" defined at the top-level sequence level, but I'm struggling to get to it from within that custom native code activity.
The design surface for this workflow does not offer Arguments, just Variables and Imports, so, I'm not even sure if I could use OutArgument.
How is this done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的自定义 NativeActivity 被定义为返回一个值,如下所示:
您现在应该能够通过设计器使用 Result 属性将返回值设置为变量。
编辑:
检查此示例图像。在 MyCustomNativeActivity 中,您将拥有一个可用的 Result 属性。要将返回的值分配给变量,只需初始化该变量并将其放入“结果”字段中。
从那时起,您可以在任何您想要的地方使用该变量。
请注意,在示例 MyCustomNativeActivity 中,返回值是 Int32,但它可以是任何其他类型。
图片链接
If your custom NativeActivity is defined to return a value, like this:
You should now be able to set the returned value to a Variable using Result property through the designer.
EDIT:
Check this sample image. In your MyCustomNativeActivity you'll have available a Result property. To assign the value returned to a variable just initialize that variable and put it in the Result field.
From that point on you can use that variable wherever you want.
Notice that in the sample MyCustomNativeActivity the returned value is an Int32 but it can be any other type.
Image link here