2
我有一堆使用Web服務和交談,我想添加一些錯誤處理數據庫的工作流基礎4.0 RC碼活動。工作流4.0的代碼活動調用其他activites(持續,延遲等)
我真的希望能夠嘗試調用我的Web服務/ db,捕獲任何錯誤,如通信故障,然後在1小時內(在記錄異常之後)重試相同的操作。
有沒有辦法做這樣的事情?
protected override void Execute(CodeActivityContext context) {
Persist(); // I would like to invoke the persist activity like this
if (!AttemptServiceCall()) {
// I would like to invoke a delay activity like this
Delay(new TimeSpan(0, 30, 0)); // wait 30 mins before trying again
Execute(context); // call this activity again
}
}
private bool AttemptServiceCall() {
bool serviceCallSuccessful = true;
try {
myService.InvokeSomeMethod();
}
catch (CommunicationException ex) {
myEventLogger.Log(ex);
serviceCallSuccessful = false;
}
return serviceCallSuccessful;
}
謝謝你的迅速回答莫里斯 - 你是工作流程的王! – Lygpt 2010-03-23 16:26:01