Select to view content in your preferred language

Detect When a Feature Class Was Replicated

2293
5
01-06-2011 06:37 AM
RobertPincus
Regular Contributor
How can I programmatically detect when a feature class was replicated from a maintenance database to a production database? I tried using the modified_date in the sys.objects table in the production database, but the date never changed. The databases are SQL Server 2008.

Thanks,
Robert
0 Kudos
5 Replies
HeatherMcCracken
Esri Contributor
Are you using Geodatabase Replication, or SqlServer (Database) replication?
-Heather
0 Kudos
RobertPincus
Regular Contributor
Geodatabase Replication
0 Kudos
RobertHu
Emerging Contributor
This query returns the date/time FCs being synced in last 10 days,


SELECT
    GPReplicaDataset.value('DatasetName[1]', 'nvarchar(max)') AS 'Feature Class',
    CAST(replicalog.LogDate AS smalldatetime) AS 'Sync Time'
FROM
    sde.GDB_ITEMS AS items
        INNER JOIN sde.GDB_ITEMTYPES AS itemtypes
        ON items.Type = itemtypes.UUID
        INNER JOIN sde.GDB_REPLICALOG AS replicalog
        On items.ObjectID = replicalog.ReplicaID
CROSS APPLY
    items.Definition.nodes
        ('/GPReplica/GPReplicaDescription/GPReplicaDatasets/GPReplicaDataset')
        AS GPReplicaDatasets(GPReplicaDataset)
WHERE
    itemtypes.Name = 'Replica'
    AND ( GETDATE() - replicalog.LogDate ) < 10
ORDER BY 'Feature Class', 'Sync Time' ;

GO
0 Kudos
HeatherMcCracken
Esri Contributor
Take a look at IReplica2.log

http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Log_Property/00250000078...

This will tell you when a replica last received changes, if you know which replica you data participates in, this will be enough for you to know when it was last updated (if changes sent to that fc as part of the sync). If not, you'll just need to query the IReplicaDatasets property of the replica to see if you data participates in which replica.

Thinking this will give you what you need?
Thanks,
Heather
0 Kudos
RobertPincus
Regular Contributor
I'll look into it ASAP
0 Kudos