私は 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);
}
ワークフローの完了時に何かをユーザーに送り返すにはどうすればよいですか?
前もって感謝します。