I have a Versioned Database reading and writing information from both the Desktop Environment and Collector for ArcGIS. I have a Server for ArcGIS, running an Advanced License. I would like users with a Basic License to be able to access published Advanced Geoprocessing (GP) Services / Tools and maintain the database using a series of my own Toolboxes.
As a test of the concept I have performed a Reconcile on my Database and published it to my Server as a Geoprocessing Service. The service runs as you would expect when run off the Server. The issue that I am having is the number of Versions of the Database will change as new users logon and create edit sessions (Primarily new devices connecting via the Collector App).
Is there a way to publish a GP Service that allows for a Dynamic input?
Allowing for the input versions list to be updated as the number of versions update. Running it off an Advanced License, this is accomplished by:
versionList = arcpy.ListVersions("Connection_To_Database")
If I try and run the Service using arcpy and updating the version list, I am presented an error:
Traceback (most recent call last): File "", line 107, in execute File "https://linktomyserver ; Geoprocessing/GP_ReconcileVersions", line 93, in ReconcileVersions ExecuteError: Failed to execute. Parameters are not valid. ERROR 000800: The value is not a member of DBO.Esri_Anonymous_P_1517838606513. ERROR 000800: The value is not a member of DBO.Esri_Anonymous_P_1517838606513. Failed to execute (ReconcileVersions).
From what I can see here, the DBO.Esri_Anonymous_P_1517838606513 is a new version I created when I logged onto the Collector and created a new Offline Map. Which is a reasonable example of a real-world instance.
I have also created a Toolbox, which calls the published GP Service. My Toolbox is running the following code:
Source = parameters.valueAsText arcpy.AddMessage(str(Source)) Input = str(Source) arcpy.AddMessage(str(Input)) read_lines = [line.rstrip('\n') for line in open(Input)] Conn = read_lines InputText = Conn arcpy.AddMessage(Conn) arcpy.AddMessage("Connecting to Server Toolbox - GP Reconcile - Testing 1") arcpy.ImportToolbox("Link t to my server/rest/services;Geoprocessing/GP_ReconcileVersions","Reconcile Versions") arcpy.AddMessage("Toolbox Connection Established") versionList = arcpy.ListVersions(InputText) arcpy.AddMessage(str(versionList)) #arcpy.ReconcileVersions_management(InputText, "ALL_VERSIONS", "sde.DEFAULT", versionList, "NO_LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "KEEP_VERSION") #arcpy.ReconcileVersions_GPReconcileVersions(InputText, "ALL_VERSIONS", "sde.DEFAULT", versionList, "NO_LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "KEEP_VERSION") result = arcpy.ReconcileVersions_GPReconcileVersions("ALL_VERSIONS", "sde.DEFAULT", versionList, "NO_LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "KEEP_VERSION") while result.status < 4: arcpy.AddMessage(result.status) time.sleep(0.2) arcpy.AddMessage("Reconcile completed") return
I have a few lines of code in there which are just for my own debugging and will be removed. The code works if I am calling a "Local" reconcile tool, but fails with the error presented when I try and call the published GP Service. I used this example: ArcGIS: Using a service in python