Application: TransactionControl
Revit Platform: All
Revit Version: 2010.0
First Released For: 2008.0
Last Modified: 02/26/2008
Modified By: RZ Autodesk
Programming Language: C#
Skill Level: Medium
Category: Basics
Type: ExternalCommand

Subject: How to deal with transaction.
Summary: 
This sample demonstrates how to use transaction control.

Classes: 
Autodesk.Revit.Document

Project Files: 
Command.cs
It contains the class Command which implements interface IExternalCommand. This is the entry of this external command.

TransactionForm.cs
It contains the class TransactionForm which has three buttons to begin, end or abort a transaction. The other three buttons are used to create, move or delete a wall. The tree view is used to display all operations and transactions above and their relationship.

CreateWallForm.cs
It contains the class CreateWallForm which is used to create a wall. There is a combo box and several text boxes in this form to set parameters used to create wall.

Description: 
Functionalities:
-	Three buttons in a group box provide following operations: beginning a transaction, ending a transaction, aborting a transaction. 
-	Three buttons in another group box provide following operations: creating a wall, moving a wall, deleting a wall. 
-	Provide a tree view to display transactions, operations and the relationship between them. 
-	Allow user to use nested transactions. User can do one or more of the operations listed above during a transaction.
-	When user clicks “Ok” and there are some transactions which are not over, show a message box to ask user whether to end all transactions.

Implements:
-	Methods “BeginTransaction”, “EndTransaction” and “AbortTransaction” of class “Autodesk.Revit.Document” can deal with transaction.
-	Method “NewWall” of class “Autodesk.Revit.Creation.Document”, methods “Move” and “Delete” of class “Autodesk.Revit.Document” can be used to create, move or delete a wall.
-	Tree node’s fore color represents different status, e.g. black means that a transaction is over using “EndTransaction” and gray means that a transaction is over using “AbortTransaction”.

Instructions: 
1.	Run this external command.
2.	A dialog will be shown. Do some operations, such as begin a transaction or create a wall, the tree view adds corresponding nodes to describe these operations and their relationship.
3.	When closing this dialog, if some transactions are not over, a message box is shown to ask whether to end all transactions.