views:

121

answers:

3

I have to perform 3 operations in a windows app as a Transaction. These are not SQL operation otherwise i'd have used TransactionScope. The first operation is to log some value in a db, 2nd is to move an e mail to a pst and 3rd one is to move email to another mailbox. If any if these operation fails,I want other operations to roll back to previous state. is there any way, this transaction could be achieved.

+1  A: 

Not unless your e-mail backend supports DTC, in which case you can use TransactionScope; note that TransactionScope is not limited just to SQL-providers; some middleware tools support it, and there is even a TransactionScope-based provided for .NET objects (not any object - only those written using the library's base-class / property-bag / etc).

As it stands, you'll probably have to roll back manually.

Marc Gravell
+1  A: 

You could roll your own ResourceManager and use System.Transactions to help you handle the transactions.

http://www.codeguru.com/csharp/.net/net_data/sortinganditerating/article.php/c10993__1/

Depending on the complexity though, and how often you'll need it, it might be an overly complex solution.

Steven Robbins
I was looking for a tutorial article on .NET System.Transactions, and finally found a link in this reply - thanks.
akavel
A: 

Doing a transaction "by the book" is easy if every single encompassed actions have proper transactional support, otherwise it would be a nightmare trying to support (commit/rollback) each of them individually in their own DIY ways :)
As Marc pointed out, doing it manually would be the simpler choice as it stands.

Heartless Angel