ISCSession Interface

The following table contains information on the ISCSession interface:

Signature

Description

Valid Arguments

VARIANT BeginNamedTransaction(

BSTR Name, VARIANT PropertyBag [optional] )

Opens a transaction on the session with the given name. Returns an identifier of the transaction.

Name � Provides a name for a new transaction.

PropertyBag � Collection of parameters for history tracking in the transaction.

The following table describes the properties used in creating a new model:

Property Name

Type

Description

History_Tracking

Boolean

TRUE � Indicates that all historical information generated during the transaction will be marked as the API event. The TRUE value is assumed if the property is not provided.

FALSE � Uses the standard erwin DM mechanism of history tracking.

History_Description

BSTR

When the History_Tracking property is TRUE, it provides the content for the Description field of the history event.

A complete set of available properties is located in the appendix API Interfaces Reference.

Example 34

The following example illustrates how to mark history records for entities and attributes as API events, and how to mark history records with the API History Tracking description using Visual Basic .NET:

Public Sub Main()
    Sub Main()
        Dim oApi As New SCAPI.Application
        Dim oBag As New SCAPI.PropertyBag
        Dim oPU As SCAPI.PersistenceUnit
        ' Construct a new logical-physical model. Accept the rest as defaults
        oBag.Add("Model_Type", "Combined")
        oPU = oApi.PersistenceUnits.Create(oBag)
        ' Clear the bag for the future reuse
        oBag.ClearAll()
        ' Start a session
        Dim oSession As SCAPI.Session
        oSession = oApi.Sessions.Add
        oSession.Open(oPU)
        ' Prepare a property bag with the transaction properties
        oBag.Add("History_Description", "API History Tracking")
        ' Start a transaction
        Dim nTransId As Object
        nTransId = oSession.BeginNamedTransaction("Create Entity and Attribute", oBag)
        ' Create an entity and an attribute
        Dim oEntity As SCAPI.ModelObject
        Dim oAttribute As SCAPI.ModelObject
        oEntity = oSession.ModelObjects.Add("Entity")
        oAttribute = oSession.ModelObjects.Collect(oEntity).Add("Attribute")
        oAttribute.Properties("Name").Value = "Attr A"
        ' Commit
        oSession.CommitTransaction(nTransId)
    End Sub

You can select the history options for the model objects for which you want to preserve history, as well as to control the type of events to track. This is done within the History Options tab in the Model Properties dialog.

If the check box for API events is cleared (unchecked), then no historic events from the API category are recorded. It is possible to control the status of that check box, as well as the check boxes for model object types from the API, by controlling the value of properties in the model where the status of these check boxes is stored.