Class GeodatabaseSyncTask
A task to generate and synchronize a mobile geodatabase with a sync-enabled ArcGIS feature service.
Inheritance
Implements
Namespace: Esri.ArcGISRuntime.Tasks.Offline
Assembly: Esri.ArcGISRuntime.dll
Syntax
public sealed class GeodatabaseSyncTask : IApiKeyResource
Remarks
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 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 CreateDefaultGenerateGeodatabaseParametersAsync(Geometry).
- Create a GenerateGeodatabaseJob by calling GenerateGeodatabase(GenerateGeodatabaseParameters, String).
- Start the GenerateGeodatabaseJob. Upon job completion, obtain the Geodatabase from the
.
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 (Download), just uploads changes made to the geodatabase (Upload), or uploads and downloads changes (Bidirectional). Here are the typical steps to synchronize data between the geodatabase file and the source feature service:
- Create a GeodatabaseSyncTask with the Source.
- Obtain the SyncGeodatabaseParameters for the geodatabase by calling CreateDefaultSyncGeodatabaseParametersAsync(Geodatabase).
- Create a SyncGeodatabaseJob by calling SyncGeodatabase(SyncGeodatabaseParameters, Geodatabase)). Specify the synchronization direction.
- Start the SyncGeodatabaseJob. Upon job completion, examine the SyncLayerResult from the
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 Esri.ArcGISRuntime.Data.Geodatabase.#ctor(System.String).
- Examine IsSyncEnabled() to check that the geodatabase is sync-enabled. If this is
false
, no further action is needed. - Create a GeodatabaseSyncTask with the Source.
- Unregister the geodatabase using UnregisterGeodatabaseAsync(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
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.
Properties
Name | Description |
---|---|
ApiKey | Gets or sets the API key that allows your app to access ArcGIS location services and private portal items. |
ServiceInfo | Gets metadata that describes the ArcGIS feature service to synchronize with. |
Uri | Gets the URI of the ArcGIS feature service to synchronize with. |
Methods
Name | Description |
---|---|
ApplyDeltaAsync(Geodatabase, String) | Imports a geodatabase delta and applies it to the given geodatabase. |
CreateAsync(Uri) | Creates a geodatabase sync task from a URI to a sync-enabled ArcGIS feature service. |
CreateAsync(Uri, String) | Creates a geodatabase sync task from an online URI. |
CreateDefaultGenerateGeodatabaseParametersAsync(Envelope) | Creates default parameters for a generate geodatabase job. |
CreateDefaultGenerateGeodatabaseParametersAsync(Geometry) | Creates default parameters to generate and download a geodatabase using the GenerateGeodatabaseJob. |
CreateDefaultSyncGeodatabaseParametersAsync(Geodatabase) | Creates default parameters to synchronize a geodatabase using the SyncGeodatabaseJob. |
CreateDefaultSyncGeodatabaseParametersAsync(Geodatabase, SyncDirection) | Creates default parameters for a sync geodatabase using the given sync direction. |
ExportDeltaAsync(Geodatabase, String) | Generates an upload delta geodatabase file containing all the changes since the last sync. |
GenerateGeodatabase(GenerateGeodatabaseParameters, String) | Creates a job to generate and download a geodatabase from a service. |
RegisterGeodatabaseAsync(Geodatabase) | Registers a copy of a sync-enabled geodatabase with an ArcGIS feature service to allow the copy to synchronize changes. |
SyncGeodatabase(SyncDirection, Boolean, Geodatabase) | Creates a job to synchronize a geodatabase back to its source ArcGIS feature service using the given sync direction and rollback on failure boolean value. |
SyncGeodatabase(SyncGeodatabaseParameters, Geodatabase) | Creates a job to synchronize a geodatabase back to a service. |
UnregisterGeodatabaseAsync(Geodatabase) | Unregisters a geodatabase from its source ArcGIS feature service. This removes the services replica id. |
UnregisterGeodatabaseAsync(Guid) | Unregisters a geodatabase from a service removing the service's replica id. This overload uses the geodatabase's sync ID rather than a reference to the geodatabase itself. |
Applies to
Target | Versions |
---|---|
.NET Standard 2.0 | 100.3 - 200.5 |
.NET | 100.13 - 200.5 |
.NET Windows | 100.13 - 200.5 |
.NET Android | 200.0 - 200.5 |
.NET iOS | 200.0 - 200.5 |
.NET Framework | 100.0 - 200.5 |
Xamarin.Android | 100.0 - 100.15 |
Xamarin.iOS | 100.0 - 100.15 |
UWP | 100.0 - 200.5 |