Check In / Check Out Replication

368
2
04-26-2010 11:16 AM
JordanHoaglund
New Contributor II
Hi All,

I'm trying to create a script in modelbuilder to automate replication through check in/check out.  What I'm struggling with is how to bring newly created feature classes into the loop.  The main problem I'm running into is being able to select all feature classes in the SDE to bring into the checkout version.  The create replica tool lets me add all the existing feature classes in the SDE to the checkout file geodatabase, but if a new one is created in there it will not be included. 

Also, if a new feature class is created in the checked out file geodatabase, it is not brought into the SDE during synchronization for some reason.  I've included the export, compare, and import replica schema tools in the model, which apparently only deal with attribute schema and not new feature classes. 

I've attached the model for you to take a look at.  If anyone has any ideas I would be VERY appreciative.  Thank you!

Jordan Hoaglund
GIS Specialist
National Park Service
U.S. Department of the Interior
0 Kudos
2 Replies
AndrewChapkowski
Esri Regular Contributor
If you are going to add new feature classes to the existing replica, then you are going to have to use ArcObjects. 

// This method adds a feature class or table to a replica.
        public void AddDatasetToReplica( IWorkspace workspace, String replicaName,
          String datasetName, String parentDatabase, String parentOwner,
          esriDatasetType datasetType, esriRowsType rowsType, Boolean useGeometry,
          String queryDef )
        {
            // Find the replica.
            IWorkspaceReplicas2 workspaceReplicas2 = (IWorkspaceReplicas2)workspace;
            IReplica replica = workspaceReplicas2.get_ReplicaByName( replicaName );

            // Create a replica dataset for the new feature class or table.
            IReplicaDataset replicaDataset = new ReplicaDatasetClass();
            IReplicaDatasetEdit replicaDatasetEdit = (IReplicaDatasetEdit)replicaDataset;
            replicaDatasetEdit.Type = datasetType;
            replicaDatasetEdit.Name = datasetName;
            replicaDatasetEdit.ParentDatabase = parentDatabase;
            replicaDatasetEdit.ParentOwner = parentOwner;
            replicaDatasetEdit.ReplicaID = replica.ReplicaID;

            // Add the dataset. Note that the pSelID parameter is not currently supported
            // and should always be Nothing.
            IWorkspaceReplicasAdmin2 workspaceReplicasAdmin2 = (IWorkspaceReplicasAdmin2)
              workspaceReplicas2;
            try
            {
                workspaceReplicasAdmin2.RegisterReplicaDataset( replicaDataset, rowsType,
                  useGeometry, queryDef, null, replica );
                MessageBox.Show( "fin" );
            }
            catch (COMException comExc)
            {
                MessageBox.Show( comExc.Message );
            }
        }
0 Kudos
JordanHoaglund
New Contributor II
Thanks Andrew.  I've never worked with ArcObjects or programming, but I suppose there's no better time than the present...
0 Kudos