Hello all,
I am trying to update a single attribute on 100 different features of at most 4 different layers, with the same value. In my case I have 100 features that need a "comments" field updated.
I used the Inspector class to modify multiple features, since it seems to be the preferred method on the ProSnippets documentation. However I noticed something odd when it took nearly 20 seconds to complete. I ran Fiddler to look at all the network calls to ArcGIS Server that were made during the process and saw that "applyEdits" was called once for each feature that I loaded into the inspector (see below screenshot, under code snippet), this resulted in 100 applyEdits calls and 100 queryFeature calls, 200 in total. I was expecting at most 1 call per layer.
I recorded some timings based on larger feature counts for my EditOperation to finish the "ExecuteAsync" method.
Is there a way for me to configure Inspector to only make at most 1 call per updated layer? Or is there a better method through the SDK?
Feature Count | Duration (in seconds) |
---|
104 | 20 |
210 | 54 |
306 | 70 |
500 | 109 |
650 | 113 |
1100 | 247 |
1200 | 276 |
public static async void ApplyUpdateUsingInspector(IDictionary<Layer, List<FeatureObject>> layerAttributes, object value, string fieldName)
{
await QueuedTask.Run(async () =>
{
var editOperation = new EditOperation();
editOperation.Name = "Changing attribute...";
editOperation.ProgressMessage = "Working...";
editOperation.ShowProgressor = true;
editOperation.CancelMessage = "Operation canceled";
editOperation.ErrorMessage = "Error updating attributes";
foreach (var layer in layerAttributes.Keys)
{
var features = layerAttributes[layer];
var objectIds = from feature in features
from attribute in feature.Attributes
where attribute.Key == "ObjectID"
select (long)attribute.Value;
var inspector = new Inspector();
inspector.Load(layer, objectIds.ToArray());
inspector[fieldName] = value;
editOperation.Modify(inspector);
}
if (editOperation.IsEmpty)
{
editOperation.Abort();
}
else
{
await editOperation.ExecuteAsync();
}
});
}