我是 WorkFlow 4 (WF 4) 的初学者,我在 MVC 3 中使用它时遇到了一个严重的问题,我在网上找不到答案。
如果工作流中发生异常或输出参数中返回任何内容,我需要显示弹出消息,我有一个用户可以编辑的页面,最后他将单击“保存”按钮。
单击“保存”按钮会将表单提交给控制器并运行工作流,当工作流完成时,我得到一个输出,说明通过工作流更新数据是否成功,然后我需要在完成操作时显示此状态,但我我无法做到,因为我异步运行它,这意味着该方法将返回给用户,同时工作流正在调用该事件。
这是我在控制器中的代码:
[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);
}
工作流程完成后如何将内容发送回用户?
提前致谢。