2011-09-10 22 views
1

それぞれがNativeActivityから派生したカスタムアクティビティ(コードビハインドで書かれています、C#)のリストで、今ではこれらのアクティビティをすべてforeachループの助けを借りてシーケンスに追加しています。 今、問題は、あるアクティビティからいくつかの値を取得し、それを別のアクティビティに渡す必要がある場合、どのように進めるべきかです。ワークフローアクティビティ間でデータを共有

アクティビティ1は、文字列プロパティの値を "some file name"(画像ファイルのパスを許可する)に設定し、それに基づいて、forループの助けを借りてシーケンスに追加されたアクティビティそのイメージを反転するための入力として使用します。

ファイルを取得するロジックは、activity1のExecuteメソッドであり、activity2のExecuteメソッドでイメージを反転するロジックです。事前に

おかげ

+0

この質問は理にかなっていません。 NativeActivityから拡張されたアクティビティを作成するのに十分な知識があれば、イン/アウト引数、変数、さらにはワークフロー拡張機能の仕組みを把握できるはずです。 – Will

+0

ヘイウィル、その感覚についてではなく、私はここでそれを妨げている、それはなぜあなたの言葉では、質問に尋ねたthats無意味ですが、私にとっては、何かが不足している可能性があります..あなたがそれに対して賢明な答え、私に教えてください、それは私のために役立つだろうかもしれません。 あなたの助けを借りて自分の考えに単語を追加できます。 –

+0

次に、activity1の控除をワークフローの変数にバインドし、次に、activity2の控除を同じ変数にバインドします。 – Will

答えて

2
...
 var workflow = new Sequence();   
     Variable<Dictionary<string,object>> variable = new Variable<Dictionary<string,object>> 
     { 
      Name = "SharedData" 
     }; 
     workflow.Variables.Add(variable); 
     foreach (MyCustomActivity activity in mAddedActivities) 
     {     
      workflow.Activities.Add(activity);          
     } 

     WorkflowInvoker invoker = new WorkflowInvoker(workflow); 
     invoker.Invoke(); 

私はその右のアプローチとして、わからないんだけど、何かが!!ウィル私を提案し、ここでActivityResultは、インターフェイスのメンバーのいくつかの並べ替えを経て、様々な追加の活動の間で共有されるプロパティです実際のインプリメンテーションのためには、任意の記帳/控除は必要ありません。変数「共有データ」は、複数のアクティビティ間でデータを保持するのに十分です。

オーバーライドされたコードアクティビティ "Execute"メソッドの各アクティビティレベルで、このワークフロー変数 "SharedData"の値をフェッチするためにコードの抜粋を使用する必要があります。

 WorkflowDataContext dataContext = context.DataContext; 
     PropertyDescriptorCollection propertyDescriptorCollection = dataContext.GetProperties(); 
     foreach (PropertyDescriptor propertyDesc in propertyDescriptorCollection) 
     { 
      if (propertyDesc.Name == "SharedData") 
      { 
       myData = propertyDesc.GetValue(dataContext) as Dictionary<string, object>; 
       if (myData == null) //this to check if its the initial(1st) activity. 
        myData = new Dictionary<string, object>(); 
       //I'm adding here an additional value into the workflow variable 
       //its having signature same as that of workflow variable 
       //dictionary's key as what it is and value as an object 
       //which user can cast to what actually one wants. 
       myData.Add("islogonrequired", Boolean.TrueString); 


       //here I'm fetching some value, as i entered it in my previous activity. 
       string filePath = myData["filepath"].ToString(); 
       propertyDesc.SetValue(dataContext, myData); 
       break; 
      } 
     } 

希望これは...彼らの助けのnサポートのため おかげでそこに誰もが他人を助けるかもしれません。

0
 var workflow = new Sequence(); 
     //Variable<string> v = new Variable<string> 
     //{ 
     // Name = "str" 
     //}; 

     //workflow.Variables.Add(v); 

     Dictionary<string, object> abc = new Dictionary<string, object>(); 
     abc.Add("thedata", "myValue"); 

     foreach (MyCustomActivity activity in mAddedActivities) 
     { 
      if (activity.ActivityResult == null) 
       activity.ActivityResult = new Dictionary<string, object>(); 
      activity.ActivityResult = abc;     
      workflow.Activities.Add(activity); 

      //new Assign<string> 
      //   { 
      //    To = v, 
      //    Value = activity.ActivityResult["thedata"].ToString() 
      //   };     

     } 
     WorkflowInvoker invoker = new WorkflowInvoker(workflow); 
     invoker.Invoke(); 

が、これは私がやったことで、何とかそれが働いています。これは私がやったことある

+0

@will ::ご連絡ください。 –

+0

これで私を助けることができる人.. –

関連する問題