2015-08-28 20 views
0
 //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); 
       } 
    } 

工作流的參數內值不爲null,但在同一工作流中的代碼活動中的值相同爲null。我想知道如何將工作流參數的值傳遞給代碼活動屬性。如何將Windows工作流的In參數參數傳遞給自定義代碼活動屬性?

回答

0

傳遞給Invoke的參數作爲參數傳遞給工作流,但它們不會自動緩衝到工作流中的活動。

在工作流定義中,您必須定義想要傳遞給工作流的參數,並且必須將toFolder和fromFolder參數顯式映射到活動的toFolder和fromFolder屬性。

請注意,參數和屬性的名稱不必匹配,使它們匹配並不意味着什麼。

+0

非常感謝。現在它的工作正常。 – varkhedi

相關問題