Exemplo n.º 1
0
            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
Exemplo n.º 2
0
        if wksId in sdeIds:
            sdeInfo = cf.get('sde', wksId)
            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', '\'\'')
#             fdsDict = AIUtils.str2dict(param2)
#             name = fdsDict['name']
            fds = AIFds()
            fds = fds.fromStr(param2)
            try:
                fds = wks.queryFds(fds)
                qr = AIUtils.dict2json(AIUtils.str2dict(str(fds)))
                qr = '' if not qr else qr
            except Exception as e:            
                logger.info(unicode(e.message).encode("utf-8"))
                logger.info('要素集' + fds.getName() + '查询失败')