//adding parameters and invoking workflow but the properties inside the codeactivity is all
static void Main(string[] args)
{
Activity workflow1 = new Workflow1();//activity
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("toFolder", @"C:\BackupByWorkFlow");//param1
parameters.Add("fromFolder", @"C:\");//param2
WorkflowInvoker.Invoke(workflow1, parameters);//invoke
}
// workflow1 contains sequence of activities
// sequence->WhileBackup activity -> and other custom activities
//Custom code activity in workflow is as below
public sealed class WhileBackup : CodeActivity
{
// Defining properties
public InArgument<string> Text { get; set; }
public InArgument<string> toFolder { get; set; }//property is null
public InArgument<string> fromFolder { get; set; }//property is null
public int totalFiles { get; set; }
public int currentFile;
public FileInfo[] files;
// If your activity returns a value, derive from CodeActivity<TResult>
// and return the value from the Execute method.
protected override void Execute(CodeActivityContext context)
{
// Obtain the runtime value of the Text input argument
string text = context.GetValue(this.Text);
}
}
工作流的in-argument值不为null,但同一工作流中的代码活动中的相同值为null。因此我想知道如何将工作流的in参数的值传递给代码活动属性。
答案 0 :(得分:0)
传递给Invoke的参数作为参数传递给工作流,但是它们不会自动渗透到工作流中的活动。
在工作流定义中,您必须定义要传递给工作流的参数,并且必须将toFolder和fromFolder参数显式映射到活动的toFolder和fromFolder属性。
请注意,参数和属性的名称不必匹配,并使它们匹配并不意味着什么。