Version

RemoveActivity(Activity) Method

Deletes an existing Activity permanently from the database, and detaches it from any related Resource.
Syntax
'Declaration
 
Public Overloads Sub RemoveActivity( _
   ByVal activity As Activity _
) 
public void RemoveActivity( 
   Activity activity
)

Parameters

activity
An activity originating from the database that has a current, valid DataKey and is to be removed from the database.
Exceptions
ExceptionDescription
System.ArgumentExceptionThrown when the activity contains a null reference (or Nothing in Visual Basic .NET) for it's DataKey property. A non-null DataKey must be specified to identify an existing Activity row to delete from the data store.
System.ArgumentNullExceptionThrown when the activity was supplied as a null reference (or Nothing in Visual Basic .NET). An Activity must be non-null to specify a DataKey to delete.
System.ComponentModel.WarningExceptionThrown when the WebScheduleInfo property has not been properly initialized before calling RemoveActivity. In order for RemoveActivity to delete the supplied activity in the data store, the WebScheduleDataProviderBase must already be initialized with the same WebScheduleInfo as the activity was.
Remarks

WebSchedule automatically handles removal of an Activity when the end user clicks the 'Delete' button from within the Edit Appointment dialog of WebSchedule's user interface. Developers would call RemoveActivity to make additional deletions based on application-defined criteria. The act of removing an Activity from it's ActivitiesCollection is insufficient to commit this change to the data store. In order to persist such a change, the developer must pass the removed Activity to this method.

The RemoveActivity method also supports administrative tasks an application might perform on a WebSchedule data store: such as in a nightly batch responsible for deleting all appointments having an EndDateTime of more than a year in the past for the purpose of keeping the database size manageable.

The supplied activity must have a valid DataKey that can be used to identify it's current row in the Activity table. RemoveActivity then deletes that row from the Activity table based on the DataKey. It does not perform extra checking to confirm that the supplied Activity instance matches the row within the Activity table, field-for-field. The activity is permanently deleted, and cannot be recovered by ordinary means (see Note below).

Calling RemoveActivity only removes the Activity from the data store. The developer must exercise caution not to treat any copies of that Activity still contained in ActivitiesCollection (or other object references) as continuing to be valid. The safest practice for developers is to first remove any and all references to the Activity instance from collections his/her application may be using, and then to pass the instance to RemoveActivity for final removal from the data store so it does not return to the collections on a subsequent data-bind fetch operation.

When all Activities associated with an organizing Resource have been removed, this does not invalidate the Resource. By default, this Resource remains available to have additional activities scheduled for it. If the developer needs orphaned resources to be removed, then the application should call RemoveResource to finish cleaning up.

Developers are encouraged to deploy scheduling applications to an industrial-grade database management system (in this case, one that supports keeping transaction logs and backups). When combined with a sound database recovery plan, this deployment scenario allows for restoration of inadvertantly removed Activities. Please speak with your Database Administrator to learn more about what options are available.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also