Understanding the Synergy Change Tracking API
The change tracking API enables you to interact with change tracking information for files that have change tracking enabled. See Change tracking for an overall picture of how change tracking works in Synergy DBL.
You can check whether change tracking is enabled on a file, retrieve change tracking and snapshot information, refresh the array of snapshots that’s being stored and then look at the snapshots individually, and more.
If you have snapshots recorded in your file, you can use the following methods in the Synergex.SynergyDE.Select.Where class to look at changes between snapshots:
-
Changes and NetChange, which allow you to select all changes and net changes made between two snapshots.
-
Snapshot, which enables you to make selections against a file as it was when an applied snapshot was made without updates made after the snapshot.
-
ChangeType, which selects records whose changes have a specific change tracking status.
When you have enumerated a change tracking record, you can retrieve a CTInfo object using the RestrictedAlphaEnumerator.GetCTInfo property to access the following information:
-
Determine what kind of change occurred using GetCTState.
-
Determine in which snapshot the change occurred and the datetime the snapshot occurred.
-
View the change record itself and its length.
-
Access record revision information using the newer and older CTInfo if they exist, which allows you to walk the entire recorded change history of a record.
To access snapshots on a file level, you can use the Synergex.SynergyDE.Select.ChangeTracking class. Once a ChangeTracking object is created, snapshot information can be accessed. For example,
ct = new ChangeTracking(“DAT:curtrans”) if (applyNow) begin ct.ApplySnapshot() ; Add a snapshot
ct.Refresh()
end foreach sinfo in ct.SnapShots begin if (sinfo.Type .eq. SSType.Snapshot) ssout(sinfo.Number, sinfo.DateTime, sinfo.Inserts+sinfo.Updates+sinfo.Deletes) end
The Select.ChangeTracking class also allows you to programmatically apply a snapshot to a file, using the ApplySnapshot() method.
Use the ChangeTracking.Refresh() method to view changes in ChangeTracking.Snapshots data. |