Hi,
I want to rollback an Edit since last UpdateFeatureAsync an ApplyEditsAsync(just geometry), so I give the feature the old geometry then UpdateFeatureAsync an ApplyEditsAsync, but it seems can't apply to server database the second time and with no EditResults(count=0) return, Below is my codes
var geoBeforeEdit = feature.Geometry;
var editGeometry = await mapControlView.SketchEditor.StartAsync(feature.Geometry);
feature.Geometry = editGeometry;
await feature.FeatureTable.UpdateFeatureAsync(feature);
IReadOnlyList<EditResult> editResults = await (feature.FeatureTable as ServiceFeatureTable).ApplyEditsAsync();
if (editResults.Any(r => r.CompletedWithErrors == true))
{
XHNotifyIcon.ShowFancyBalloon(editResults.Where(r => r.CompletedWithErrors == true).Aggregate(string.Empty, (current, o) => "Edit to Object '" + o.ObjectId + "' failed: " + o.Error.Message + "\n\r"));
return false;
}
bool isSuccess = //do something else.....
if(!isSuccess )
{
feature.Geometry = geoBeforeEdit;
await feature.FeatureTable.UpdateFeatureAsync(feature);
IReadOnlyList<EditResult> editResults = await (feature.FeatureTable as ServiceFeatureTable).ApplyEditsAsync();
if (editResults.Any(r => r.CompletedWithErrors == true))
{
XHNotifyIcon.ShowFancyBalloon(editResults.Where(r => r.CompletedWithErrors == true).Aggregate(string.Empty, (current, o) => "Edit to Object '" + o.ObjectId + "' failed: " + o.Error.Message + "\n\r"));
return false;
}
}
I'm a little confused about this. You want to roll back if an error occurred failing to apply? If it failed to apply, there's nothing to roll back on the server.
Hi, maybe the codes is a bit confusing, I change the codes like below and it will be more clearly.
var geoBeforeEdit = feature.Geometry;
var editGeometry = await mapControlView.SketchEditor.StartAsync(feature.Geometry);
feature.Geometry = editGeometry;
await feature.FeatureTable.UpdateFeatureAsync(feature);
await (feature.FeatureTable as ServiceFeatureTable).ApplyEditsAsync();
bool isSuccess = //do something else.....
if(!isSuccess )
{
feature.Geometry = geoBeforeEdit;
await feature.FeatureTable.UpdateFeatureAsync(feature);
await (feature.FeatureTable as ServiceFeatureTable).ApplyEditsAsync();
}