def main(argv = None): success = True targetName = '' try: if not arcpy.Exists(gzSupport.workspace): gzSupport.addMessage(gzSupport.workspace + " does not exist, attempting to create") gzSupport.createGizintaGeodatabase() else: gzSupport.compressGDB(gzSupport.workspace) if len(datasets) > 0: progBar = len(datasets) + 1 arcpy.SetProgressor("step", "Importing Datasets...", 0,progBar, 1) #gzSupport.deleteExistingRows(datasets) arcpy.SetProgressorPosition() for dataset in datasets: gzSupport.sourceIDField = dataset.getAttributeNode("sourceIDField").nodeValue sourceName = dataset.getAttributeNode("sourceName").nodeValue targetName = dataset.getAttributeNode("targetName").nodeValue xmlFields = gzSupport.getXmlElements(gzSupport.xmlFileName,"Field") arcpy.SetProgressorLabel("Loading " + sourceName + " to " + targetName +"...") if not arcpy.Exists(os.path.join(sourceWorkspace,sourceName)): gzSupport.addError(os.path.join(sourceWorkspace,sourceName + " does not exist, exiting")) return if not arcpy.Exists(os.path.join(gzSupport.workspace,targetName)): gzSupport.addMessage(os.path.join(gzSupport.workspace,targetName) + " does not exist") else: arcpy.Delete_management(os.path.join(gzSupport.workspace,targetName)) arcpy.env.Workspace = gzSupport.workspace try: retVal = gzSupport.exportDataset(sourceWorkspace,sourceName,targetName,dataset, xmlFields) if retVal == False: success = False except: gzSupport.showTraceback() success = False retVal = False gzSupport.logDatasetProcess(sourceName,targetName,retVal) arcpy.SetProgressorPosition() except: gzSupport.showTraceback() gzSupport.addError("A Fatal Error occurred") success = False gzSupport.logDatasetProcess("extractWorkspaceToGDB",targetName,False) finally: arcpy.ResetProgressor() arcpy.RefreshCatalog(gzSupport.workspace) try: arcpy.ClearWorkspaceCache_management(gzSupport.workspace) arcpy.ClearWorkspaceCache_management(sourceWorkspace) except: gzSupport.addMessage("Unable to clear workspace cache, continuing") if success == False: gzSupport.addError("Errors occurred during process, look in log files for more information") if gzSupport.ignoreErrors == True: success = True gzSupport.closeLog() arcpy.SetParameter(SUCCESS, success)
def main(argv = None): # process one or more views global log, playlists_xml outputSuccess = True # default value, will be set to False if any processing errors returned processed = 0 plist = fixConfigPath(playlist_xml) xmlDataDoc = xml.dom.minidom.parse(plist) datasets = gzSupport.getXmlElements(plist,"Dataset") for dataset in datasets: name = dataset.getAttributeNode("name").nodeValue try: name = dataset.getAttributeNode("targetName").nodeValue # special case to handle multi sources to one target. except: pass printmsg(name) changeNodes = dataset.getElementsByTagName("ChangeDetection") if len(changeNodes) == 0: printmsg("No Change Detection Node") else: changeNode = changeNodes[0] exceptProd = changeNode.getAttributeNode("exceptProductionView").nodeValue exceptStaging = changeNode.getAttributeNode("exceptStagingView").nodeValue fieldStr = changeNode.getAttributeNode("viewFields").nodeValue fieldStr = fieldStr.replace(" ","") fields = fieldStr.split(",") eprodSql = getExceptProdViewSql(name,exceptProd,exceptStaging,fields) estagingSql = getExceptStagingViewSql(name,exceptProd,exceptStaging,fields) retVal = createView(exceptProd,eprodSql) if retVal == False: outputSuccess = False createView(exceptStaging,estagingSql) if retVal == False: outputSuccess = False log.close()
# --------------------------------------------------------------------------- # Copyright 2012-2013 Vertex3 Inc # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. import os, sys, traceback, time, arcpy, xml.dom.minidom, gzSupport gzSupport.xmlFileName = arcpy.GetParameterAsText(0) # xml file name as a parameter gzSupport.workspace = arcpy.GetParameterAsText(1) # Gizinta Geodatabase sourceFieldQA = arcpy.GetParameterAsText(2) # True/False targetFieldQA = arcpy.GetParameterAsText(3) # True/False gzSupport.ignoreErrors = gzSupport.strToBool(arcpy.GetParameterAsText(4)) # boolean indicates whether to return False if errors encountered SUCCESS = 5 # parameter number for output success value gzSupport.startLog() xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(xmlDoc,"Dataset") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode("errorTableName").nodeValue valueMaps = gzSupport.getXmlElements(xmlDoc,"ValueMap") def main(argv = None): success = True gzSupport.compressGDB(gzSupport.workspace) if len(datasets) > 0: progBar = len(datasets) arcpy.SetProgressor("step", "Running QA...", 0,progBar, 1) for dataset in datasets: arcpy.env.Workspace = gzSupport.workspace name = dataset.getAttributeNode("name").nodeValue gzSupport.sourceIDField = dataset.getAttributeNode("sourceIDField").nodeValue
# --------------------------------------------------------------------------- # Copyright 2012-2014 Vertex3 Inc # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. import os, sys, traceback, time, arcpy, xml.dom.minidom, gzSupport, myGizinta gzSupport.xmlFileName = arcpy.GetParameterAsText( 0) # xml file name as a parameter gzSupport.workspace = arcpy.GetParameterAsText(1) # Gizinta Geodatabase gzSupport.ignoreErrors = gzSupport.strToBool(arcpy.GetParameterAsText( 2)) # boolean indicates whether to return False if errors encountered SUCCESS = 3 # parameter number for output success value gzSupport.startLog() xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(gzSupport.xmlFileName, "Dataset") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode( "errorTableName").nodeValue valueMappings = gzSupport.getXmlElements(gzSupport.xmlFileName, "ValueMaps") def main(argv=None): success = True gzSupport.compressGDB(gzSupport.workspace) arcpy.ClearWorkspaceCache_management(gzSupport.workspace) tables = gzSupport.listDatasets(gzSupport.workspace) tNames = tables[0] tFullNames = tables[1]
gzSupport.xmlFileName = arcpy.GetParameterAsText(0) # xml file name as a parameter gzSupport.workspace = arcpy.GetParameterAsText(1) # Gizinta Geodatabase defaultWorkspace = arcpy.GetParameterAsText(2) # Connection to the default version targetWorkspace = arcpy.GetParameterAsText(3) # Connection to the version to be used/updated gzSupport.ignoreErrors = gzSupport.strToBool( arcpy.GetParameterAsText(4) ) # boolean indicates whether to return False if errors encountered SUCCESS = 5 # parameter number for output success value if targetWorkspace == "" or targetWorkspace == "#": targetWorkspace = defaultWorkspace gzSupport.startLog() xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(gzSupport.xmlFileName, "Dataset") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode("errorTableName").nodeValue settings = gzSupport.getXmlElements(gzSupport.xmlFileName, "AppendSettings")[0] fieldNames = gzSupport.getNodeValue(settings, "FieldNames") fieldNames = fieldNames.split(",") try: versionName = gzSupport.getNodeValue(settings, "VersionName") defaultVersionName = gzSupport.getNodeValue(settings, "DefaultVersionName") except: versionName = None defaultVersionName = None
sourceGDB = arcpy.GetParameterAsText(0) # workspace / connection file if sourceGDB == "#" or sourceGDB == "": sourceGDB = "Sample.gdb" # you can set this to a default like this if you want. targetGDB = arcpy.GetParameterAsText(1) # workspace / connection file if targetGDB == "#" or targetGDB == "": targetGDB = "Sample(WebMercator).gdb" # you can set this to a default like this if you want. gzSupport.workspace = targetGDB # target Geodatabase gzSupport.xmlFileName = arcpy.GetParameterAsText(2) # optional - xml File for list of datasets datasetNames = [] if gzSupport.xmlFileName == "#" or gzSupport.xmlFileName == "": gzSupport.xmlFileName = None else: xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(gzSupport.xmlFileName,"Dataset") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode("errorTableName").nodeValue for dataset in datasets: name = dataset.getAttributeNode("name").nodeValue datasetNames.append(name.upper()) SUCCESS = 3 # parameter number for output success value gzSupport.startLog() def main(argv = None): # main function - list the source and target datasets, then append where there is a match on non-prefixed name success = True name = '' arcpy.ClearWorkspaceCache_management(gzSupport.workspace)
# This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. import os, sys, traceback, time, datetime as dt, arcpy, xml.dom.minidom, gzSupport gzSupport.xmlFileName = arcpy.GetParameterAsText( 0) # xml file name as a parameter cadFolder = arcpy.GetParameterAsText(1) # Folder to scan for drawing files since = arcpy.GetParameterAsText(2) # date since file name as a parameter gzSupport.workspace = arcpy.GetParameterAsText(3) # Gizinta Geodatabase gzSupport.ignoreErrors = gzSupport.strToBool(arcpy.GetParameterAsText( 4)) # boolean indicates whether to return False if errors encountered SUCCESS = 5 # parameter number for output success value gzSupport.startLog() xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(xmlDoc, "CADDataset") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode( "errorTableName").nodeValue cadExt = rootElem.getAttributeNode("fileExtension").nodeValue def main(argv=None): success = True if not arcpy.Exists(gzSupport.workspace): gzSupport.addMessage(gzSupport.workspace + " does not exist, attempting to create") gzSupport.createGizintaGeodatabase() else: gzSupport.compressGDB(gzSupport.workspace)
# Copyright 2012-2013 Vertex3 Inc # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. import os, sys, traceback, time, arcpy, xml.dom.minidom, gzSupport gzSupport.xmlFileName = arcpy.GetParameterAsText( 0) # xml file name as a parameter sourceLayer = arcpy.GetParameterAsText(1) # Source Layer File to load from gzSupport.workspace = arcpy.GetParameterAsText(2) # Gizinta Geodatabase gzSupport.ignoreErrors = gzSupport.strToBool(arcpy.GetParameterAsText( 3)) # boolean indicates whether to return False if errors encountered SUCCESS = 4 # parameter number for output success value gzSupport.startLog() xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(xmlDoc, "MapLayer") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode( "errorTableName").nodeValue def main(argv=None): success = True try: if not arcpy.Exists(gzSupport.workspace): gzSupport.addMessage(gzSupport.workspace + " does not exist, attempting to create") gzSupport.createGizintaGeodatabase() else: gzSupport.compressGDB(gzSupport.workspace)
import os, sys, traceback, arcpy, gzSupport # Local variables... debug = False # Parameters sourceGDB = arcpy.GetParameterAsText(0) # workspace / connection file if sourceGDB == "#" or sourceGDB == "": sourceGDB = "Sample.gdb" gzSupport.xmlFileName = arcpy.GetParameterAsText(1) # optional - xml File for list of datasets datasetNames = [] if gzSupport.xmlFileName == "#" or gzSupport.xmlFileName == "": gzSupport.xmlFileName = None else: xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(xmlDoc,"Dataset") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode("errorTableName").nodeValue for dataset in datasets: name = dataset.getAttributeNode("name").nodeValue datasetNames.append(name.upper()) SUCCESS = 2 # parameter number for output success value gzSupport.startLog() def main(argv = None): # main function - list the datasets and delete rows success = True try: names = gzSupport.listDatasets(sourceGDB)
# Description: Import a set of .lyr files to Geodatabase. # --------------------------------------------------------------------------- # Copyright 2012-2013 Vertex3 Inc # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. import os, sys, traceback, time, arcpy, xml.dom.minidom, gzSupport gzSupport.xmlFileName = arcpy.GetParameterAsText(0) # xml file name as a parameter sourceLayer = arcpy.GetParameterAsText(1) # Source Layer File to load from gzSupport.workspace = arcpy.GetParameterAsText(2) # Gizinta Geodatabase gzSupport.ignoreErrors = gzSupport.strToBool(arcpy.GetParameterAsText(3)) # boolean indicates whether to return False if errors encountered SUCCESS = 4 # parameter number for output success value gzSupport.startLog() xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(xmlDoc,"MapLayer") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode("errorTableName").nodeValue def main(argv = None): success = True try: if not arcpy.Exists(gzSupport.workspace): gzSupport.addMessage(gzSupport.workspace + " does not exist, attempting to create") gzSupport.createGizintaGeodatabase() else: gzSupport.compressGDB(gzSupport.workspace) if len(datasets) > 0: progBar = len(datasets) + 1 arcpy.SetProgressor("step", "Importing Layers...", 0,progBar, 1)
def main(argv=None): success = True name = '' if not arcpy.Exists(gzSupport.workspace): gzSupport.addMessage(gzSupport.workspace + " does not exist, attempting to create") gzSupport.createGizintaGeodatabase() else: gzSupport.compressGDB(gzSupport.workspace) arcpy.ClearWorkspaceCache_management(gzSupport.workspace) try: gzSupport.addMessage("Looking for drawings modified since " + since) minTime = datetime.datetime.strptime(since, "%d/%m/%Y %I:%M:%S %p") cadFiles = gzSupport.getFileList(cadFolder, cadExt, minTime) if len(cadFiles) > 0: progBar = len(cadFiles) + 1 arcpy.SetProgressor("step", "Importing Drawings...", 0, progBar, 1) arcpy.SetProgressorPosition() gzSupport.deleteExistingRows(datasets) for item in cadFiles: cadPath = item[0] cadName = item[1] gzSupport.addMessage("Importing Drawing " + cadName) for dataset in datasets: try: name = dataset.getAttributeNode("sourceName").nodeValue except: name = dataset.getAttributeNode("name").nodeValue gzSupport.sourceIDField = dataset.getAttributeNode( "sourceIDField").nodeValue xmlFields = gzSupport.getXmlElements(gzSupport.xmlFileName, "Field") arcpy.SetProgressorLabel("Loading " + name + " for " + cadName + "...") arcpy.env.Workspace = gzSupport.workspace targetName = dataset.getAttributeNode("targetName").nodeValue sourceWorkspace = os.path.join(cadPath, cadName) exists = False if not arcpy.Exists( os.path.join(gzSupport.workspace, targetName)): gzSupport.addMessage( os.path.join(gzSupport.workspace, targetName) + " does not exist") else: exists = True #arcpy.Delete_management(os.path.join(gzSupport.workspace,targetName)) try: if not exists == True: retVal = gzSupport.exportDataset( sourceWorkspace, name, targetName, dataset, xmlFields) addDrawingField( os.path.join(gzSupport.workspace, targetName), cadName) else: retVal = importLayer(cadPath, cadName, dataset) addDrawingField( os.path.join(gzSupport.workspace, targetName), cadName) if retVal == False: success = False except: gzSupport.showTraceback() success = False retVal = False arcpy.env.Workspace = gzSupport.workspace gzSupport.logDatasetProcess(cadName, name, retVal) gzSupport.cleanupGarbage() arcpy.SetProgressorPosition() except: gzSupport.addError("A Fatal Error occurred") gzSupport.showTraceback() success = False gzSupport.logDatasetProcess("extractCADToGDB", name, False) finally: arcpy.ResetProgressor() arcpy.RefreshCatalog(gzSupport.workspace) arcpy.ClearWorkspaceCache_management(gzSupport.workspace) gzSupport.cleanupGarbage() if success == False: gzSupport.addError( "Errors occurred during process, look in log files for more information" ) if gzSupport.ignoreErrors == True: success = True gzSupport.closeLog() arcpy.SetParameter(SUCCESS, success)
def main(argv=None): success = True targetName = '' try: if not arcpy.Exists(gzSupport.workspace): gzSupport.addMessage(gzSupport.workspace + " does not exist, attempting to create") gzSupport.createGizintaGeodatabase() else: gzSupport.compressGDB(gzSupport.workspace) if len(datasets) > 0: progBar = len(datasets) + 1 arcpy.SetProgressor("step", "Importing Datasets...", 0, progBar, 1) #gzSupport.deleteExistingRows(datasets) arcpy.SetProgressorPosition() for dataset in datasets: gzSupport.sourceIDField = dataset.getAttributeNode( "sourceIDField").nodeValue sourceName = dataset.getAttributeNode("sourceName").nodeValue targetName = dataset.getAttributeNode("targetName").nodeValue xmlFields = gzSupport.getXmlElements(gzSupport.xmlFileName, "Field") arcpy.SetProgressorLabel("Loading " + sourceName + " to " + targetName + "...") if not arcpy.Exists(os.path.join(sourceWorkspace, sourceName)): gzSupport.addError( os.path.join(sourceWorkspace, sourceName + " does not exist, exiting")) return if not arcpy.Exists(os.path.join(gzSupport.workspace, targetName)): gzSupport.addMessage( os.path.join(gzSupport.workspace, targetName) + " does not exist") else: arcpy.Delete_management( os.path.join(gzSupport.workspace, targetName)) arcpy.env.Workspace = gzSupport.workspace try: retVal = gzSupport.exportDataset(sourceWorkspace, sourceName, targetName, dataset, xmlFields) if retVal == False: success = False except: gzSupport.showTraceback() success = False retVal = False gzSupport.logDatasetProcess(sourceName, targetName, retVal) arcpy.SetProgressorPosition() except: gzSupport.showTraceback() gzSupport.addError("A Fatal Error occurred") success = False gzSupport.logDatasetProcess("extractWorkspaceToGDB", targetName, False) finally: arcpy.ResetProgressor() arcpy.RefreshCatalog(gzSupport.workspace) try: arcpy.ClearWorkspaceCache_management(gzSupport.workspace) arcpy.ClearWorkspaceCache_management(sourceWorkspace) except: gzSupport.addMessage("Unable to clear workspace cache, continuing") if success == False: gzSupport.addError( "Errors occurred during process, look in log files for more information" ) if gzSupport.ignoreErrors == True: success = True gzSupport.closeLog() arcpy.SetParameter(SUCCESS, success)
import os, sys, traceback, time, arcpy, xml.dom.minidom, gzSupport gzSupport.xmlFileName = arcpy.GetParameterAsText(0) # xml file name as a parameter gzSupport.workspace = arcpy.GetParameterAsText(1) # Gizinta Geodatabase defaultWorkspace = arcpy.GetParameterAsText(2) # Connection to the default version targetWorkspace = arcpy.GetParameterAsText(3) # Connection to the version to be used/updated gzSupport.ignoreErrors = gzSupport.strToBool(arcpy.GetParameterAsText(4)) # boolean indicates whether to return False if errors encountered SUCCESS = 5 # parameter number for output success value if targetWorkspace == "" or targetWorkspace == "#": targetWorkspace = defaultWorkspace gzSupport.startLog() xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(xmlDoc,"Dataset") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode("errorTableName").nodeValue settings = gzSupport.getXmlElements(xmlDoc,"AppendSettings")[0] fieldNames = gzSupport.getNodeValue(settings,"FieldNames") fieldNames = fieldNames.split(",") try: versionName = gzSupport.getNodeValue(settings,"VersionName") defaultVersionName = gzSupport.getNodeValue(settings,"DefaultVersionName") except: versionName = None defaultVersionName = None
def sync(inputDrawing,playlists,GISStagingDefault_sde,GISProdDefault_sde,logfile): # sync from the staging database to prod. The staging database should have rows for the current drawing # This process will replace rows in the production database for the floor/drawing, it uses change detection if it is set up in the Gizinta Xml files global log log = logfile plists = playlists.split(" ") arcpy.AddMessage(playlists) datasets = [] for playlist in plists: #xmlFile = os.path.join(gse.configFolder,playlist + ".xml") datasets = datasets + gzSupport.getXmlElements(playlist,"Dataset") gzSupport.workspace = GISProdDefault_sde retVal = True if inputDrawing == '*': dwg = '*' drawingID = 'all' else: dwg = inputDrawing[inputDrawing.rfind(os.sep)+1:] drawingID = gseDrawing.getDrawingFromName(dwg) processed = [] for dataset in datasets: name = dataset.getAttributeNode("name").nodeValue try: name = dataset.getAttributeNode("targetName").nodeValue # special case to handle multi sources to one target. except: pass if name not in processed: sourceDataset = os.path.join(GISStagingDefault_sde,name) targetDataset = os.path.join(GISProdDefault_sde,name) changeNode = dataset.getElementsByTagName("ChangeDetection")[0] if changeNode != None and changeNode != []: try: processed.index(name) except: processed.append(name) # if there is a change node then do change detection using views arcpy.env.workspace = GISStagingDefault_sde desc = arcpy.Describe(os.path.join(GISProdDefault_sde,name)) idField = changeNode.getAttributeNode("idField").nodeValue try: viewIdField = changeNode.getAttributeNode("viewIdField").nodeValue if debug == True: msg("Using Change detection id field " + viewIdField) except: viewIdField = "floorid" # the default if inputDrawing != '*': if debug == True: msg("Using default id field " + viewIdField) whereClause = buildViewWhereClause(viewIdField,inputDrawing) adds = getChanges(changeNode,"exceptProductionView",GISStagingDefault_sde,whereClause,idField) deletes = getChanges(changeNode,"exceptStagingView",GISStagingDefault_sde,whereClause,idField) if len(deletes) > 0: deleteExpr = getDeltaWhereClause(desc,idField,deletes) arcpy.env.workspace = GISProdDefault_sde retcode = gzSupport.deleteRows(GISProdDefault_sde,name,deleteExpr) if retcode == True: msg(str(len(deletes)) + " Rows deleted in prod for " + name) else: msg("Failed to delete rows") retVal = False #else: # msg("No changed rows found to delete") if len(adds) > 0: addExpr = getDeltaWhereClause(desc,idField,adds) arcpy.env.workspace = GISProdDefault_sde gzSupport.workspace = GISProdDefault_sde retcode = gzSupport.appendRows(sourceDataset,targetDataset,addExpr) if retcode == True: msg(str(len(adds)) + " Rows appended in prod for " + name) else: msg("Failed to append rows for " + name) retVal = False #else: # msg("No changed rows found to add for " + name) del adds del deletes else: # if there is no change node then replace everything for a floor if inputDrawing == '*': idField = '' else: idField = "FLOORID" whereClause = buildViewWhereClause(idField,inputDrawing) desc = arcpy.Describe(sourceDataset) view = "tempCount" gzSupport.workspace = GISStagingDefault_sde arcpy.env.workspace = GISStagingDefault_sde gzSupport.makeView(desc.DataElementType,GISStagingDefault_sde,name,view,whereClause,[]) res = arcpy.GetCount_management(view) count = int(res.getOutput(0)) if(count > 0): msg("Replacing rows for " + name + ", " + str(count) + " rows") retcode = gzSupport.deleteRows(GISProdDefault_sde,name,whereClause) retcode = gzSupport.appendRows(sourceDataset,targetDataset,whereClause) else: msg("No rows in source database to update for " + name) del view #msg(processed) return retVal
if sourceGDB == "#" or sourceGDB == "": sourceGDB = "Sample.gdb" # you can set this to a default like this if you want. targetGDB = arcpy.GetParameterAsText(1) # workspace / connection file if targetGDB == "#" or targetGDB == "": targetGDB = "Sample(WebMercator).gdb" # you can set this to a default like this if you want. gzSupport.workspace = targetGDB datasetNames = [] gzSupport.xmlFileName = arcpy.GetParameterAsText(2) # optional - xml File for list of datasets datasetNames = [] if gzSupport.xmlFileName == "#" or gzSupport.xmlFileName == "": gzSupport.xmlFileName = None else: xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(gzSupport.xmlFileName,"Dataset") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode("errorTableName").nodeValue for dataset in datasets: name = dataset.getAttributeNode("name").nodeValue datasetNames.append(name.upper()) SUCCESS = 3 # parameter number for output success value gzSupport.startLog() def main(argv = None): # main function - list the source and target datasets, then delete rows/append where there is a match on non-prefixed name success = True try: if len(datasetNames) == 0:
def main(argv=None): success = True if not arcpy.Exists(gzSupport.workspace): gzSupport.addMessage(gzSupport.workspace + " does not exist, attempting to create") gzSupport.createGizintaGeodatabase() else: gzSupport.compressGDB(gzSupport.workspace) arcpy.ClearWorkspaceCache_management(gzSupport.workspace) try: gzSupport.addMessage("Looking for drawings modified since " + since) minTime = datetime.datetime.strptime(since, "%d/%m/%Y %I:%M:%S %p") cadFiles = gzSupport.getFileList(cadFolder, cadExt, minTime) if len(cadFiles) > 0: progBar = len(cadFiles) + 1 arcpy.SetProgressor("step", "Importing Drawings...", 0, progBar, 1) arcpy.SetProgressorPosition() gzSupport.deleteExistingRows(datasets) for item in cadFiles: cadPath = item[0] cadName = item[1] gzSupport.addMessage("Importing Drawing " + cadName) for dataset in datasets: try: name = dataset.getAttributeNode("sourceName").nodeValue except: name = dataset.getAttributeNode("name").nodeValue gzSupport.sourceIDField = dataset.getAttributeNode("sourceIDField").nodeValue xmlFields = gzSupport.getXmlElements(gzSupport.xmlFileName, "Field") arcpy.SetProgressorLabel("Loading " + name + " for " + cadName + "...") arcpy.env.Workspace = gzSupport.workspace targetName = dataset.getAttributeNode("targetName").nodeValue sourceWorkspace = os.path.join(cadPath, cadName) exists = False if not arcpy.Exists(os.path.join(gzSupport.workspace, targetName)): gzSupport.addMessage(os.path.join(gzSupport.workspace, targetName) + " does not exist") else: exists = True # arcpy.Delete_management(os.path.join(gzSupport.workspace,targetName)) try: if not exists == True: retVal = gzSupport.exportDataset(sourceWorkspace, name, targetName, dataset, xmlFields) addDrawingField(os.path.join(gzSupport.workspace, targetName), cadName) else: retVal = importLayer(cadPath, cadName, dataset) addDrawingField(os.path.join(gzSupport.workspace, targetName), cadName) if retVal == False: success = False except: gzSupport.showTraceback() success = False retVal = False arcpy.env.Workspace = gzSupport.workspace gzSupport.logDatasetProcess(cadName, name, retVal) gzSupport.cleanupGarbage() arcpy.SetProgressorPosition() except: gzSupport.addError("A Fatal Error occurred") gzSupport.showTraceback() success = False gzSupport.logDatasetProcess("", "", False) finally: arcpy.ResetProgressor() arcpy.RefreshCatalog(gzSupport.workspace) arcpy.ClearWorkspaceCache_management(gzSupport.workspace) gzSupport.cleanupGarbage() if success == False: gzSupport.addError("Errors occurred during process, look in log files for more information") if gzSupport.ignoreErrors == True: success = True gzSupport.closeLog() arcpy.SetParameter(SUCCESS, success)
# Created on: 2014-08-14 SG # Description: Add missing fields to a target Geodatabase using the provided field name, type, etc. using the Gizinta.xml # --------------------------------------------------------------------------- # Copyright 2012-2014 Vertex3 Inc # This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. import os, sys, traceback, time, arcpy, xml.dom.minidom, gzSupport, myGizinta gzSupport.xmlFileName = arcpy.GetParameterAsText(0) # xml file name as a parameter gzSupport.workspace = arcpy.GetParameterAsText(1) # Gizinta Geodatabase gzSupport.ignoreErrors = gzSupport.strToBool(arcpy.GetParameterAsText(2)) # boolean indicates whether to return False if errors encountered SUCCESS = 3 # parameter number for output success value gzSupport.startLog() xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(gzSupport.xmlFileName,"Dataset") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode("errorTableName").nodeValue valueMappings = gzSupport.getXmlElements(gzSupport.xmlFileName,"ValueMaps") def main(argv = None): success = True gzSupport.compressGDB(gzSupport.workspace) arcpy.ClearWorkspaceCache_management(gzSupport.workspace) tables = gzSupport.listDatasets(gzSupport.workspace) tNames = tables[0] tFullNames = tables[1] for dataset in datasets: arcpy.env.Workspace = gzSupport.workspace
0) # xml file name as a parameter gzSupport.workspace = arcpy.GetParameterAsText(1) # Gizinta Geodatabase defaultWorkspace = arcpy.GetParameterAsText( 2) # Connection to the default version targetWorkspace = arcpy.GetParameterAsText( 3) # Connection to the version to be used/updated gzSupport.ignoreErrors = gzSupport.strToBool(arcpy.GetParameterAsText( 4)) # boolean indicates whether to return False if errors encountered SUCCESS = 5 # parameter number for output success value if targetWorkspace == "" or targetWorkspace == "#": targetWorkspace = defaultWorkspace gzSupport.startLog() xmlDoc = xml.dom.minidom.parse(gzSupport.xmlFileName) datasets = gzSupport.getXmlElements(gzSupport.xmlFileName, "Dataset") rootElem = gzSupport.getRootElement(xmlDoc) gzSupport.logTableName = rootElem.getAttributeNode("logTableName").nodeValue gzSupport.errorTableName = rootElem.getAttributeNode( "errorTableName").nodeValue settings = gzSupport.getXmlElements(gzSupport.xmlFileName, "AppendSettings")[0] fieldNames = gzSupport.getNodeValue(settings, "FieldNames") fieldNames = fieldNames.split(",") try: versionName = gzSupport.getNodeValue(settings, "VersionName") defaultVersionName = gzSupport.getNodeValue(settings, "DefaultVersionName") except: versionName = None defaultVersionName = None