AnsweredAssumed Answered

Managing Data - Can I query Feature Service Information

Question asked by Nebaku on Jul 27, 2017
Latest reply on Jul 31, 2017 by sethlewistempe

We are trying to migrate some feature classes and feature tables from an older geodatabase(Oracle) to a new 10.5X geodatabase(SQL).

 

One of the underlying question is whether or not our ArcGIS Server has a published feature service connected to the data in the older geodatabase.

Can I quickly query the ArcGIS Server that has 50+ services to get a list of all of the tables that I "shouldn't move".  I'm hoping there is a "connection string" like attribute that I can query.

 

Thanks!

I found a workable solution below.  On your old ArcGIS 10 server, copy the .msd folders to a new location from arcgisserver\arcgisinput\ and run python similar to below. 

It goes through the folders that are in the same directory as this python script and finds .msd files.  Then it will collect the connection string from those files.

##################################################################

import arcpy,sys, string, os, arcgisscripting,arcpy,traceback,csv,zipfile,time,logging
from arcpy import env
from time import gmtime, strftime
from xml.etree.cElementTree import iterparse
#FIRST COPY ALL YOUR MSD FILES FROM YOUR ARCGIS SERVER into a seperate location and then place the python script in that location as well.
#FOR MY CASE IT WAS HERE c:\arcgisserver\arcgisinput
data_path =              (os.path.dirname(sys.argv[0]) + "/")
FileDate =               str(strftime("%a, %d %b %Y", gmtime()))
TXTFILEOUTPUT =          data_path + "MSD_RESULTS_"+ FileDate+".txt"
f = open(TXTFILEOUTPUT,'a')
def PrintMessage(MESSAGE,DEFINEDWRITINGTOOL):
     try:
          DEFINEDWRITINGTOOL.write(str(MESSAGE) + '\n')
     except:
          pass

def sListInfo(MSD):
     MSD = zipfile.ZipFile(MSD)
     for name in MSD.namelist():
          for _event, elem in iterparse(MSD.open(name)):
               if elem.tag == "WorkspaceConnectionString" or elem.tag =="Dataset":
                    for items in elem.text.split(';'):
                         PrintMessage('          '+ str(items),f)
     MSD.close()
                              ##data_path is the folder that I am running the python script from, you can always hard code instead. ##
for root, dirs, files in os.walk(data_path):
     for file in files:
          if file.endswith(".msd"):
               MapService = os.path.join(root, file).replace("/","\\")
               PrintMessage("#######################################################################################################################################",f)
               PrintMessage(MapService,f)
               sListInfo(MapService)
               PrintMessage("#######################################################################################################################################",f)

Outcomes