动态设置活动的属性 [英] Setting properties on an activity dynamically

查看:116
本文介绍了动态设置活动的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个活动,例如我工作流程中的emailActivity。但是,要在emailActivity上设置的那些属性的值是通过工作流中的代码活动获得的,例如转到数据存储以获取配置的详细信息以及收件人相关信息。

但是如果我在工作流类中编写此类代码(代码活动所在的位置)

< font size = 2> emailDocumentActivity1.AttachmentFile = outputFile;
emailDocumentActivity1.Body = " Please find附上汇款通知书以供你注意" ;

调用活动时,这些属性的值为null,我认为是因为工作流中的副本是模板,而不是执行时活动中的实际值。我不能使用依赖属性,即从一个活动绑定到另一个活动,因为这些值是在代码活动中获得的,并且为了具有其他活动可以绑定到E.g的属性的唯一目的而必须创建自定义活动似乎相当差。 DocumentDeliveryDataActivity。这个活动只是一个用于其他活动的占位符,但没有执行逻辑,看起来很差,肯定还有另一种方法可以动态获取活动中的值吗?

I have an activity e.g. emailActivity within my workflow. However the values of those properties to set on the emailActivity are obtained through a code actvity in the workflow e.g. going off to the data store to obtain the details for configuration and also recipient related information.
 
However if I write code such as this within the workflow class ( where the code activity lies )
 
emailDocumentActivity1.AttachmentFile = outputFile;
emailDocumentActivity1.Body =
"Please find attached a remittance advice for your attention";
 
When the activity is invoked the values of these properties are null which I presume is because the copy in the workflow is a template and not the actual value in the activity when executed.  I can't use dependency properties i.e. bound from one activity to another because these values are obtained in a code activity and it seems rather poor to have to create a custom activity for the sole purpose of having properties which other activities can bind to E.g. DocumentDeliveryDataActivity.  This activity would just be a placeholder to be used for other activities but would have no execution logic, that seems poor, surely there must be another way to get the value in the activity dynamically?

电子邮件活动是我编写的一个简单的自定义活动,它提供了您期望的所有属性,例如smtpserver,发送电子邮件到/来自

The email activity is a simple custom activity I've written which provides all the properties you'd expect e.g. smtpserver , email to / from

推荐答案

您好

正如您所猜测的那样,工作流程定义只是一个模板以及在此过程中涉及的内容工作流程执行完全取决于当时可用的内容。对于您的情况,您可以将数据推送到数据库并在自定义活动中读取数据库吗?
Hello

As you guessed, the workflow defn is just a template and what gets involved during a workflows execution is entirely as to what is available at that time. For your case, can you push the data on to a database and read the database in a custom activity?


这篇关于动态设置活动的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆