Common Custom controls
Common_CustomControls_CSharp\ADFWebPart\MapIdentify.cs
// Copyright 2010 ESRI
// 
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// 
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// 
// See the use restrictions.
// 


namespace ADFWebPart
{
    /// <summary>
    /// Custom tool for identifying features on the map
    /// </summary>
    internal class MapIdentify : ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools.IMapServerToolAction
    {
        #region IMapServerToolAction Members

        void ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools.IMapServerToolAction.ServerAction(
            ESRI.ArcGIS.ADF.Web.UI.WebControls.ToolEventArgs toolEventArgs)
        {
            // Get the Map control that was clicked
            ESRI.ArcGIS.ADF.Web.UI.WebControls.Map adfMap = toolEventArgs.Control as ESRI.ArcGIS.ADF.Web.UI.WebControls.Map;                    

            // Get the point clicked
            ESRI.ArcGIS.ADF.Web.UI.WebControls.MapPointEventArgs mapPointEventArgs =
                (ESRI.ArcGIS.ADF.Web.UI.WebControls.MapPointEventArgs)toolEventArgs;
            ESRI.ArcGIS.ADF.Web.Geometry.Point adfPoint = mapPointEventArgs.MapPoint; 
         
            // Identify each functionality (i.e. resource) in the map
            foreach (ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality gisFunctionality in adfMap.GetFunctionalities())
            {
                // Get a reference to the current resource and check whether it supports querying
                ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gisResource = gisFunctionality.Resource;
                bool supportsQueryFunctionality = gisResource.SupportsFunctionality(
                    typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality));

                if (supportsQueryFunctionality)
                {
                    // Create a query functionality object to use in performing the identify operation
                    ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality queryFunctionality =
                        (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)gisResource.CreateFunctionality
                        (typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);

                    // Get the names and IDs of the current resource's queryable layers
                    string[] layerIDs = null;
                    string[] layerNames = null;
                    queryFunctionality.GetQueryableLayers(null, out layerIDs, out layerNames);

                    int pixelTolerance = 3;

                    // Execute the identify operation
                    System.Data.DataTable[] identifyResultsDataTableArray =
                        queryFunctionality.Identify(gisFunctionality.Name, adfPoint,
                        pixelTolerance, ESRI.ArcGIS.ADF.Web.IdentifyOption.AllLayers, layerIDs);

                    // Put code here for manipulating the results tables for display
                }
            }
        }

        #endregion
    }
}