Version

AddActivity(Activity,Resource) Method

Adds an Activity that does not currently exist to the database.
Syntax
'Declaration
 
Public Overloads Sub AddActivity( _
   ByVal activity As Activity, _
   ByVal resource As Resource _
) 
public void AddActivity( 
   Activity activity,
   Resource resource
)

Parameters

activity
An activity created dynamically by the application or taken from an external source, that is not already present in the data source.
resource
A resource that is the organizer affiliated with the activity, or null (Nothing in Visual Basic .NET) to indicate the activity has no Resource to be associated with it.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionThrown when the activity was supplied as a null reference (or Nothing in Visual Basic .NET). An Activity must be non-null in order for it's properties to be inserted into the data store.
System.NotSupportedExceptionThrown when the concrete type of activity is something other than Appointment. Presently, only the insertion of Appointment objects into the data store is supported.
System.ComponentModel.WarningExceptionThrown when the WebScheduleInfo property has not been properly initialized before calling AddActivity. In order for AddActivity to add the supplied activity to the data store, the WebScheduleDataProviderBase must already be initialized with the same WebScheduleInfo as the activity was.
Remarks

WebSchedule automatically handles adding an Activity when an end user submits a new Appointment through the user interface. Developers would call AddActivity to add additional Activities they may have created programmatically. Ordinarily, Activity instances added to the ActivitiesCollection on WebScheduleInfo are not automatically saved to the data store.

The AddActivity method also supports administrative and batch applications to transform external scheduling information into the WebSchedule data model, and bulk load it into the data store. An example is an application that extracts, transforms, and loads user schedules from Microsoft Exchange into WebSchedule.

Any setting of the DataKey or Key properties of the supplied activity will be ignored, since this method adds a new row to the Activity data table. When this method is successful, the DataKey on the supplied Activity object reference will be modified to contain the auto-generated identifier from the database.

The supplied resource is used to enter a new row into the ActivityResource child table. When specified, the resource must exist in the ResourcesCollection of WebScheduleInfo and within the data store, or the referential integrity constraint of the WebSchedule data model will be violated. The DataKey of the resource is used when adding this row to ActivityResource and must be valid for the operation to be successful.

Were the resource omitted (passed in as null or Nothing in Visual Basic .NET) then the activity will be associated with the UnassignedResource by default.

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