[mapguide-commits] r6244 - in trunk/Tools/Maestro: OSGeo.MapGuide.MaestroAPI/Mapping SDK/SamplesWeb/SamplesWeb SDK/SamplesWeb/SamplesWeb/Tasks

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Nov 22 10:03:24 EST 2011


Author: jng
Date: 2011-11-22 07:03:24 -0800 (Tue, 22 Nov 2011)
New Revision: 6244

Added:
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx.cs
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx.designer.cs
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/LayerInfo.aspx
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/LayerInfo.aspx.cs
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/LayerInfo.aspx.designer.cs
Modified:
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/SamplesWeb.csproj
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddTracksLayer.aspx.cs
   trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/Home.aspx
Log:
Update Web Samples: 

 - Add a new sample demonstrating how to create a dynamically themed layer
 - Add a new sample demonstrating how to get the class definition of a given layer

Also update RuntimeMapGroup to set Group to empty string by default

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs	2011-11-22 13:55:27 UTC (rev 6243)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapGroup.cs	2011-11-22 15:03:24 UTC (rev 6244)
@@ -38,6 +38,7 @@
         {
             _disableChangeTracking = true;
             this.Group = "";
+            this.LegendLabel = "";
             this.Type = kNormal;
             this.ObjectId = Guid.NewGuid().ToString();
         }

Modified: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/SamplesWeb.csproj
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/SamplesWeb.csproj	2011-11-22 13:55:27 UTC (rev 6243)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/SamplesWeb.csproj	2011-11-22 15:03:24 UTC (rev 6244)
@@ -84,8 +84,10 @@
     <Content Include="Default.aspx" />
     <Content Include="Global.asax" />
     <Content Include="readme.txt" />
+    <Content Include="Tasks\AddThemedDistrictsLayer.aspx" />
     <Content Include="Tasks\AddTracksLayer.aspx" />
     <Content Include="Tasks\FeatureInfo.aspx" />
+    <Content Include="Tasks\LayerInfo.aspx" />
     <Content Include="Tasks\ListSelection.aspx" />
     <Content Include="Tasks\SetSelectedFeatures.aspx" />
     <Content Include="Tasks\ToggleGroupVisibility.aspx" />
@@ -106,6 +108,13 @@
       <DependentUpon>Global.asax</DependentUpon>
     </Compile>
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Tasks\AddThemedDistrictsLayer.aspx.cs">
+      <DependentUpon>AddThemedDistrictsLayer.aspx</DependentUpon>
+      <SubType>ASPXCodeBehind</SubType>
+    </Compile>
+    <Compile Include="Tasks\AddThemedDistrictsLayer.aspx.designer.cs">
+      <DependentUpon>AddThemedDistrictsLayer.aspx</DependentUpon>
+    </Compile>
     <Compile Include="Tasks\AddTracksLayer.aspx.cs">
       <DependentUpon>AddTracksLayer.aspx</DependentUpon>
       <SubType>ASPXCodeBehind</SubType>
@@ -120,6 +129,13 @@
     <Compile Include="Tasks\FeatureInfo.aspx.designer.cs">
       <DependentUpon>FeatureInfo.aspx</DependentUpon>
     </Compile>
+    <Compile Include="Tasks\LayerInfo.aspx.cs">
+      <DependentUpon>LayerInfo.aspx</DependentUpon>
+      <SubType>ASPXCodeBehind</SubType>
+    </Compile>
+    <Compile Include="Tasks\LayerInfo.aspx.designer.cs">
+      <DependentUpon>LayerInfo.aspx</DependentUpon>
+    </Compile>
     <Compile Include="Tasks\ListSelection.aspx.cs">
       <DependentUpon>ListSelection.aspx</DependentUpon>
       <SubType>ASPXCodeBehind</SubType>

Added: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx	                        (rev 0)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx	2011-11-22 15:03:24 UTC (rev 6244)
@@ -0,0 +1,21 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddThemedDistrictsLayer.aspx.cs" Inherits="SamplesWeb.Tasks.AddThemedDistrictsLayer" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head runat="server">
+    <title></title>
+</head>
+<body>
+    <form id="form1" runat="server">
+    <div>
+        <asp:Label ID="lblMessage" runat="server"></asp:Label>
+        <br />
+        <a href="Home.aspx">Go back</a>
+        <br />
+        <div id="debug" runat="server">
+        </div>
+    </div>
+    </form>
+</body>
+</html>

Added: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx.cs	                        (rev 0)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx.cs	2011-11-22 15:03:24 UTC (rev 6244)
@@ -0,0 +1,193 @@
+#region Disclaimer / License
+// Copyright (C) 2011, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Configuration;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using OSGeo.MapGuide.MaestroAPI.Mapping;
+using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+using OSGeo.MapGuide.ObjectModels;
+using System.Drawing;
+using System.Collections.Specialized;
+using OSGeo.MapGuide.MaestroAPI.Feature;
+using System.Text;
+
+namespace SamplesWeb.Tasks
+{
+    public partial class AddThemedDistrictsLayer : System.Web.UI.Page
+    {
+        protected void Page_Load(object sender, EventArgs e)
+        {
+            string agent = ConfigurationManager.AppSettings["MapAgentUrl"];
+
+            IServerConnection conn = ConnectionProviderRegistry.CreateConnection(
+                "Maestro.Http",
+                "Url", agent,
+                "SessionId", Request.Params["SESSION"]);
+
+            IMappingService mpSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
+            string rtMapId = "Session:" + conn.SessionID + "//" + Request.Params["MAPNAME"] + ".Map";
+
+            RuntimeMap rtMap = mpSvc.OpenMap(rtMapId);
+
+            RuntimeMapLayer tracks = rtMap.Layers["ThemedDistricts"];
+            if (tracks != null)
+            {
+                lblMessage.Text = "Themed districts layer already added";
+            }
+            else
+            {
+                //Add our themed districts layer
+
+                //Our Feature Source
+                string fsId = "Library://Samples/Sheboygan/Data/VotingDistricts.FeatureSource";
+
+                //The place we'll store the layer definition
+                string layerId = "Session:" + conn.SessionID + "//ThemedVotingDistricts.LayerDefinition";
+
+                CreateDistrictsLayer(conn, fsId, layerId);
+
+                ILayerDefinition layerDef = (ILayerDefinition)conn.ResourceService.GetResource(layerId);
+                RuntimeMapLayer layer = new RuntimeMapLayer(rtMap, layerDef);
+
+                layer.Name = "ThemedDistricts";
+                layer.Group = "";
+                layer.LegendLabel = "Themed Districts";
+                layer.ShowInLegend = true;
+                layer.ExpandInLegend = true;
+                layer.Selectable = true;
+                layer.Visible = true;
+
+                //Set it to be drawn above districts.
+                //In terms of draw order, it goes [0...n] -> [TopMost ... Bottom]
+                //So for a layer to be drawn above something else, its draw order must be
+                //less than that particular layer.
+
+                int index = rtMap.Layers.IndexOf("Districts");
+                rtMap.Layers.Insert(index, layer);
+
+                rtMap.Save();
+
+                Page.ClientScript.RegisterStartupScript(
+                    this.GetType(),
+                    "load",
+                    "<script type=\"text/javascript\"> window.onload = function() { parent.parent.Refresh(); } </script>");
+
+                lblMessage.Text = "Themed districts layer added";
+            }
+
+            rtMap = mpSvc.OpenMap(rtMapId);
+            DumpMap(rtMap);
+        }
+
+        private void CreateDistrictsLayer(IServerConnection conn, string resId, string layerId)
+        {
+            //We use the ObjectFactory class to create our layer
+            ILayerDefinition ldf = ObjectFactory.CreateDefaultLayer(conn, LayerType.Vector);
+            IVectorLayerDefinition vldf = (IVectorLayerDefinition)ldf.SubLayer;
+
+            //Set feature source
+            vldf.ResourceId = resId;
+
+            //Set the feature class
+            vldf.FeatureName = "SDF_2_Schema:VotingDistricts";
+
+            //Set the designated geometry
+            vldf.Geometry = "Data";
+
+            //Get the first vector scale range. This will have been created for us and is 0 to infinity
+            IVectorScaleRange vsr = vldf.GetScaleRangeAt(0);
+
+            //What are we doing here? We're checking if this vector scale range is a
+            //IVectorScaleRange2 instance. If it is, it means this layer definition
+            //has a composite style attached, which takes precedence over point/area/line
+            //styles. We don't want this, so this removes the composite styles if they
+            //exist.
+            IVectorScaleRange2 vsr2 = vsr as IVectorScaleRange2;
+            if (vsr2 != null)
+                vsr2.CompositeStyle = null;
+
+            //Get the area style
+            IAreaVectorStyle astyle = vsr.AreaStyle;
+            //Remove the default rule
+            astyle.RemoveAllRules();
+
+            IFeatureService featSvc = conn.FeatureService;
+            //Generate a random color for each distinct feature id
+            //Perform a distinct value query
+            IReader valueReader = featSvc.AggregateQueryFeatureSource(resId, "SDF_2_Schema:VotingDistricts", null, new NameValueCollection()
+            {
+                { "Value", "UNIQUE(Autogenerated_SDF_ID)" } //UNIQUE() is the aggregate function that collects all distinct values of FeatId
+            });
+
+            while (valueReader.ReadNext())
+            {
+                //The parent Layer Definition provides all the methods needed to create the necessary child elements
+                IAreaRule rule = ldf.CreateDefaultAreaRule();
+                //Set the filter for this rule
+                rule.Filter = "Autogenerated_SDF_ID = " + valueReader["Value"].ToString();
+                //IReader allows object access by name in case you don't care to determine the data type
+                rule.LegendLabel = valueReader["Value"].ToString();
+                //Assign a random color fill
+                rule.AreaSymbolization2D.Fill.ForegroundColor = Utility.SerializeHTMLColor(RandomColor(), true);
+                //Add this rule
+                astyle.AddRule(rule);
+            }
+            valueReader.Close();
+
+            //Now save it
+            conn.ResourceService.SaveResourceAs(ldf, layerId);
+        }
+
+        Random rand = new Random();
+
+        Color RandomColor()
+        {
+            return Color.FromArgb(rand.Next(0, 256), rand.Next(0, 256), rand.Next(0, 256));
+        }
+
+        //This method dumps the runtime state of the map. I personally
+        //used this method to debug this sample as I was developing it.
+        //
+        //It's been kept here for reference.
+        private void DumpMap(RuntimeMap rtMap)
+        {
+            StringBuilder sb = new StringBuilder();
+            sb.Append("<p>Debugging</p>");
+            sb.Append("Name: " + rtMap.Name + "<br/>");
+            sb.Append("Layers: <br/>");
+            sb.Append("<ul>");
+            foreach (var layer in rtMap.Layers)
+            {
+                sb.Append("<li>Name: " + layer.Name + " (Selectable: " + layer.Selectable + ", Visible: " + layer.Visible + ")<br/>");
+                sb.Append("Label: " + layer.LegendLabel + "<br/>");
+                sb.Append("Group: " + layer.Group + "<br/>");
+                sb.Append("Draw Order: " + layer.DisplayOrder + "</li>");
+            }
+            sb.Append("</ul>");
+
+            debug.InnerHtml = sb.ToString();
+        }
+    }
+}

Added: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx.designer.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx.designer.cs	                        (rev 0)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx.designer.cs	2011-11-22 15:03:24 UTC (rev 6244)
@@ -0,0 +1,43 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:2.0.50727.5448
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace SamplesWeb.Tasks {
+    
+    
+    public partial class AddThemedDistrictsLayer {
+        
+        /// <summary>
+        /// form1 control.
+        /// </summary>
+        /// <remarks>
+        /// Auto-generated field.
+        /// To modify move field declaration from designer file to code-behind file.
+        /// </remarks>
+        protected global::System.Web.UI.HtmlControls.HtmlForm form1;
+        
+        /// <summary>
+        /// lblMessage control.
+        /// </summary>
+        /// <remarks>
+        /// Auto-generated field.
+        /// To modify move field declaration from designer file to code-behind file.
+        /// </remarks>
+        protected global::System.Web.UI.WebControls.Label lblMessage;
+        
+        /// <summary>
+        /// debug control.
+        /// </summary>
+        /// <remarks>
+        /// Auto-generated field.
+        /// To modify move field declaration from designer file to code-behind file.
+        /// </remarks>
+        protected global::System.Web.UI.HtmlControls.HtmlGenericControl debug;
+    }
+}

Modified: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddTracksLayer.aspx.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddTracksLayer.aspx.cs	2011-11-22 13:55:27 UTC (rev 6243)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/AddTracksLayer.aspx.cs	2011-11-22 15:03:24 UTC (rev 6244)
@@ -66,7 +66,6 @@
                 {
                     group = new RuntimeMapGroup(rtMap, groupName);
                     rtMap.Groups.Add(group);
-                    throw new Exception("Layer group not found");
                 }
 
                 //For some reason, the Sheboygan sample data does not have a Rail

Modified: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/Home.aspx
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/Home.aspx	2011-11-22 13:55:27 UTC (rev 6243)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/Home.aspx	2011-11-22 15:03:24 UTC (rev 6244)
@@ -42,6 +42,7 @@
     <ul>
         <li><a href="#" onclick="Go('../SamplesWeb/Tasks/ToggleParcelsLayer.aspx')">Add/Remove Parcels Layer</a></li>
         <li><a href="#" onclick="Go('../SamplesWeb/Tasks/AddTracksLayer.aspx')">Add Tracks Layer</a></li>
+        <li><a href="#" onclick="Go('../SamplesWeb/Tasks/AddThemedDistrictsLayer.aspx')">Add Themed Districts Layer</a></li>
         <li><a href="#" onclick="Go('../SamplesWeb/Tasks/ToggleGroupVisibility.aspx','GROUPNAME','Base Map')">Toggle "Base Map" Group</a></li>
         <li><a href="#" onclick="Go('../SamplesWeb/Tasks/ToggleLayerVisibility.aspx','LAYERNAME','Parcels')">Toggle "Parcels" Layer</a></li>
     </ul>
@@ -50,5 +51,9 @@
         <li><a href="#" onclick="Go('../SamplesWeb/Tasks/ListSelection.aspx')">List Selected Features</a></li>
         <li><a href="#" onclick="Go('../SamplesWeb/Tasks/SetSelectedFeatures.aspx')">Set Selected Features</a></li>
     </ul>
+    <p>Map/Layer Information:</p>
+    <ul>
+        <li><a href="#" onclick="Go('../SamplesWeb/Tasks/LayerInfo.aspx')">Layer Information</a></li>
+    </ul>
 </body>
 </html>

Added: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/LayerInfo.aspx
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/LayerInfo.aspx	                        (rev 0)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/LayerInfo.aspx	2011-11-22 15:03:24 UTC (rev 6244)
@@ -0,0 +1,25 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LayerInfo.aspx.cs" Inherits="SamplesWeb.Tasks.LayerInfo" %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head runat="server">
+    <title>Layer Information</title>
+</head>
+<body>
+    <form id="form1" runat="server">
+    <div>
+        <input id="MAPNAME" runat="server" type="hidden" />
+        <input id="SESSION" runat="server" type="hidden" />
+        <p>Select a map layer and click describe to get the class definition</p>
+        <p>Layer:</p>
+        <asp:DropDownList ID="ddlLayers" runat="server" />
+        <asp:Button ID="btnDescribe" runat="server" Text="Describe" 
+            onclick="btnDescribe_Click" />
+        <hr />
+        <div id="classDef" runat="server">
+        </div>
+    </div>
+    </form>
+</body>
+</html>

Added: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/LayerInfo.aspx.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/LayerInfo.aspx.cs	                        (rev 0)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/LayerInfo.aspx.cs	2011-11-22 15:03:24 UTC (rev 6244)
@@ -0,0 +1,105 @@
+#region Disclaimer / License
+// Copyright (C) 2011, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Configuration;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using OSGeo.MapGuide.MaestroAPI.Mapping;
+using OSGeo.MapGuide.MaestroAPI.Schema;
+using System.Text;
+
+namespace SamplesWeb.Tasks
+{
+    public partial class LayerInfo : System.Web.UI.Page
+    {
+        protected void Page_Load(object sender, EventArgs e)
+        {
+            if (!IsPostBack)
+            {
+                string agent = ConfigurationManager.AppSettings["MapAgentUrl"];
+                MAPNAME.Value = Request.Params["MAPNAME"];
+                SESSION.Value = Request.Params["SESSION"];
+
+                IServerConnection conn = ConnectionProviderRegistry.CreateConnection(
+                    "Maestro.Http",
+                    "Url", agent,
+                    "SessionId", SESSION.Value);
+
+                IMappingService mpSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
+                string rtMapId = "Session:" + conn.SessionID + "//" + MAPNAME.Value + ".Map";
+
+                RuntimeMap rtMap = mpSvc.OpenMap(rtMapId);
+                foreach (RuntimeMapLayer rtLayer in rtMap.Layers)
+                {
+                    ddlLayers.Items.Add(new ListItem(rtLayer.Name, rtLayer.ObjectId));
+                }
+            }
+        }
+
+        protected void btnDescribe_Click(object sender, EventArgs e)
+        {
+            string agent = ConfigurationManager.AppSettings["MapAgentUrl"];
+            MAPNAME.Value = Request.Params["MAPNAME"];
+            SESSION.Value = Request.Params["SESSION"];
+
+            IServerConnection conn = ConnectionProviderRegistry.CreateConnection(
+                "Maestro.Http",
+                "Url", agent,
+                "SessionId", SESSION.Value);
+
+            IMappingService mpSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
+            string rtMapId = "Session:" + conn.SessionID + "//" + MAPNAME.Value + ".Map";
+
+            RuntimeMap rtMap = mpSvc.OpenMap(rtMapId);
+
+            //Get the selected layer
+            RuntimeMapLayer rtLayer = rtMap.Layers.GetByObjectId(ddlLayers.SelectedValue);
+
+            //Get the class definition
+            ClassDefinition clsDef = conn.FeatureService.GetClassDefinition(rtLayer.FeatureSourceID, rtLayer.QualifiedClassName);
+
+            StringBuilder sb = new StringBuilder();
+
+            sb.Append("<p>Schema: " + clsDef.QualifiedName.Split(':')[0] + "</p>");
+            sb.Append("<p>Class Name: " + clsDef.Name + "</p>");
+            sb.Append("<strong>Properties (* indicates identity):</strong>");
+            sb.Append("<ul>");
+            for (int i = 0; i < clsDef.Properties.Count; i++)
+            {
+                PropertyDefinition prop = clsDef.Properties[i];
+                bool isIdentity = false;
+
+                if (prop.Type == PropertyDefinitionType.Data)
+                {
+                    isIdentity = clsDef.IdentityProperties.Contains((DataPropertyDefinition)prop);
+                }
+                string name = (isIdentity ? "* " + prop.Name : prop.Name);
+                sb.AppendFormat("<li><p>Name: {0}</p><p>Type: {1}</p></li>", name, prop.Type.ToString());
+            }
+            sb.Append("</ul>");
+
+            classDef.InnerHtml = sb.ToString();
+        }
+    }
+}

Added: trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/LayerInfo.aspx.designer.cs
===================================================================
--- trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/LayerInfo.aspx.designer.cs	                        (rev 0)
+++ trunk/Tools/Maestro/SDK/SamplesWeb/SamplesWeb/Tasks/LayerInfo.aspx.designer.cs	2011-11-22 15:03:24 UTC (rev 6244)
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:2.0.50727.5448
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace SamplesWeb.Tasks {
+    
+    
+    public partial class LayerInfo {
+        
+        /// <summary>
+        /// form1 control.
+        /// </summary>
+        /// <remarks>
+        /// Auto-generated field.
+        /// To modify move field declaration from designer file to code-behind file.
+        /// </remarks>
+        protected global::System.Web.UI.HtmlControls.HtmlForm form1;
+        
+        /// <summary>
+        /// MAPNAME control.
+        /// </summary>
+        /// <remarks>
+        /// Auto-generated field.
+        /// To modify move field declaration from designer file to code-behind file.
+        /// </remarks>
+        protected global::System.Web.UI.HtmlControls.HtmlInputHidden MAPNAME;
+        
+        /// <summary>
+        /// SESSION control.
+        /// </summary>
+        /// <remarks>
+        /// Auto-generated field.
+        /// To modify move field declaration from designer file to code-behind file.
+        /// </remarks>
+        protected global::System.Web.UI.HtmlControls.HtmlInputHidden SESSION;
+        
+        /// <summary>
+        /// ddlLayers control.
+        /// </summary>
+        /// <remarks>
+        /// Auto-generated field.
+        /// To modify move field declaration from designer file to code-behind file.
+        /// </remarks>
+        protected global::System.Web.UI.WebControls.DropDownList ddlLayers;
+        
+        /// <summary>
+        /// btnDescribe control.
+        /// </summary>
+        /// <remarks>
+        /// Auto-generated field.
+        /// To modify move field declaration from designer file to code-behind file.
+        /// </remarks>
+        protected global::System.Web.UI.WebControls.Button btnDescribe;
+        
+        /// <summary>
+        /// classDef control.
+        /// </summary>
+        /// <remarks>
+        /// Auto-generated field.
+        /// To modify move field declaration from designer file to code-behind file.
+        /// </remarks>
+        protected global::System.Web.UI.HtmlControls.HtmlGenericControl classDef;
+    }
+}



More information about the mapguide-commits mailing list