-1
我已經使用Microsoft wf示例項目:WF_WCF_Samples \ WF \ Application \ VisualWorkflowTracking \ CS 此示例項目運行wf4模擬。工作流程無法正常執行,但沒有發生異常
工作流程有一個輸入bool參數。
目前我有兩個問題。
第一個問題:
如果我輸入一個值參數(工作流設計器),我沒有當代碼運行,但模擬不執行得到任何異常。
我修改了代碼並嘗試獲取參數集合。然後我將它們添加到一個字典,然後傳遞給調用方法。這種方法不會給我任何錯誤,但它不會啓動這個過程。我認爲參數的價值沒有正確地傳遞給詞典。以下是代碼:
ThreadPool.QueueUserWorkItem(new WaitCallback((context) =>
{
bool noArguments = false;
var serviceManager = this.WorkflowDesigner.Context.Services;
Dictionary<string, object> retval = new Dictionary<string, object>();
var modelService = serviceManager.GetService<ModelService>();
var rootModelItem = modelService.Root;
var properties = rootModelItem.Properties["Properties"];
if (properties == null) noArguments = true;
var propertiesCollection = properties.Collection;
if (propertiesCollection == null) noArguments = true;
if (propertiesCollection.Count == 0) noArguments = true;
foreach (var p in propertiesCollection)
{
var d = p.GetCurrentValue() as DynamicActivityProperty;
if (d != null)
{
var name = d.Name;
dynamic inArgument = d.Value;
try
{
var val = inArgument.Expression.Value;
retval.Add(name, val);
}
catch (Exception er)
{
MessageBox.Show("Variable: " + d.Name + " Value is Empty", "Variable Error",MessageBoxButton.OK,MessageBoxImage.Error);
}
}
}
//Invoking the Workflow Instance with Input Arguments
if (noArguments)
{
instance.Invoke();
}
else
{
//this line below does raise any error but it does not run the process.
//instance.Invoke(retval, new TimeSpan(1, 0, 0));
//this line below works as long as in the workflow designer the argument value is left blank
instance.Invoke(new Dictionary<string, object> { { "decisionVar", "hello" } }, new TimeSpan(1, 0, 0));
}
//This is to remove the final debug adornment
this.Dispatcher.Invoke(DispatcherPriority.Render
, (Action)(() =>
{
this.WorkflowDesigner.DebugManagerView.CurrentLocation = new SourceLocation(this.WorkFlowFile,1,1,1,10);
//this.WorkflowDesigner.DebugManagerView.CurrentLocation = new SourceLocation("Workflow.xaml",1,1,1,10);
}));
}));
你好羅恩,感謝您花時間評論我的問題。 – user1239078 2012-03-02 11:38:05
羅恩,感謝您花時間評論我的問題。我在WCF和WF上下載了MS樣本。打開項目WF_WCF_Samples \ WF \ Application \ VisualWorkflowTracking \ CS VisualWorkflowTracking.sln執行F5,然後在調試過程中,在應用程序上單擊「文件」,然後「運行工作流程」....您將看到模擬運行。現在,試試這個:停止調試,在設計模式下打開工作流程,有一個名爲「desicionVar」的參數。在「默認值」中輸入一個值。真或假。再次運行它,您將看到仿真不運行 – user1239078 2012-03-02 12:04:06
在示例代碼中,「WorkflowDesignerHost.xaml.cs」文件中有一行將硬編碼值傳遞給默認值。 該行是: instance.Invoke(new Dictionary {{「decisionVar」,true}},new TimeSpan(1,0,0)); 我不明白爲什麼在工作流設計器中爲decisionVar參數輸入「默認值」後模擬不會運行? 編譯時或執行時看不到任何錯誤 希望能夠澄清我的問題。請讓我知道你是否可以複製我在這裏描述的內容。 –
user1239078
2012-03-02 12:09:40