</summary///<paramname=serverContext服务上下文</param///<paramname=connStr格式如:SERVER=fsgt;INSTANCE=esri_sde;USER=scott;PASSWORD=tiger;VERSION=SDEDEFAULT</param///<returns</returnspublicstaticIWorkspaceGetWorkspaceByServerContext(IServerContextserverContext,stringconnStr){try{IWorkspaceFactory2pWorkspaceFactory2=serverContextCreateObject(esriDataSourcesGDBSdeWorkspaceFactory)asIWorkspaceFactory2;returnpWorkspaceFactory2OpenFromString(connStr,0);}catch{thrownewArgumentException(无法获取连接,请检查连接字符串格式是否正确!);}}publicstaticESRIArcGISServerIServerContextGetServerContext(stringhost,stringserviceName,stringserviceType){ESRIArcGISServerIServerObjectManagerserverManager=GetServerConnection(host)ServerObjectManager;returnserverManagerCreateServerContext(serviceName,serviceType);}///<summary///获取Server的连接,注意此连接必须在客户端与服务端的当前 *** 作系统帐户一致情况下才有效(此时无须再指定用户名/密码)///</summary///<paramname=host</param///<paramname=serviceName</param///<returns</returnspublicstaticGISServerConnectionClassGetServerConnection(stringhost){ESRIArcGISServerGISServerConnectionClassgisConnection=newESRIArcGISServerGISServerConnectionClass();gisConnectionConnect(host);returngisConnection;}在客户端,你大概可以这样调用:[Test]publicvoidGetWorkspaceFromServerContext(){//获取服务上下文IServerContextserverContext=GetServerContext(Host,YourServiceName,MapServer);//打开Workspace的连接字符串,支持直连和非直连方式stringconnStr=SERVER=host;INSTANCE=esri_sde;USER=scott;PASSWORD=tiger;VERSION=SDEDEFAULT;IWorkspacepWorkspace=GetWorkspaceByServerContext(serverContext,connStr);//AssertIsNotNull(pWorkspace);//注意释放上下文serverContextReleaseContext();}之前试过用获取IMap的第一个图层,再QI为IDataset,再获取到IWorkspace这种方式来获取IWorkspace,但这种方式感觉还是不大正规,有旁门左道之嫌。That's all!
对象值不符合service实现类的类型。
比如:在工作中遇到了传入一个实体对象,通过该实体对象获得其spring中service对象的方法
项目目录结构如下
每个实体对应一个包,包下有对应的controller,entity,service 通过传入的对象获得当前对象在spring容器中对应的service
通过WebApplicationContext webApplicationContext = WebApplicationContextUtilsgetRequiredWebApplicationContext(requestgetSession()getServletContext());拿到spring 容器
Object objectService = webApplicationContextgetBean(objectServiceName);
通过实体对应的service类名拿到相应的service
Android的Context类里有常量WINDOW_SERVICE
/Use with {@link #getSystemService} to retrieve a
{@link androidviewWindowManager} for accessing the system's window
manager
@see #getSystemService
@see androidviewWindowManager
/
public static final String WINDOW_SERVICE = "window";
所以你可以在activity类里直接调用(ActivityManager) getSystemService(WINDOW_SERVICE)方法,或者得到context得到。
以上就是关于如何在ArcGIS Server服务下获取IWorkspace全部的内容,包括:如何在ArcGIS Server服务下获取IWorkspace、为什么service实现类获取不到对象的值、android windowmanagerservice怎么获取等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)