How to use
See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.
Preparing the data
- This sample requires that the raster catalog has a long integer column named "gen." If the replica has been created and has that column, proceed with Step 7 in this section.
- Open the parent raster catalog to be synchronized in ArcMap.
- Add the gen column to the raster catalog using the Add Field option in the attribute table.
- Set the value of the gen column for any existing raster datasets in the raster catalog to 0. The field calculator can be used to do this quickly.
- Repeat Steps 2-4 for the child raster catalog.
- Create a replica of the raster catalog. For more information, see "How to create a replica in a connected environment" in the See Also section in this topic. The creation process copies the raster catalog and the raster datasets that intersect the replica geometry by default. To create the replica, at least one versioned feature class with edit permission must also be included in the replica. It is not possible to create a replica consisting only of the raster dataset.
- Once the replica exists, make sure that the raster catalog exists in the parent and the child replica geodatabases, and that each has a long integer column named gen.
- If there are common raster datasets, set the value in the gen column to 0 for the common datasets in the parent and child replica geodatabases.
Building the extension
- Once the data is prepared, build the extension and register it with the replica geodatabases by completing the following steps.
- Copy the solution locally and open the solution.
- Open the RasterSyncWorkspaceExtension.cs (if working in C#) or RasterSyncWorkspaceExtension.vb (if working in VB .NET) source file.
- There are two member variables in the extension that can be adjusted. The rasterCatalog variable (a private constant string, currently set to "ras_cat") is the name of the raster catalog to involve in the synchronization. By changing this value before building the assembly, the synchronized raster catalog can be changed.
- The other variable is the replica variable (a private constant string, currently set to "myreplicaras"), which is the name of the replica whose synchronization event triggers this behavior. By changing this value before building the assembly, the replica with extended behavior can be changed.
- Right-click the project and choose build. This creates the assembly in the project's debug or release directory (depending on the selected option).
Applying the extension to one or more geodatabases
- Which geodatabase or geodatabases require the workspace extension depends on the type of replica being used. For one-way parent-to-child replication, both geodatabases involved with the replica requires the extension. For two-way replication, both geodatabases involved with the replica requires the extension. The RasterSynchExtensionReg* project compiles to an executable that registers the workspace extension with a geodatabase.
- Right-click the RasterSyncExtensionReg* project and choose Set as StartUp Project.
- Open RegisterExtension.cs.
- Change the RegisterExtension.workspacePath value to the path of an ArcSDE connection file or local geodatabase that has the extension applied to it.
- Change the RegisterExtension.geodatabaseType value to reflect the type of geodatabase on which the extension is being registered.
- Right-click the project and choose build.
- Press F5 to run the project.
- Steps 2-7 in this section registers the extension with one of the replica geodatabases. If two-way replication is being used, repeat these steps for the other replica geodatabase. Once this is completed, synchronizing the replica identified in the previous steps executes the extension.
Using the extension
- Synchronizing the replica associated with the extension using the wizards, or the geoprocessing tools in ArcCatalog or ArcMap, triggers the extension's behavior. To test this, assuming that a two-way replica is being used, complete the following steps.
- Load one or more new raster datasets into the raster catalog in the parent geodatabase. When this is done, the gen column has a null value for the new raster datasets.
- In the same way, load one or more new raster datasets into the raster catalog in the child.
- In ArcCatalog, connect to the parent replica geodatabase and synchronize from the parent to the child. Notice that a value is assigned to the gen column of the new raster datasets. This is the generation number of the synchronization in which the raster datasets were sent.
- In ArcCatalog, connect to the child replica geodatabase and preview the raster catalog. Notice that the raster datasets from the parent have been applied and have a gen value of –1. The –1 value indicates that these have been received from the parent.
- In ArcCatalog, synchronize from the child to the parent. Notice that the raster datasets that were added to the child in Step 3 were applied to the parent and the values in the gen column for these datasets were adjusted.
- As raster datasets are added and synchronized, the parent and child are kept up to date with the new raster datasets. The extension also supports cases where (for any reason) synchronization fails. Here, the generation information in the gen column is used to determine if rasters need to be resent.
Additional information
Expanding the sample
The main goal of the sample is to show how to extend replica synchronization. There are a number of enhancements that can be added to support your specific requirements. Some of these include the following:
- Disconnected replication—The sample does not work in cases where you are performing disconnected synchronization where changes are synchronized using delta files. If you use disconnected synchronization, the raster catalog is ignored.
- To extend the sample to cover this case, you can implement the AfterExportingDataChanges event in the extension. This event is called when you run the export data changes command. Here, you can use the same logic from the AfterSynchronizingDataChanges event handler to copy the raster datasets to a local file geodatabase. This can then be copied with the delta file to a location accessible by the target replica geodatabase. When the data file is imported, you can add code to the AfterSynchronizingDataChanges event, which is also called with the import message command. This code can import the raster datasets from the local file geodatabase.
- Multiple replicas—This sample is for a single replica. Implementing it for several replicas involves creating a gen column per replica.
- Multiple raster catalogs—This sample is for a single raster catalog. Implementing it for several raster catalogs involves adding enhancements to keep track of which raster catalogs to synchronize.
- Replication using geodata services and ArcGIS for Server—This sample does not work in this environment. Synchronizing using geodata services and ArcGIS for Server ignores the raster catalog. In this case, you can use similar techniques as previously described for disconnected replication, since the server uses delta files to synchronize changes.
- Creating a workspace property page—To avoid hard coding the values, such as the replica and raster dataset name, a property page can be created that gets and sets the values from a private table.
RasterSyncExtension/RasterSyncWorkspaceExtension.cs | A workspace extension that extends the synchronization process. |
RasterSyncExtensionReg/RegisterExtension.cs | A console application that registers the extension with a geodatabase. |
RasterSyncExtension/RasterSyncWorkspaceExtension.vb | A workspace extension that extends the synchronization process. |
RasterSyncExtensionReg/RegisterExtension.vb | A console application that registers the extension with a geodatabase. |
Download the files for all languages
See Also:
How to create a replica in a connected environmentDevelopment licensing | Deployment licensing |
---|---|
ArcGIS for Desktop Standard | ArcGIS for Desktop Standard |
ArcGIS for Desktop Advanced | ArcGIS for Desktop Advanced |
Engine Developer Kit | Engine: Geodatabase Update |