private void AddMap2Connection(List <string> serviceNames, List <IMap> maps) { try { if (serviceNames.Count != maps.Count) { return; } for (int i = 0; i < serviceNames.Count; i++) { XmlStream stream = new XmlStream("MapDocument"); stream.Save("IMap", maps[i]); stream.ReduceDocument("//IMap"); StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); stream.WriteStream(sw); //XmlDocument doc = new XmlDocument(); //doc.LoadXml(sb.ToString()); MapServerConnection service = new MapServerConnection(ConfigTextStream.ExtractValue(_connectionString, "server")); if (!service.AddMap(serviceNames[i], sb.ToString(), ConfigTextStream.ExtractValue(_connectionString, "user"), ConfigTextStream.ExtractValue(_connectionString, "pwd"))) { System.Windows.Forms.MessageBox.Show("Can't add map", "ERROR"); } } Refresh(); if (Refreshed != null) { Refreshed(this); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "ERROR"); } }
private void AddService2Connection(XmlStream stream) { try { StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); stream.WriteStream(sw); XmlDocument doc = new XmlDocument(); doc.LoadXml(sb.ToString()); FormAddServiceableDataset dlg = new FormAddServiceableDataset(); if (dlg.ShowDialog() != DialogResult.OK) { return; } MapServerConnection service = new MapServerConnection(ConfigTextStream.ExtractValue(_connectionString, "server")); if (!service.AddMap(dlg.ServiceName, doc.SelectSingleNode("//IServiceableDataset").OuterXml, ConfigTextStream.ExtractValue(_connectionString, "user"), ConfigTextStream.ExtractValue(_connectionString, "pwd"))) { System.Windows.Forms.MessageBox.Show("Can't add map", "ERROR"); } //Refresh(); Refresh(); if (Refreshed != null) { Refreshed(this); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "ERROR"); } }