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();
這是我做過什麼對於實際的實現來說,不需要任何公理/超越,變量「共享數據」具有足夠的能力來保存跨活動的數據。
現在,在重寫代碼活動「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載體。
這個問題沒有意義。如果您足夠了解創建從NativeActivity擴展的活動,則應該能夠弄清楚進/出參數,變量甚至工作流擴展的工作方式。 – Will
嘿威爾,它不是關於感覺,我在這裏阻礙,這就是爲什麼問這個問題,用你的話說,它可以是無知的,但對我來說,我可能會失去一些東西。如果你知道一些稱爲明智的答案,讓我知道,可能會對我有用。 你的幫助可以給我的想法添加詞語。 –
然後將activity1的外部參數綁定到工作流的變量,然後將activity2的參數綁定到同一個變量。 – Will