Hi,
I have problem with version changing. I used this chunk of code for it:
public static async Task ChangeVersion(Map map, Geodatabase geodatabase, string nameNewVersion)
{
await QueuedTask.Run(() =>
{
if (geodatabase == null)
return;
VersionManager versionManager = geodatabase.GetVersionManager();
ArcGIS.Core.Data.Version currentVersion = versionManager.GetCurrentVersion();
ArcGIS.Core.Data.Version toVersion = versionManager.GetVersion(nameNewVersion);
if (toVersion != null)
{
//Changing version
map.ChangeVersion(currentVersion, toVersion);
}
});
}
This works fine, if I use it at MapView. But If I try to use it at LayoutView, where I need to change source for layers in the map frame, I get this error: An unknown error occured while changing the database version.
I don't know if it is possible to do it that way. Is there even possible in SDK to change version only for one featureLayer as it was possible in ArcGIS Desktop? I can't find such possibility in ArcGIS Pro SDK...
I get the map for changing by this code:
Project proj = Project.Current;
Map map = null;
if (aprxName.Contains("vystup"))
{
LayoutProjectItem layoutProjItem = proj.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(aprxName, StringComparison.CurrentCultureIgnoreCase));
if (layoutProjItem != null)
{
Layout lyt = await QueuedTask.Run(() => layoutProjItem.GetLayout());
var mapPane = ProApp.Panes.OfType<ILayoutPane>().FirstOrDefault(mPane => (mPane as Pane).ContentID == layoutProjItem.Path);
if (mapPane != null)
{
var pane = mapPane as Pane;
pane.Activate();
//Reference MapFrame
MapFrame mf = lyt.FindElement("ZTM_50_edit") as MapFrame;
//Reference map and layer
map = mf.Map;
}
}
}