What replaces SaveEdits and UndoEdits (Rollback) on offline FeatureLayer in 10.2.5 .NET

1035
3
06-08-2017 01:17 AM
KarinGisperg1
New Contributor

Hello,

we are developing an app that supports editing on offline maps. We are using *.geodatabase FeatureLayers and *.tpks.

However , in offline mode, i found no possibility to enable a "transaction mode" with a rollback to multiple edit operations. After adding, deleting or editing the features, the "commit" has to be done for each operation separately. That means if Add and Delete is done well, and Update fails, a correct rollback is not possible.

               this.ArcFeatureTable.AddFeaturesAsync(List<Feature> flist);

               this.ArcFeatureTable.DeleteFeaturesAsync( List<Feature> flist );

                this.ArcFeatureTable.UpdateFeaturesAsync( List<Feature> flist );

Further more, how do i know that all features have been added/deleted/updated correctly at all? What is the ResultObject / callback?

I tried  (in ArcGISRuntime 10.2.5 ) to delete a list with three features in  ftable.DeleteAsync(oids) (with oids is a List<long> containing three objectIds , two of them exist in the database). Two objects were deleted without telling me that the third one does not exist.

In ArcgisRuntime SDK  for WPF there exists:

SaveEdits

ArcGIS Runtime SDK for Microsoft WPF - Library Reference 

and UndoEdits

ArcGIS Runtime SDK for Microsoft WPF - Library Reference 

What are the corresponding methods in ArcGIS Runtime .NET 10.2.5 - 10.2.7 and further more in ArcGISRuntime .NET 100.0.0 ?

Thank you

0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor

In current released version v100, you can use GeodatabaseSyncTask.SyncGeodatabase to push your geodatabase edits back to the server, and for its parameters, specify RollbackOnFailure.

https://developers.arcgis.com/net/latest/wpf/api-reference//html/P_Esri_ArcGISRuntime_Tasks_Offline_...

If there were any failure on server, you will get this value in the EditResults

https://developers.arcgis.com/net/latest/wpf/api-reference//html/T_Esri_ArcGISRuntime_Data_SyncLayer...

            var task = await GeodatabaseSyncTask.CreateAsync(new Uri(featureServerUrl));
            var parameters = await task.CreateDefaultSyncGeodatabaseParametersAsync(geodatabase);
            var job = task.SyncGeodatabase(parameters, geodatabase);
            var syncLayerResults = await job.GetResultAsync();
            foreach (var result in syncLayerResults)
            {
                foreach (var editResult in result.EditResults)
                {
                    editResult.CompletedWithErrors;
                    editResult.EditOperation;
                    editResult.Error;
                }
            }

Offline map task and Offline map sync task are coming in Update 1.

0 Kudos
KarinGisperg1
New Contributor
Thank you for your feedback.
The rollback workflow for online editing or syncing offline data back to server does not solve our problem. Our scenario concerns exclusively offline data. Our clients are working a whole day on offline databases before syncing. Therefore, we need something like an offline editor that collects ALL operations (Add, Delete and Edit) during a transaction step, and pushes the collection (NOT THE SEPARATE ACTIONS) to the offline database with rollback possibiltiy.
E.g. When an feature (that exists both on server and offline database) is deleted in the offline database, a restoration is not possible, because with "re-inserting" the deleted feature a new object-id and global-id is created.
=> In short we need something similar to the online workflow, but for offline *.geodatabases (offline GeodatabaseFeatureTables)
YOUR ONLINE EXAMPLE:
private async void AddDamageFeature(MapPoint structureLocation, string type, string cause)
{
    var attributes = new Dictionary<string, object>();
    attributes.Add("typdamage", type);
    attributes.Add("primcause", cause);


    // create a new feature in the damage table, pass in the attributes and geometry
    var newFeature = _damagePointsTable.CreateFeature(attributes, structureLocation);
    // add the new feature (this updates the local copy of the table)
    await _damagePointsTable.AddFeatureAsync(newFeature);


    // push this update (apply edits) to the feature service
    IReadOnlyList<EditResult> editResults = await _damagePointsTable.ApplyEditsAsync();
    // check the results for errors
    foreach(var r in editResults)
    {
        if (r.CompletedWithErrors)
        {
            Console.WriteLine("Edit to Object '" + r.ObjectId + "' failed: " + r.Error.Message);
        }
    }
}
You mention offline map task and offline map sync Task in update1 - do I understand correctly that these new tasks cope with this problem? When will update1  be released?
Thank you
0 Kudos
AnttiKajanus1
Occasional Contributor III

Hi Karin,

The new offline functionality isn't going to help with this issue. I think that this is very important workflow but unfortunately we don't have a proper support for this in current API. Could you provide more details on the use case so I can take that forward to the product group. The more details you can share of your workflow and use case you can provide, would help me to argue to get the proper support in easier for me. If you cannot or want to share this publicly you can send it to me to akajanus@esri.com.

I'll have a look if there is a good way to implement this with the current API but I think that is going to involve quite a bit of code. 

0 Kudos