static public void SaveConfig(IMap map) { try { if (mapDocument == null) { return; } ServerMapDocument doc = new ServerMapDocument(); if (!doc.AddMap(map)) { return; } XmlStream stream = new XmlStream("MapServer"); stream.Save("MapDocument", doc); stream.WriteStream(ServicesPath + @"\" + map.Name + ".mxl"); } catch (Exception ex) { if (Functions.log_errors) { Logger.Log(loggingMethod.error, "LoadConfig: " + ex.Message); } } }
public MapServerInstanceType() { _doc = IMS.mapDocument; _log_requests = Functions.log_requests; _log_request_details = Functions.log_request_details; _log_errors = Functions.log_errors; }
internal static IMap LoadMap(string name, IServiceRequestContext context) { try { DirectoryInfo di = new DirectoryInfo(ServicesPath); if (!di.Exists) { di.Create(); } FileInfo fi = new FileInfo(ServicesPath + @"\" + name + ".mxl"); if (fi.Exists) { ServerMapDocument doc = new ServerMapDocument(); doc.LoadMapDocument(fi.FullName); if (doc.Maps.Count == 1) { ApplyMetadata(doc.Maps[0] as Map); if (!mapDocument.AddMap(doc.Maps[0])) { return(null); } return(doc.Maps[0]); } return(null); } fi = new FileInfo(ServicesPath + @"\" + name + ".svc"); if (fi.Exists) { XmlStream stream = new XmlStream(""); stream.ReadStream(fi.FullName); IServiceableDataset sds = stream.Load("IServiceableDataset", null) as IServiceableDataset; if (sds != null && sds.Datasets != null) { Map map = new Map(); map.Name = name; foreach (IDataset dataset in sds.Datasets) { if (dataset is IRequestDependentDataset) { if (!((IRequestDependentDataset)dataset).Open(context)) { return(null); } } else { if (!dataset.Open()) { return(null); } } //map.AddDataset(dataset, 0); foreach (IDatasetElement element in dataset.Elements) { if (element == null) { continue; } ILayer layer = LayerFactory.Create(element.Class, element as ILayer); if (layer == null) { continue; } map.AddLayer(layer); if (element.Class is IWebServiceClass) { if (map.SpatialReference == null) { map.SpatialReference = ((IWebServiceClass)element.Class).SpatialReference; } foreach (IWebServiceTheme theme in ((IWebServiceClass)element.Class).Themes) { map.SetNewLayerID(theme); } } else if (element.Class is IFeatureClass && map.SpatialReference == null) { map.SpatialReference = ((IFeatureClass)element.Class).SpatialReference; } else if (element.Class is IRasterClass && map.SpatialReference == null) { map.SpatialReference = ((IRasterClass)element.Class).SpatialReference; } } } ApplyMetadata(map); if (!mapDocument.AddMap(map)) { return(null); } return(map); } return(null); } } catch (Exception ex) { if (Functions.log_errors) { Logger.Log(loggingMethod.error, "LoadConfig: " + ex.Message); } } return(null); }