azatrain

Update Attributes Only for ArcGIS Server FeatureServer Service Layer

Discussion created by azatrain on Dec 10, 2013
Latest reply on Dec 11, 2013 by azatrain
I am writing functionality for my app that allows the user to edit geometry and attributes for features inside of an ArcGISLocalFeatureLayer.  This layer comes from an MPK, but it also has a matching layer inside of an ArcGIS Server FeatureServer service.  I've coded the ability to push new geometries with their attributes and attachments from the local feature layer up to the FeatureServer service layer.  This works great, and I can see the results of this process inside of an ArcGIS.com web map.

What I need to do now is code for the scenario where the user has edited the attributes of a local feature that already exists in the FeatureServer service layer.  In this case I do not want to push the geometry back up to the server since it already exists, I only want to update the attribute values for that geometry.  In other words, does the 10.1 Runtime API have something equivalent to the Apply Edits or Update Features REST capabilities?

Here is the code I am using to add new geometries along with their attributes.  I perform a query to return all features from the local layer and then add them all to the sync layer (FeatureServer service layer).  Hopefully someone can point me in the right direction here.  Thanks ...

void SyncFeaturesQueryTask_ExecuteCompleted(object sender, QueryEventArgs e)
        {
                QueryTask querTask = sender as QueryTask;
                FeatureLayer syncFeatLyr = null;
                ArcGISLocalFeatureLayer locFeatLyr = null;

                //  Get local and sync feature layers for edit layer being queried

                foreach (EditLayer editLayer in ApplicationManager.configManager.DamageAssessmentLayers)
                {
                    if (querTask.Url == editLayer.LocalHostLayer)
                    {
                        syncFeatLyr = ApplicationManager.map.Layers[editLayer.SyncLayerName] as FeatureLayer;
                        locFeatLyr = ApplicationManager.map.Layers[editLayer.LayerName] as ArcGISLocalFeatureLayer;
                        break;
                    }
                }

                if (syncFeatLyr != null)
                {
                    //  Get features returned from query

                    syncFeatLyr.AutoSave = true;
                    IEnumerable<Graphic> grEnum = e.FeatureSet;
                    GraphicIDs grIDs = new GraphicIDs();
                    EpochField.Model.GraphicID grID;
                    ICollection<object> attColl;
                    string objID;

                    //  Add graphics returned from query to sync feature layer

                    foreach (Graphic gr in grEnum)
                    {
                        attColl = gr.Attributes.Values;
                        objID = attColl.ElementAt(0).ToString();
                        grID = new EpochField.Model.GraphicID(objID, gr);
                        grIDs.Add(grID);
                        syncFeatLyr.Graphics.Add(gr);
                    }

                    //  Save edits to sync feature layer

                    syncFeatLyr.SaveEdits();
                    grIDs.LocalFeatureLayer = querTask.Url;
                    m_GraphicIDs.Add(grIDs);
                    locFeatLyr.Refresh();
                }           
        }

Outcomes