private void btnGetMapKml_Click(object sender, EventArgs e) { var mapagent = _conn.GetCustomProperty("BaseUrl").ToString(); //NOXLATE mapagent += "mapagent/mapagent.fcgi?SESSION=" + _conn.SessionID + "&VERSION=1.0.0&OPERATION=GETMAPKML&DPI=96&MAPDEFINITION=" + _map.MapDefinition + "&FORMAT=KML&CLIENTAGENT=Maestro Local Map Previewer"; //NOXLATE _launcher.OpenUrl(mapagent); }
public void TestCustomProperties() { Skip.If(_fixture.Skip, _fixture.SkipReason); var conn = CreateHttpConnection("http://tempuri.org", "en"); //Work through the interface IServerConnection isvc = (IServerConnection)conn; //UserAgent is exposed as a custom property var props = isvc.GetCustomPropertyNames(); Assert.NotNull(props); Assert.Equal(2, props.Length); Assert.True(Array.IndexOf <string>(props, HttpServerConnectionProperties.PROP_USER_AGENT) >= 0); Assert.True(Array.IndexOf <string>(props, HttpServerConnectionProperties.PROP_BASE_URL) >= 0); //It is of type string var type = isvc.GetCustomPropertyType(HttpServerConnectionProperties.PROP_USER_AGENT); Assert.Equal(typeof(string), type); type = isvc.GetCustomPropertyType(HttpServerConnectionProperties.PROP_BASE_URL); Assert.Equal(typeof(string), type); //We can set and get it isvc.SetCustomProperty(HttpServerConnectionProperties.PROP_USER_AGENT, "MapGuide Maestro API Unit Test Fixture"); var agent = (string)isvc.GetCustomProperty(HttpServerConnectionProperties.PROP_USER_AGENT); Assert.Equal("MapGuide Maestro API Unit Test Fixture", agent); //BaseUrl is read-only try { isvc.SetCustomProperty(HttpServerConnectionProperties.PROP_BASE_URL, "http://mylocalhost/mapguide"); Assert.True(false, "Should've thrown exception"); } catch { } }
public void TestCustomProperties() { var builder = new RequestBuilder(new Uri("http://tempuri.org"), "en"); var conn = new HttpServerConnection(builder); //Work through the interface IServerConnection isvc = (IServerConnection)conn; //UserAgent is exposed as a custom property var props = isvc.GetCustomPropertyNames(); Assert.IsNotNull(props); Assert.AreEqual(props.Length, 2); Assert.IsTrue(Array.IndexOf <string>(props, HttpServerConnection.PROP_USER_AGENT) >= 0); Assert.IsTrue(Array.IndexOf <string>(props, HttpServerConnection.PROP_BASE_URL) >= 0); //It is of type string var type = isvc.GetCustomPropertyType(HttpServerConnection.PROP_USER_AGENT); Assert.AreEqual(type, typeof(string)); type = isvc.GetCustomPropertyType(HttpServerConnection.PROP_BASE_URL); Assert.AreEqual(type, typeof(string)); //We can set and get it isvc.SetCustomProperty(HttpServerConnection.PROP_USER_AGENT, "MapGuide Maestro API Unit Test Fixture"); var agent = (string)isvc.GetCustomProperty(HttpServerConnection.PROP_USER_AGENT); Assert.AreEqual(agent, "MapGuide Maestro API Unit Test Fixture"); //BaseUrl is read-only try { isvc.SetCustomProperty(HttpServerConnection.PROP_BASE_URL, "http://mylocalhost/mapguide"); Assert.Fail("Should've thrown exception"); } catch { } }
public SetupRun(IServerConnection connection, string[] maps, Dictionary<string, string> args) : this() { m_connection = connection; grpDifferentConnection.Enabled = chkUseDifferentConnection.Enabled = !m_connection.ProviderName.ToUpper().Equals("MAESTRO.LOCAL"); //NOXLATE m_commandlineargs = args; m_coordinateOverrides = new Dictionary<string, IEnvelope>(); IEnvelope overrideExtents = null; //HttpServerConnection hc = connection as HttpServerConnection; try { var url = connection.GetCustomProperty("BaseUrl"); //NOXLATE if (url != null) MapAgent.Text = url.ToString(); } catch { } if (m_commandlineargs.ContainsKey("mapdefinitions")) //NOXLATE m_commandlineargs.Remove("mapdefinitions"); //NOXLATE if (m_commandlineargs.ContainsKey("mapagent")) //NOXLATE MapAgent.Text = m_commandlineargs["mapagent"]; //NOXLATE if (m_commandlineargs.ContainsKey("username")) //NOXLATE Username.Text = m_commandlineargs["username"]; //NOXLATE if (m_commandlineargs.ContainsKey("password")) //NOXLATE Password.Text = m_commandlineargs["password"]; //NOXLATE if (m_commandlineargs.ContainsKey("native-connection")) //NOXLATE UseNativeAPI.Checked = true; if (m_commandlineargs.ContainsKey("limitrows")) //NOXLATE { int i; if (int.TryParse(m_commandlineargs["limitrows"], out i) && i > 0) //NOXLATE { MaxRowLimit.Value = i; TilesetLimitPanel.Enabled = true; } } if (m_commandlineargs.ContainsKey("limitcols")) //NOXLATE { int i; if (int.TryParse(m_commandlineargs["limitcols"], out i) && i > 0) //NOXLATE { MaxColLimit.Value = i; TilesetLimitPanel.Enabled = true; } } if (m_commandlineargs.ContainsKey("extentoverride")) //NOXLATE { string[] parts = m_commandlineargs["extentoverride"].Split(','); if (parts.Length == 4) { double minx; double miny; double maxx; double maxy; if ( double.TryParse(parts[0], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out minx) && double.TryParse(parts[1], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out miny) && double.TryParse(parts[2], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out maxx) && double.TryParse(parts[3], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out maxy) ) { overrideExtents = ObjectFactory.CreateEnvelope(minx, miny, maxx, maxy); } } } if (m_commandlineargs.ContainsKey("metersperunit")) //NOXLATE { double d; if ( double.TryParse(m_commandlineargs["metersperunit"], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.CurrentUICulture, out d) //NOXLATE || double.TryParse(m_commandlineargs["metersperunit"], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d) //NOXLATE ) if (d >= (double)MetersPerUnit.Minimum && d <= (double)MetersPerUnit.Maximum) { UseOfficialMethod.Checked = true; MetersPerUnit.Value = (decimal)d; } } if (maps == null || maps.Length == 0 || (maps.Length == 1 && maps[0].Trim().Length == 0)) { List<string> tmp = new List<string>(); foreach (ResourceListResourceDocument doc in m_connection.ResourceService.GetRepositoryResources(StringConstants.RootIdentifier, ResourceTypes.MapDefinition.ToString()).Items) tmp.Add(doc.ResourceId); maps = tmp.ToArray(); } var basegroupsSelected = new List<string>(); if (m_commandlineargs.ContainsKey("basegroups"))//NOXLATE { basegroupsSelected = new List<string>(m_commandlineargs["basegroups"].Split(','));//NOXLATE m_commandlineargs.Remove("basegroups"); //NOXLATE } var scalesSelected = new List<int>(); if (m_commandlineargs.ContainsKey("scaleindex")) //NOXLATE { foreach (string scaleIndex in m_commandlineargs["scaleindex"].Split(','))//NOXLATE { scalesSelected.Add(int.Parse(scaleIndex)); } m_commandlineargs.Remove("scaleindex"); //NOXLATE } MapTree.Nodes.Clear(); foreach (string m in maps) { IMapDefinition mdef = m_connection.ResourceService.GetResource(m) as IMapDefinition; if (mdef == null) //Skip unknown Map Definition version (which would be returned as UntypedResource objects) continue; IBaseMapDefinition baseMap = mdef.BaseMap; if (baseMap != null && baseMap.ScaleCount > 0 && baseMap.HasGroups()) { TreeNode mn = MapTree.Nodes.Add(m); mn.ImageIndex = mn.SelectedImageIndex = 0; mn.Tag = mdef; foreach (var g in baseMap.BaseMapLayerGroup) { TreeNode gn = mn.Nodes.Add(g.Name); gn.Tag = g; if (basegroupsSelected.Contains(g.Name)) { mn.Checked = true; gn.Checked = true; if (overrideExtents != null && !m_coordinateOverrides.ContainsKey(m)) { m_coordinateOverrides.Add(m, overrideExtents); } } gn.ImageIndex = gn.SelectedImageIndex = 1; int counter = 0; foreach (double d in baseMap.FiniteDisplayScale) { TreeNode sn = gn.Nodes.Add(d.ToString(System.Globalization.CultureInfo.CurrentUICulture)); if (gn.Checked && scalesSelected.Contains(counter)) { sn.Checked = true; } sn.ImageIndex = sn.SelectedImageIndex = 3; counter++; } } mn.Expand(); } } MapTree_AfterSelect(null, null); }
/// <summary> /// Gets the value of a custom connection property /// </summary> /// <param name="name"></param> /// <returns></returns> public object GetCustomProperty(string name) { return(_conn.GetCustomProperty(name)); }
public override IServerConnection CreateFromExistingSession(IServerConnection orig) { return ConnectionProviderRegistry.CreateConnection("Maestro.Http", HttpServerConnection.PARAM_URL, orig.GetCustomProperty(HttpServerConnection.PROP_BASE_URL).ToString(), HttpServerConnection.PARAM_SESSION, orig.SessionID); }
public override IServerConnection CreateFromExistingSession(IServerConnection orig) { return(ConnectionProviderRegistry.CreateConnection("Maestro.Http", HttpServerConnection.PARAM_URL, orig.GetCustomProperty(HttpServerConnection.PROP_BASE_URL).ToString(), HttpServerConnection.PARAM_SESSION, orig.SessionID)); }