我是WorkFlow 4(WF 4)的初學者,我正在使用它在MVC 3中遇到嚴重問題,我在網上找不到答案。從控制器MVC完成WorkFlow 4後顯示一個彈出消息
我需要顯示一個彈出消息,如果在workFlow中發生異常或在outpput參數中返回的任何異常,我有一個用戶可以編輯的頁面,最後他將單擊Save按鈕。
點擊保存按鈕將表單提交到控制器並運行一個工作流,當工作流完成時,我得到一個輸出解釋是否通過工作流更新數據是否成功,然後我需要在完成時顯示此狀態行動,但我無法,因爲我異步運行它意味着該方法將返回給用戶,並行工作流正在調用該事件。
這是我在控制器代碼:
[HttpPost()]
public ActionResult SaveVehicles(vehiclesData model) {
Services.VehiclesDataUpdate vehiclesDataUpdate = new Services.VehiclesDataUpdate(this.SessionData.DealerLotKey, null, null);
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("VehiclesDataUpdate", vehiclesDataUpdate);
parameters.Add("UnionVehicles", unionVehicles);
parameters.Add("SolrVehicles", solrVehicles);
IDictionary<string, object> outputs = new Dictionary<string, object>();
AutoResetEvent syncEvent = new AutoResetEvent(false);
WorkflowApplication wfApp = new WorkflowApplication(new VehiclesUpdate(), parameters);
wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e) {
outputs = e.Outputs;
syncEvent.Set();
if (!errorExceptions.IsNullOrEmpty()) {
//TODO: Render a parital view to display an error message or the result of the workflow in the ouptput
//TODO: Logging.
}
};
wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs e) {
syncEvent.Set();
};
wfApp.Run();
return View(model);
}
我怎麼能送點東西回來時給用戶的工作流程完成?
在此先感謝。
[WorkflowInvoker](http://msdn.microsoft.com/en-us/library/system.activities.workflowinvoker.aspx)或使用[ManualResetEvent](http://msdn.microsoft.com/zh-cn/ us/library/system.threading.manualresetevent.aspx)向ASP.NET工作線程發信號通知工作流應用程序已完成執行。 – Will
你能提供一個例子嗎? –
這裏有很多。 Troll通過[wf4]並讀取。我不會回答,因爲我相信在ASP.NET中使用[異步頁面](http://msdn.microsoft.com/en-us/magazine/cc163725.aspx)可能會有更好的解決方案。問題在於我沒有足夠熟悉這個以便給出足夠的答案。 – Will