Select to view content in your preferred language

ArcGIS Pro SDK & Change Moment

1154
6
08-03-2023 02:54 PM
JonathanBurmeister
New Contributor II

Hi everyone,

I am attempting to add functionality to a custom ArcGIS Pro 3.1 add-in to set a specific date and time and apply the time as a historical moment. With the feature service data source that I am using, I am able the do this manually by selecting the data source, selecting Change Moment, entering the specific date & time, and then selecting the apply button.

I would like to create behavior within the add-in to do the same thing using the ArcGIS Pro SDK. Does the SDK support changing the map version to a specific date and time?

Also, the Historical Markers option on the History pane is disabled. I am assuming it is disable because it is not supported while using a feature service, but I cannot find documentation if this is correct or not. Can someone point me to documentation about the History pane the Historical Moments requirements?

I would appreciate any help, Jon

JonathanBurmeister_0-1691099637480.png

 

0 Kudos
6 Replies
Aashis
by Esri Contributor
Esri Contributor

Yes. Consult Map.ChangeVersion and historical version.

 

0 Kudos
JonathanBurmeister
New Contributor II

Aashis,

Thanks for replying.

I was looking for information about changing the map version to a historical version with a Feature Service Feature Class data source. The examples in the historical version link you provided utilize a SDE data source, and I was looking for documentation that specifies if Feature Service Feature Class data sources are supported when calling CreateHistoricalVersion.

HistoricalVersion historicalVersion = versionManager.CreateHistoricalVersion(new HistoricalVersionDescription("Historical marker snapshot at the moment", DateTime.Now));

The reason I ask is because when using a Feature Service Feature Class data source, CreateHistoricalVersion raises an exception with the message “The underlying data store does not support this operation.”

What I also would like to do is use the ‘Specific Date and Time (UTC)’ functionality with a Feature Service Feature Class data source and I was also wondering if that was exposed in the ArcGIS Pro 3.1 SDK as well. I am currently attempting to use the logic below to select a specific date/time, but it appears ChangeVersion is handling an exception and displaying the attached error image.

Does the ArcGIS Pro 3.1 SDK support changing the map version to a specific date and time while connected to a Feature Service Feature Class data source?

Thanks again for your help, Jon

JonathanBurmeister_0-1691174386632.png

 using (Datastore datastore = table.GetDatastore())
{
Geodatabase geodatabase = datastore as Geodatabase;
using (VersionManager versionManager = geodatabase.GetVersionManager())
{
HistoricalVersion historicalVersion = versionManager.GetHistoricalVersion(archiveRecordTime);
VersionBaseType versionBaseType = versionManager.GetCurrentVersionBaseType();
if (versionBaseType == VersionBaseType.Version)
{
ArcGIS.Core.Data.Version fromVersion = versionManager.GetCurrentVersion();
MapView.Active.Map.ChangeVersion(fromVersion, historicalVersion);
}
if (versionBaseType == VersionBaseType.HistoricalVersion)
{
HistoricalVersion fromHistoricVersion = versionManager.GetCurrentHistoricalVersion();
MapView.Active.Map.ChangeVersion(fromHistoricVersion, historicalVersion);
}
}
}
0 Kudos
JonathanBurmeister
New Contributor II

Hi again Rich,

When calling MapView.Active.Map.ChangeVersion(fromVersion, historicalVersion), the map seems to handle an error with a message 'An unknown error occurred while changing the database version. Failed to change the database time.' 

JonathanBurmeister_0-1691675210913.png

The SDK seems to be hiding an error with my code or something with the underlying feature service database. 

Do you know where I can find more information about this condition when attempting to change to a historic version using a feature service?

Using the Change Moment (History) pane in ArcGIS Pro 3.1, changing to a Specific Date and Time works correctly with the same project.

Thanks again, Jon

0 Kudos
RichRuh
Esri Regular Contributor

I don't know of any particular thing that would cause this error.

Some troubleshooting tips-

1. Simplify the map to only one feature class to see if that works.  Re-add layers one at a time to see if you can find one causing a problem.

2. If you're skilled with fiddler, you could compare the `query` calls generated by the SDK vs. the calls that are sent to the service after changing the moment in the Pro UI.  (Passing the wrong moment?)

Sorry I can't be of more help,

--Rich

0 Kudos
RichRuh
Esri Regular Contributor

Jonathan,

VersionManager.CreateHistoricalVersion is used to create a named historical version in an enterprise geodatabase. As you noted, that's not supported with feature services.

To connect to an historical moment, create an HistoricalVersion object using VersionManager.GetHistoricalVersion(DateTime), then pass it to ChangeVersion as your code sample above already shows.

I hope this helps,

--Rich

 

JonathanBurmeister
New Contributor II

Hi Rich,

Thank you for the quick response. It is good to know that the named historical version is not supported using a feature service but a specific date/time is supported. 

I'll focus on that and let you know when I am successful. 

Again, I appreciate your response.

Thanks, Jon 

0 Kudos