Scenario:
SDE database. Feature class registered as versioned. Traditional versioning with DEFAULT version only. Version access public. ArcGIS Pro Options | Editing | “Enable and disable from the Edit tab” = True and “Single workspace edit session” selected.
Behavior using esri_editing_ToggleEditBtn:
Two separate ArcGIS Pro instances open. Start editing in instance 1 using the Ribbon | Edit tab | Edit button (esri_editing_ToggleEditBtn). Edit attribute in feature class. Save edits and stop editing. Start editing in instance 2 using the esri_editing_ToggleEditBtn. Attributes in same feature class in instance 2 refresh with edit made in instance 1.
Behavior using SetIsEditingEnabledAsync:
Same two separate ArcGIS Pro instances open. Start editing in instance 1 using the esri_editing_ToggleEditBtn. Edit attribute in feature class. Save edits and stop editing. Start editing in instance 2 using Project.Current.SetIsEditingEnabledAsync(true). Following pattern shown here: https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-Editing#enable-editing-1. Attributes in feature class in instance 2 DO NOT refresh to edit made in instance 1.
Attempts to refresh otherwise:
I have tried running the following in an awaited QueuedTask prior to running SetIsEditingEnabledAsync from another awaited QueuedTask:
var connectionString = new Uri("C:\\dir\\my_sde.sde");
using var gdb = new Geodatabase(new DatabaseConnectionFile(connectionString));
using var versionManager = gdb.GetVersionManager();
using var version = versionManager.GetCurrentVersion();
version.Refresh();
If an edit session was previously started via SetIsEditingEnabledAsync, then version.Refresh() throws error: ArcGIS.Core.Data.Exceptions.GeodatabaseEditingException: 'This operation is not allowed while editing.' This occurs even after having run Project.Current.SetIsEditingEnabledAsync(false);.
Questions:
Why does Project.Current.SetIsEditingEnabledAsync(true) not refresh attributes the same way the esri_editing_ToggleEditBtn does?
What is the best way to refresh attributes when starting an edit session via Project.Current.SetIsEditingEnabledAsync(true)?
I am looking at this issue, but in the meantime i think you can just use the button directly instead of setting the set enable editing API method:
// if not editing
if (!Project.Current.IsEditingEnabled)
{
var res = MessageBox.Show("You must enable editing to use editing tools. Would you like to enable editing?",
"Enable Editing?", System.Windows.MessageBoxButton.YesNoCancel);
if (res == System.Windows.MessageBoxResult.No ||
res == System.Windows.MessageBoxResult.Cancel)
{
return;
}
// Project.Current.SetIsEditingEnabledAsync(true);
// use the esri_editing_ToggleEditingBtn instead for .SetIsEditingEnabledAsync
var damlId = "esri_editing_ToggleEditingBtn";
IPlugInWrapper wrapper = FrameworkApplication.GetPlugInWrapper(damlId);
var command = wrapper as ICommand;
if ((command != null) && command.CanExecute(null))
command.Execute(null);
}
Thank you, that approach does solve the initial issue. Unfortunately, it creates another issue in my application. I do need the process to enable editing to complete prior to running a few other tasks, so changing from SetIsEditingEnabledAsync() is causing issues. Is there a way I can run your snippet and await a completed task? I looked at setting up ICommand to run as an async task, but that is looking pretty complicated.
Thanks for the reply. I am aiming to look into this workaround soon.