Application: CancelSave
Revit Platform: All
Revit Version: 2011.0
First Released For: 2010.0
Programming Language: C#
Skill Level: Beginning
Category: Basics
Type: ExternalApplication

Subject: Cancel document save process
Summary: 
This sample demonstrates how to cancel the document save process through DocumentSaving / DocumentSavingAs event’s arguments.

Classes: 
Autodesk.Revit.UI.IExternalApplication
Autodesk.Revit.ApplicationServices.ControlledApplication 
Autodesk.Revit.DB.ProjectInfo

Project Files: 
CancelSave.cs
This file contains one class CancelSave which implements IExternalApplication interface. And it checks “Project Status” value once user saves the project. If the value has been updated accept the save else cancel the save and inform user.

LogManager.cs
This file contains one class LogManager in which one log file will be created for tracking events raise.

Description: 
The “Project Status” in Project Information dialog must be updated once the project is saved, else cancel the save and inform user. This sample shows how to implement this through API event mechanism.
-	Through DocumentOpened and DocumentCreated events, this sample reserves original Project Status value once user finished opening or creating a project.
-	Through DocumentSaving and DocumentSavingAs, this sample compares current Project Status value with the original value. If they are same cancel the save and inform user by a messageBox else pass the save and update the original value to prepare for next save.

Instructions: 
1.	Open Revit.exe
2.	Create one project in Revit UI and then save it (because the project status wasn’t updated, the save will be cancelled).
3.	Run menu command Setting\Project Information, and then update project status in that dialog and click OK button to save the update.
4.	SaveAs this project (because the project status was updated, the save is allowed).

Note:
1.	Because Family document doesn’t support Project Information, this sample should not run on Family document.