sdePassword = sdeInfos[3] try: sde = AISde( os.path.join(rootPath, "resources", "sde"), wksId, sdeServer + "/" + sdeInstance, sdeUsername, sdePassword, ) sde.connect() except Exception as e: logger.info(unicode(e.message).encode("utf-8")) logger.info("数据库服务器" + sdeServer + "上空间数据库" + sdeInstance + "实例连接失败") logger.info("数据库服务器" + sdeServer + "上空间数据库" + sdeInstance + "实例连接成功") wks = AIWks(sde.getSdeOutFullName(), sde.getSdeUserName()) logger.info("工作空间" + sde.getSdeOutFullName() + "初始化成功") # 查询要素集 param2 = sys.argv[2] param2 = param2.replace("null", "''") fds = AIFds() fds = fds.fromStr(param2) try: fdss = wks.queryFdsList(fds) if not AIUtils.isEmpty(fdss) and len(fdss) > 0: qr = AIUtils.list2json([AIUtils.str2dict(str(fds)) for fds in fdss]) except Exception as e: logger.info(unicode(e.message).encode("utf-8")) logger.info("要素集" + fds.getName() + "查询失败") print qr
sdeInfos = sdeInfo.split('/') sdeServer = sdeInfos[0] sdeInstance = sdeInfos[1] sdeUsername = sdeInfos[2] sdePassword = sdeInfos[3] try: sde = AISde(os.path.join(rootPath, 'resources', 'sde'), wksId, sdeServer + '/' + sdeInstance, sdeUsername, sdePassword) sde.connect() except Exception as e: logger.info(unicode(e.message).encode("utf-8")) logger.info('数据库服务器' + sdeServer + '上空间数据库' + sdeInstance + '实例连接失败') logger.info('数据库服务器' + sdeServer + '上空间数据库' + sdeInstance + '实例连接成功') wks = AIWks(sde.getSdeOutFullName(), sde.getSdeUserName()) logger.info('工作空间' + sde.getSdeOutFullName() + '初始化成功') # 查询要素类列表 param2 = sys.argv[2] param2 = param2.replace('null', '\'\'') fcDict = AIUtils.str2dict(param2) fdsName = fcDict['name'] fc = AIFc() fc = fc.fromStr(param2) try: fcs = wks.queryFcList(fc) if not AIUtils.isEmpty(fcs) and len(fcs) > 0: qr = AIUtils.list2json([AIUtils.str2dict(str(fc)) for fc in fcs]) except Exception as e: logger.info(unicode(e.message).encode("utf-8")) logger.info('要素类' + fc.getName() + ' 查询失败') print qr