Geodatabase Sync Task
A task to generate and synchronize a mobile geodatabase with a sync-enabled ArcGIS feature service. Mobile geodatabases are designed for querying and viewing feature data when your app is offline. While offline, users can edit a mobile geodatabase locally and later synchronize changes with its feature service, assuming the associated service supports synchronization. While offline, the geodatabase keeps track of all local edits. When you synchronize the geodatabase with the service, the service receives the geodatabase's local edits, and the geodatabase receives the service's remote edits.
This task allows you to build apps that can download data from an ArcGIS feature service that has been enabled for offline use[https://enterprise.arcgis.com/en/server/latest/publish-services/windows/prepare-data-for-offline-use.htm] into a geodatabase. Here are the typical steps to download data from sync-enabled ArcGIS feature service into a geodatabase file on your device:
Construct and load the GeodatabaseSyncTask with a URL to a sync-enabled ArcGIS feature service.
Create a Geometry to define the area of interest that you wish to take offline.
Obtain the GenerateGeodatabaseParameters for the area of interest by calling GeodatabaseSyncTask.createDefaultGenerateGeodatabaseParameters(Geometry).
Create a GenerateGeodatabaseJob by calling GeodatabaseSyncTask.createGenerateGeodatabaseJob(GenerateGeodatabaseParameters, String). Specify a path where the mobile geodatabase (.geodatabase file) is downloaded to.
Start the GenerateGeodatabaseJob. Upon job completion, obtain the Geodatabase from the GenerateGeodatabaseJob.result.
The geodatabase may contain feature layers, annotation layers, related records, non-spatial tables, and attachments. You can create, update, or delete this data according to the capabilities of the source feature service. The geodatabase is registered with the online feature service so that you can synchronize their data when a network connection to the feature service is available. Your app business logic will determine whether the synchronization just downloads changes from the feature service (SyncDirection.Download), just uploads changes made to the geodatabase (SyncDirection.Upload), or uploads and downloads changes (SyncDirection.Bidirectional). Here are the typical steps to synchronize data between the geodatabase file and the source feature service:
Create a GeodatabaseSyncTask with the Geodatabase.serviceUrl.
Obtain the SyncGeodatabaseParameters for the geodatabase by calling GeodatabaseSyncTask.createDefaultSyncGeodatabaseParameters(Geodatabase).
Create a SyncGeodatabaseJob by calling GeodatabaseSyncTask.createSyncGeodatabaseJob(SyncGeodatabaseParameters, Geodatabase)). Specify the synchronization direction.
Start the SyncGeodatabaseJob. Upon job completion, examine the SyncLayerResult from the SyncGeodatabaseJob.result to determine whether the synchronization was successful.
When the geodatabase is no longer needed, you should unregister it to clean up the tracking metadata stored on the feature service. Unregistered geodatabases cannot be re-registered. Here are the steps to unregister a geodatabase:
Create and load a Geodatabase from the downloaded geodatabase file using Geodatabase.Geodatabase(String).
Examine Geodatabase.isSyncEnabled to check that the geodatabase is sync-enabled. If this is false, no further action is needed.
Create a GeodatabaseSyncTask with the Geodatabase.serviceUrl.
Unregister the geodatabase using GeodatabaseSyncTask.unregisterGeodatabase(Geodatabase).
There is another option for working with mobile geodatabases. You can place a copy of a sync-enabled geodatabase onto your device and register it with the associated service using GeodatabaseSyncTask.registerSyncEnabledGeodatabase(Geodatabase). This will give the geodatabase its own replica ID and you will be able to synchronize the geodatabase with its service.
If you want to download a portion of a web map and its content, instead of individual ArcGIS feature services, consider using the OfflineMapTask. You can then synchronize all of the map's geodatabase content together using the OfflineMapSyncTask.
Since
200.1.0
Constructors
Properties
Inherited properties
The API key allows your app to access ArcGIS location services and private portal items. An API key is a unique long-lived access token that is used to authenticate and monitor requests to ArcGIS location services and private portal items. You can create and manage an API key using your portal when you sign in with an ArcGIS Location Platform account or an ArcGIS Online account with administrator access or a custom role that has the Generate API keys
privilege. To learn how to create and manage API keys, go to the Create an API Key tutorial. You must ensure that your API key has the correct privileges to access secure resources.
The load status.
Functions
Creates default parameters to generate and download a geodatabase using the GenerateGeodatabaseJob. This populates the parameters with values that match the feature service. For example, if the service does not support SyncModel.Layer then SyncModel.Geodatabase will be used and all layers from the service will be included. Attachments are included by default, but related tables/layers are not included. Output features are in the spatial reference of the given extent.
Creates default parameters for a sync geodatabase using the given sync direction if it is not null.
Returns a job to generate and download a geodatabase from an ArcGIS feature service.
Returns a job to synchronize a geodatabase back to its source ArcGIS feature service. For a successfully completed job the job's result returns an array of SyncLayerResult, typically the array is empty. If individual edits failed then the result array provides these errors grouped by each table using SyncLayerResult instances which in turn contain each edit error.
Returns a job to synchronize a geodatabase back to its source ArcGIS feature service using the specified sync direction and rollback on failure boolean value. If the given sync direction is not compatible with the geodatabase sync task's feature service, the returned job will fail.
Registers a copy of a sync-enabled geodatabase with an ArcGIS feature service to allow the copy to sync changes. This method is typically used as part of services pattern workflow, sometimes known as a pre-planned workflow. A sync-enabled geodatabase is generated centrally and not modified or synced. Copies of this original geodatabase are distributed and loaded onto each user's device. The copy must first be registered with the service to allow the server to identify changes in subsequent sync operations. One of the main benefits of this workflow is a reduction in server load to generate geodatabases for many clients. It is important not to sync the copy before registering to ensure the server can maintain consistent state on each copy. This operation is not the opposite of GeodatabaseSyncTask.unregisterGeodatabase(Geodatabase) which is used to remove a geodatabase from the service prior to deletion.
Unregisters a geodatabase from its source ArcGIS feature service using the geodatabases sync ID. This removes the services replica id. This method is used to unregister a geodatabase from a service using the sync ID. This is commonly used to enable cleanup of the service after the local geodatabase has already been deleted. See Geodatabase.syncId. After unregistering a geodatabase it can no longer be synced back to the service. This operation is not related to GeodatabaseSyncTask.registerSyncEnabledGeodatabase(Geodatabase), which is for registering copies of a sync-enabled geodatabase.
Unregisters a geodatabase from its source ArcGIS feature service. This removes the services replica id. After unregistering a geodatabase it can no longer be synced back to the service. This is often used prior to deleting a local geodatabase. This operation is not related to GeodatabaseSyncTask.registerSyncEnabledGeodatabase(Geodatabase), which is for registering copies of a sync-enabled geodatabase.