I have tried to use the Change Version (ArcGIS Pro 2.4 API Reference Guide) method on my current map and do not get the results I would expect. I copied the code example directly into a button action. The UI doesn't show that the version has changed and there are no errors reported. My Map has layers using the classic versioning model. Is there something else that needs to be done to the UI to refresh? Is there another way to get all the layers in a map to point to a different version?
#arcgisprosdk
If you haven't done so already, I would take a look at toVersion.GetName() prior to calling Map.ChangeVersion() to verify that the value is expected.
Outside of that, I don't have any other ideas. I set up an Oracle 12 environment that used classic versioning, and ran the sample code to switch the version from SDE.DEFAULT to the next version in the list (GDB.foo). It all works correctly, and the Map refreshes afterwards.
You may need to open an incident with tech support to figure out why this isn't working for you.
--Rich
A-ha! Thanks for following up.
The issue in the Oracle instance where this failed to work was that there was a version set to public but it's parent was set to private. When the version manager is opened in ArcGIS Pro this version was marked red and version tools would not behave until this issue was cleared up.
Here's the updated code I ran (changes in red). The first time it ran I noticed that the first version was owned by another user but set to public. I thought that might be an issue so I added the IsOwner and still got the same lack of result.
await QueuedTask.Run(() => { FeatureLayer flyr = MapView.Active.Map.GetLayersAsFlattenedList() .OfType<FeatureLayer>().FirstOrDefault(); //first feature layer Datastore dataStore = flyr.GetFeatureClass().GetDatastore(); //getting datasource Geodatabase geodatabase = dataStore as Geodatabase; //casting to Geodatabase if (geodatabase == null) return; VersionManager versionManager = geodatabase.GetVersionManager(); ArcGIS.Core.Data.Version currentVersion = versionManager.GetCurrentVersion(); //Getting all available versions except the current one IEnumerable<ArcGIS.Core.Data.Version> versions = versionManager.GetVersions() .Where(v => !v.GetName().Equals(currentVersion.GetName(), StringComparison.CurrentCultureIgnoreCase) && v.IsOwner()); foreach (var item in versions) { System.Diagnostics.Debug.WriteLine(item.GetName()); } //Assuming there is at least one other version we pick the first one from the list ArcGIS.Core.Data.Version toVersion = versions.FirstOrDefault(); if (toVersion != null) { //Changing version MapView.Active.Map.ChangeVersion(currentVersion, toVersion); }
Could you change the code to iterate through the versions on the geodatabase connection and verify that you are seeing all of the expected versions? I'm trying to figure out if the problem is with versioning or with actually switching the map layers.
Thanks,
Sure got to start with the easy questions. All the layers in my map (except basemap) are versioned pointing to an Oracle 12.1 enterprise geodatabase.
Jimmy,
At the risk of asking a stupid question, is the first layer in your map a feature layer that points to a versioned feature class? That sample code only works if that is the case.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.