EditOperation.ExecuteAsync runs, but edits aren't saved

82
3
Jump to solution
05-19-2022 02:00 PM
KenBuja
MVP Honored Contributor

I am running an EditOperation in my add-in, but after I call the ExecuteAsync method and look at the Edit tab, the Save button is activated. This is a problem, since the next step in the process is to run a dissolve on the edited layer. I get the error message that the dissolve cannot run since the layer is being edited.

In this code, I'm modifying two fields and saving the edits. Why aren't they being properly saved?

        QueryFilter queryFilter = new QueryFilter { WhereClause = "1=1" };
        EditOperation editOperation = new EditOperation();
        Inspector inspector;
        editOperation.ShowProgressor = true;
        await QueuedTask.Run(() =>
        {
          using (RowCursor rowCursor = featureClass.Search(queryFilter, false))
          {
            while (rowCursor.MoveNext())
            {
              using (Row record = rowCursor.Current)
              {
                inspector = new Inspector();
                inspector.Load(record);
                inspector["PS_Count"] = 1;
                if (geometryType == GeometryType.Polygon)
                {
                  var feature = (Feature)record;
                  inspector["PS_Area"] = GeometryEngine.Instance.GeodesicArea(feature.GetShape());
                }
                editOperation.Modify(inspector);
              }
            }
          }
        });
        try
        {
          bool result = await editOperation.ExecuteAsync();
          if (!result) message = editOperation.ErrorMessage;
        }

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RichRuh
Esri Regular Contributor

Hi Ken,

Your code just makes the edit and adds it to the undo/redo stack.

If you want to save your edits, call

 Project.Current.SaveEditsAsync()

--Rich

 

View solution in original post

0 Kudos
3 Replies
RichRuh
Esri Regular Contributor

Hi Ken,

Your code just makes the edit and adds it to the undo/redo stack.

If you want to save your edits, call

 Project.Current.SaveEditsAsync()

--Rich

 

0 Kudos
KenBuja
MVP Honored Contributor

I guess I didn't read far enough through the documentation on this. Using Inspector.ApplyAsync() was much slower than EditOperation.Modify(inspector). I then tested it just using the Modify(Row,String,Object) method and that was much faster than using the Inspector.

0 Kudos
GintautasKmieliauskas
Regular Contributor

Hi,

"The Inspector.ApplyAsync() method applies and saves the changes in one shot (there is no undo). Whereas EditOperation.Modify(inspector) will apply the changes and add an undo operation to the Pro undo/redo stack on EditOperation.Execute."

https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Editing 

0 Kudos