I am attempting to sync my offline geodatabase of a Feature Layer for the first time using these steps
Sync offline edits—ArcGIS Runtime SDK for Qt | ArcGIS for Developers
I have made sure my changes are in my offline .geodatabase file on my machine, but after I sync my changes they don't appear to be syncing. My feature layer has 3 layers in it. When I set the geodatabase to sync, do I need to specify the layers to sync or something? Shouldn't it sync everything in the feature service. The changes don't seem to be uploading?
SyncGeodatabaseParameters {
id: syncParameters
// only sync the 1 layer
layerOptions: [
SyncLayerOption {
layerId: app.layerId //My feature service with 3 layers, shouldn't it sync everything.
}
]
// push up edits
geodatabaseSyncDirection: Enums.SyncDirectionUpload
}
GeodatabaseSyncTask {
id: geodatabaseSyncTask
url: "myURL/FeatureServer"
property var generateJob
property var syncJob
function executeSync() {
// execute the asynchronous task and obtain the job
//syncOverrideGDB is not null and is the feature service with 3 layers
syncJob = syncGeodatabase(syncParameters, syncOverrideGDB);
// check if the job is valid
if (syncJob) {
// show the sync window
syncWindow.visible = true;
// connect to the job's status changed signal to know once it is done
syncJob.jobStatusChanged.connect(updateSyncJobStatus);
// start the job
syncJob.start();
} else {
// a valid job was not obtained, so show an error
syncWindow.visible = true;
statusText = "Sync failed";
syncWindow.hideWindow(5000);
}
}
function updateSyncJobStatus() {
switch(syncJob.jobStatus) {
case Enums.JobStatusFailed:
statusText = "Sync failed";
syncWindow.hideWindow(5000);
break;
case Enums.JobStatusNotStarted:
statusText = "Job not started";
break;
case Enums.JobStatusPaused:
statusText = "Job paused";
break;
case Enums.JobStatusStarted:
statusText = "In progress...";
break;
case Enums.JobStatusSucceeded:
statusText = "Complete";
syncWindow.hideWindow(1500);
break;
default:
break;
}
}
}
Hi M Ka thanks for your question.
When performing this operation you do need to specify the layers in your geodatabase that you wish to sync. Rather than manually creating these SyncLayerOption's yourself you can call GeodatabaseSyncTask.createDefaultSyncGeodatabaseParametersWithSyncDirection passing your offline Geodatabase. When this asynchronous operation completes it will give you a set of parameters with sensible defaults pre-populated - including options for each of the layers.
What sync model is your geodatabase using? E.g. is it perLayer or perReplica?
Thanks,
Luke
I am taking my web map offline that has 5 feature layers. I use the offline map task to take the map offline with default map parameters that are per layer by default. Are you saying to go into the individual layers in the paramerter overrides and set the sync model of the layers I don't care about to SyncModelNone? Is there a more efficient way to set the sync model on individual layers without the override on the original default parameters?
offlineMapTask.createDefaultGenerateOfflineMapParameters(exportGeometry.extent)
OfflineMapTask {
id: offlineMapTask
onlineMap: app.mainMapView.maponCreateDefaultGenerateOfflineMapParametersStatusChanged: {parameters = createDefaultGenerateOfflineMapParametersResult;offlineMapTask.createGenerateOfflineMapParameterOverrides(parameters)....
}
onCreateGenerateOfflineMapParameterOverridesStatusChanged:{
if (createGenerateOfflineMapParameterOverridesStatus === Enums.TaskStatusCompleted) {var geodatabaseParamOverrides = overrides.generateGeodatabaseParameters;geodatabaseParamOverrides.value(geodatabaseParamOverrides.keyAt(0)).syncModel = Enums.SyncModelLayer; geodatabaseParamOverrides.value(geodatabaseParamOverrides.keyAt(1)).syncModel = Enums.SyncModelNone; geodatabaseParamOverrides.value(geodatabaseParamOverrides.keyAt(2)).syncModel = Enums.SyncModelNone; geodatabaseParamOverrides.value(geodatabaseParamOverrides.keyAt(3)).syncModel = Enums.SyncModelNone; geodatabaseParamOverrides.value(geodatabaseParamOverrides.keyAt(4)).syncModel = Enums.SyncModelNone;.......
}
}
}
createGenerateOfflineMapParameterOverrides
Hi M Ka - if you never want to sync those layers it may be a good idea to override those capabilities somehow in the web map. For example, you could create a feature layer view on the data to reduce the sync capabilities for those layers.
If you do want the layers to be sync enabled in that web map, you can choose the best approach in Runtime:
- take all layers offline with sync capabilities (as you are doing now)
- manually change the capabilities using the overrides workflow (as you suggest above)
If you take the layers offline with the sync capability but then don't want to sync them, you would need to make sure the layer options are set correctly when you come to sync back your changes.
By the way, if you are using the OfflineMapTask to take the data offline, you may find the OfflineMapSyncTask useful (it essentially syncs all of the data in your map in one task - e.g. from multiple services).
I hope that helps,
Luke