Show which users have an offline area downloaded

369
1
06-28-2023 01:41 PM
Status: Open
Labels (1)
L77
by
Occasional Contributor

It would be nice in Field Maps Designer to be able to see which users have an offline area downloaded in the designer section of each map.

 

1 Comment
DougBrowning

Just saw the new version of Pro will have it.

DougBrowning_0-1688047340601.png

 

For now I am using a python script to make a report.  As long as Pro is logged in it will grab the credentials from there.  it gives the username and last date, etc.

# gets a list of replicas for a given HFS (hosted feature service)


import arcpy
from arcgis.gis import GIS
import arcgis
from arcgis.features import FeatureLayerCollection

gis = GIS('pro')

#gis = arcgis.GIS(profile_name=profile)
#itemID of service
# Lotic
itemID = "713e3aaef967447d618"


item = gis.content.get(itemID)
flc = FeatureLayerCollection.fromitem(item)
replicas = flc.replicas.get_list()
print ("ReplicaOwner,ReplicaName,ReplicaID,CreateDate,LastSyncDate")
for r in replicas:
    replica = flc.replicas.get(r['replicaID'])
    create_date = datetime.datetime.fromtimestamp(replica['creationDate'] / 1000)
    last_sync_date = 'n/a' # don't trust this to always be populated
    if type(replica['lastSyncDate']) is int:
        last_sync_date = datetime.datetime.fromtimestamp(replica['lastSyncDate'] / 1000)

    print(replica['replicaOwner'] + "," + replica['replicaName'] + "," + replica['replicaID'] + "," + str(create_date) + "," + str(last_sync_date))

You can take the output and paste into Excel.  (sorry was just a quick script you could add to a csv right away)

I also have a script that takes a list from this and will unregister in bulk

# Unregisters a list of given replica ids - usually from the List replicas script


import requests, arcpy

# sameple  https://services.myserver.com/lidGgNLxw9LL0SbI/ArcGIS/rest/services/SaveTheBay/FeatureServer/unRegisterReplica?replicaID={b7b70c50-7b8d-4938-a6f9-61f376e94c75 }

# read in the list of replcias to remove from file
replicaFile = r"ReplicaListBeforeJuly15.txt"
replicaRead = open(replicaFile,"r")
replicaList = replicaRead.read().splitlines()
replicaRead.close()

print ("Read in list")

# base URL to the HFS
serviceURL = 'https://services1.arcgis.com/Hp6G80Pky0om7QvQ/arcgis/rest/services/youragolserviceService/FeatureServer/unRegisterReplica?replicaID='

token = arcpy.GetSigninToken()
##if token is not None:
##    print(token['token'])

for replica in replicaList:

    print ("Removing Replica " + replica)
    urlResponse = requests.post(serviceURL + "{" + replica + "}&token=" + token['token'])

    #print(urlResponse.text)

 I use this to unregister old replicas on the regular.  As we get more and more it gets unreliable.  We keep having old ones since there is a bug in Field Maps that if you remove an offline area while offline it never tells the service to remove the replica.  You can see it fail in the logs.  I told the team but I do not think it ever got fixed since they think it works but I showed it does not.

Hope that helps