I am trying to figure out the best way to create web maps with editing capabilities for our operators out in the field. Similar to a QA/QC type of situation. From what I've read and tried the only way to allow our operators editing access is by creating a version called [Operators] and publishing it with full editing capabilities. Please correct me if there is a better way to do it. And the other thing is the reconcile / post maintenance script we have. The script does a full compression every 2 weeks. Essentially it's deleting all the versions. If it's deleting the version [Operator] does that mean the web map will not work? Does anyone happen to know a workflow that will be useful?
Software:
ArcGIS Enterprise 10.6
Portal 10.6
ArcMap 10.5
import arcpy, time, smtplib, os
deleteVersions = True
arcpy.env.overwriteOutput = True
reconcileLog = r'C:\temp\Weekly_Reconcile_Log\Reconcile_Log.txt'
# set the workspace
arcpy.env.workspace = 'C:\Users\jnmiller\AppData\Roaming\ESRI\Desktop10.5\ArcCatalog\SDE.sde'
# Set a variable for the workspace
adminConn = arcpy.env.workspace
# Block new connections to the database.
print("The database is no longer accepting connections")
arcpy.AcceptConnections(adminConn, False)
# Wait 15 minutes
#time.sleep(900)
# Disconnect all users from the database.
print("Disconnecting all users")
arcpy.DisconnectUser(adminConn, "ALL")
# Get a list of versions to pass into the ReconcileVersions tool.
print("Getting list of all versions")
versionList = arcpy.ListVersions(adminConn)
for version in versionList:
if 'default' in version.lower():
if 'dbo' in version.lower():
defaultVersion = 'dbo.DEFAULT'
elif 'sde' in version.lower():
defaultVersion = 'sde.DEFAULT'
# Execute the ReconcileVersions tool.
print("Reconciling/posting/deleting all versions")
if deleteVersions:
try:
arcpy.ReconcileVersions_management(adminConn, "ALL_VERSIONS", defaultVersion, versionList, "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "DELETE_VERSION", reconcileLog)
except:
reconcileMessage = "Reconcile failed: " + arcpy.GetMessages() + ". Check reconcilelog.txt file in the " + str(reconcileLog)
arcpy.AddWarning(reconcileMessage)
pass
else:
try:
arcpy.ReconcileVersions_management(adminConn, "ALL_VERSIONS", defaultVersion, versionList, "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "KEEP_VERSION", reconcileLog)
except:
reconcileMessage = "Reconcile failed: " + arcpy.GetMessages() + ". Check reconcilelog.txt file in the " + str(reconcileLog)
arcpy.AddWarning(reconcileMessage)
pass
print("Completed Reconcile & Post")
# Run the compress tool.
print("Running compress")
arcpy.Compress_management(adminConn)
print("Compress Completed")
# Allow the database to begin accepting connections again
print("Allow users to connect to the database again")
arcpy.AcceptConnections(adminConn, True)
print("Starting Rebuild Indexes")
# Get a list of all the datasets the user has access to.
# First, get all the stand alone tables, feature classes and rasters.
dataList = arcpy.ListTables() + arcpy.ListFeatureClasses() + arcpy.ListRasters()
# Next, for feature datasets get all of the datasets and featureclasses
# from the list and add them to the master list.
for dataset in arcpy.ListDatasets("", "Feature"):
arcpy.env.workspace = os.path.join(adminConn,dataset)
dataList += arcpy.ListFeatureClasses() + arcpy.ListDatasets()
# Get the user name for the workspace
userName = arcpy.Describe(adminConn).connectionProperties.user.lower()
# remove any datasets that are not owned by the connected user.
userDataList = [ds for ds in dataList if ds.lower().find(".%s." % userName) > -1]
# Execute rebuild indexes
# Note: to use the "SYSTEM" option the workspace user must be an administrator.
arcpy.RebuildIndexes_management(adminConn, "SYSTEM", userDataList, "ALL")
print('Rebuild Complete')
# Update statistics on the system tables
print("Updating statistics on the system tables")
# Execute analyze datasets
# Note: to use the "SYSTEM" option the workspace user must be an administrator.
arcpy.AnalyzeDatasets_management(adminConn, "SYSTEM", userDataList, "ANALYZE_BASE","ANALYZE_DELTA","ANALYZE_ARCHIVE")
print("Analyze Complete")
print("Finished.")
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>