I've already looked here을 통한 트랜잭션 및 트랜잭션 관리에 대한 유용한 정보가 있습니다.DAL 작업 + 웹 서비스 호출 + 로깅
제 문제는 최소한 하나의 경우 웹 서비스를 호출하고 데이터베이스 테이블에 로깅하는 것입니다. 거기
customer = batchRefundToProcess.RefundCustomer;
//Validate everything
if (ValidateRefund(batchRefundToProcess) == false)
{
refund.RefundStatusId = (int)REFUNDSTATUSES.RefundDenied;
refund.ReviewedBy = displayUserName;
refund.Update();
return false;
}
//get this customer's payments
List<RefundTran> trans = customer.ARTransactions;
refund.RefundStatusId = (int)REFUNDSTATUSES.RefundInProcess;
refund.ReviewDate = DateTime.Now;
refund.ReviewedBy = displayUserName;
refund.Update();
List<RefundTran> paperTransactions = new List<RefundTran>();
foreach (RefundTran transaction in trans)
{
if (customer.Balance < 0) //balance is negative if we owe them money
{
//processtransaction has the following side effects:
//1. refund detail is created for the tran
//2. customer is billed for the refunded amount, web service is called
var paperTransaction = processTransaction(customer, transaction, refund);
if (paperTransaction != null) //this transaction qualifies for a paper check for one reason or another
{
paperTransactions.Add(paperTransaction);
}
}
}
//get total amount
//basically, the sum total of all their paper check transactions plus whatever's left on their balance, if anything
decimal paperCheckAmount = paperTransactions.Sum(pt => pt.Amount) - customer.Balance;
if (paperTransactions.Count > 0)
{
//cut a check for all the transactions together
AddLineToFile(customer, paperCheckAmount, paperTransactions.First(), REFUNDFILETYPE.ElectronicCheck, refund.RefundId);
}
refund.RefundStatusId = (int)REFUNDSTATUSES.RefundApproved;
refund.ReviewedBy = displayUserName;
refund.Update();
} //end using block
return true;
있습니다 웹 서비스 호출 및 일부 데이터베이스 로그 : 여기에 일을 더 명확하게 도움이 될 몇 가지 사이비 코드입니다. 나는 외부 공급 업체에게 webservice 호출을 "실행 취소"하는 마법 같은 방법이 없다는 것을 알고 있습니다.하지만 실패 할 경우 데이터베이스 로깅이 트랜잭션과 함께 롤백되지 않게하려면 어떻게해야합니까? 이미 웹 서비스 호출을 한 경우 어떻게해야합니까? 이걸 너무 힘들게 만드는거야? 고객에게 청구서를 내고 수표를 자르는 데 실패하거나 악화 (조직의 의견으로는)하지 않고 수표를 자르고 계정을 청구하지 않습니다.