# 获取sde连接文件 sdeIds = cf.options('sde') 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', '\'\'') param2 = param2.replace('true', 'True') param2 = param2.replace('false', 'False') fc = AIFc() fc = fc.fromStr(param2) try: flag = 'true' if wks.removeFc(fc) else 'false' except Exception as e: logger.info(unicode(e.message).encode("utf-8")) logger.info('要素类' + fc.getName() + '删除失败') print flag
# flds.append(AIFld('name', '名称2', 'String ', None, 100, True)) # flag = wks.updateFc(AIFc('ent_4326_4', '新企业', 'point', 4326, AIFds('test_1'), flds)) # print flag # # delete fc # flag = wks.removeFc(AIFc('ent_4326_4', '新企业', 'point', 4326, AIFds('test_1'), [])) # print flag # query fc list # qrs = wks.queryFcList(AIFc('4326', '新企业', 'point', 4326, AIFds('gis.test'), [])) # print '[' + ','.join([str(qr) for qr in qrs]) + ']' # param2 = "{'name':'test','wkid':''}" # fds = AIFds() # fds = fds.fromStr(param2) # print fds # fdss = wks.queryFdsList(fds) # print fdss[0] # qr = str([AIUtils.dict2json(AIUtils.str2dict(str(fds))) for fds in fdss]) # print qr param2 = "{'name':'4326','alias':'企业nb2','ftype':'point','fds':{'name':'test'}}" fc = AIFc() fc = fc.fromStr(param2) print fc fcs = wks.queryFcList(fc) print fcs except Exception as e: print unicode(e.message).encode("utf-8")