摘要:
还有一点必须主要的,Mxd更改以后,地图服务是没有发生变化的,所发布的地图一直驻留在内存中。因此,这时候需要更新一下地图服务。 方法有很多,最傻瓜最直接的方法就是跑到机房去重启mxd所对应的service。但是,懒羊羊比较懒,所以,还是希望通过代码去控制,update 一下。下面是更新地图服务的函数 private void updateService(string serviceName,string serverName) { ServerConnection pServerConnection = new ESRI.ArcGIS.Server.WebControls.ServerConnection(serverName);//地图服务机器名 pServerConnection.Connect(); IServerObjectAdmin pServerSOA = pServerConnection.ServerObjectAdmin; IServerObjectConfiguration pConfig = pServerSOA.GetConfiguration(serviceName, "MapServer"); pServerSOA.UpdateConfiguration(pConfig); } 细心的朋友应该注意到了,这里面主要是使用了IServerObjectAdmin 接口,IServerObjectAdmin 接口功能十分强大,建议去查一下帮助, 对其加深了解。 描述 RemarksAny application that runs as a user account in the agsadmin user group on the ArcGIS Server can use the IGISServerConnection interface to connect to the ArcGIS Server and to get a reference to the ServerObjectAdmin. If the user account is not part of the agsadmin user group the ServerObjectAdmin property on IServerConnection will return an error. Applications that are running as accounts that can connect to the server but are not part of the agsadmin user group can use the ServerObjectManager property on IGISServerConnection to get a reference on the ServerObjectManager. The IServerObjectAdmin interface has the necessary methods for an application to adminstrate both the set of server object configurations and types associated with the server, and to administer aspects of the server itself. The following administration functionality of the ArcGIS Server is exposed by methods and properties on IServerObjectAdmin : Adminster server object configurations:
|