xiaoguang

ApplyEditsAsync() the second time return no EditResults

Discussion created by xiaoguang on Sep 16, 2017
Latest reply on Sep 18, 2017 by xiaoguang

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;
   }
}

Outcomes