/// <summary> /// 删除地图服务 /// </summary> /// <param name="port"></param> /// <param name="serviceName"></param> /// <returns></returns> public static string DeleteService(int port, string serviceName) { if (!ServerEntitiyDic.ContainsKey(port)) { return("端口【 " + port + "】的服务器尚未启动"); } if (!ServerEntitiyDic[port].ServerProvider.GISServicesDic.ContainsKey(serviceName)) { return("名称为【 " + serviceName + "】的服务不存在与端口为【" + port + "】的服务器中."); } ServicesInServer.Remove(ServerEntitiyDic[port].ServerProvider.GISServicesDic[serviceName]); ServerEntitiyDic[port].ServerProvider.GISServicesDic[serviceName].Dispose(); ServerEntitiyDic[port].ServerProvider.GISServicesDic.Remove(serviceName); return(string.Empty); }
/// <summary> /// 创建地图服务 /// </summary> /// <param name="serviceName"></param> /// <param name="port"></param> /// <param name="strType">DataSourceType enum + custom online maps</param> /// <param name="dataSorucePath"></param> /// <param name="disableClientCache"></param> /// <param name="displayNoDataTile"></param> /// <param name="style"></param> /// <param name="tilingSchemePath">Set this parameter only when type is ArcGISDynamicMapService and do not use Google Maps's tiling scheme</param> /// <returns>errors or warnings. string.empty if nothing wrong.</returns> public static string CreateGISService(string serviceName, int port, string strType, string dataSorucePath, bool allowMemoryCache, bool disableClientCache, bool displayNoDataTile, VisualStyle style, string tilingSchemePath = null) { ServerProvider serverProvider = null; string errorMessage; //验证该端口指向的服务器是否已经启动 if (!ServerEntitiyDic.ContainsKey(port)) { ///如果服务器启动失败 errorMessage = StartServer(port); if (errorMessage != string.Empty) { return(errorMessage); } } //获取服务器接口对象 serverProvider = ServerEntitiyDic[port].ServerProvider; //服务器对象想服务名称必须唯一 if (serverProvider.GISServicesDic.ContainsKey(serviceName)) { return("服务名称已经存在!"); } GISServiceEntity gisservice; try { gisservice = new GISServiceEntity(serviceName, dataSorucePath, port, strType, allowMemoryCache, disableClientCache, displayNoDataTile, style, tilingSchemePath); } catch (Exception ex)//in case of reading conf.xml or conf.cdi file error|| reading a sqlite db error { return("创建服务【" + serviceName + "】 失败!\r\n数据源:【 " + dataSorucePath + "】\r\n\r\n" + ex.Message + ex.StackTrace); } ///向缓存中增加对象 serverProvider.GISServicesDic.Add(serviceName, gisservice); ServicesInServer.Add(gisservice); return(string.Empty); }