Synchronizing a replica in a connected environment
The following steps describe how to synchronize a replica using ArcObjects. Before running the code, it is assumed that replicas already exist and you are ready to synchronize the changes.
- Connect to the geodatabase containing the parent replica and connect to the geodatabase containing the child replica. This requires initializing a GeoDataServer object for each connection. GeoDataServer objects allow you to access a geodatabase on a LAN or a WAN through ArcGIS Server. To see how to initialize a GeoDataServer, refer to How to initialize a geodataserver object.
- Call the following procedure. To do this, paste it into your application and call it passing in the following parameters:
parentGDS |
One of the GeoDataServers that you initialized in Step 1.
|
childGDS
|
The other GeoDataServer that you initialized in Step 1.
|
replicaName
|
The name of the replica that you want to synchronize.
|
conflictPolicy
|
The policy that describes how conflicts will be handled when synchronizing.
|
syncDirection
|
Determines if you want to send the changes from the parent to the child or from the child to the parent.
|
columnLevel
|
True means that you want to define conflicts from the column level, while false means that you want to define conflicts from the object level.
|
See the following code:
[Java]
// ++ Synchronizes a replica in a connected environment.
static void synchronizeReplica(IGeoDataServer parentGDS, IGeoDataServer childGDS,
String replicaName, int conflictPolicy, int syncDirection, boolean columnLevel)
throws Exception{
// ++ Get the parent replica.
IGPReplicas replicas = parentGDS.getReplicas();
IGPReplica replica = new GPReplica();
String baseName;
int dotIndex;
for (int i = 0; i < replicas.getCount(); i++){
replica = replicas.getElement(i);
dotIndex = replica.getName().lastIndexOf(".") + 1;
baseName = replica.getName().substring(dotIndex, replica.getName().length()
- dotIndex);
if (baseName.equalsIgnoreCase(replicaName))
break;
}
//++ Get the child replica.
replicas = childGDS.getReplicas();
IGPReplica replicaChild = new GPReplica();
for (int i = 0; i < replicas.getCount(); i++){
replicaChild = replicas.getElement(i);
dotIndex = replicaChild.getName().lastIndexOf(".") + 1;
baseName = replicaChild.getName().substring(dotIndex, replicaChild.getName()
.length() - dotIndex);
if (baseName.equalsIgnoreCase(replicaName))
break;
}
//++ Sync the replica.
IReplicationAgent repAgent = new ReplicationAgent();
repAgent.synchronizeReplica(parentGDS, childGDS, replica, replicaChild,
conflictPolicy, syncDirection, columnLevel);
}
Development licensing | Deployment licensing |
---|---|
ArcEditor | ArcEditor |
ArcInfo | ArcInfo |
Engine Developer Kit | Engine Runtime: Geodatabase Update |