Ejemplo n.º 1
0
 /// <summary>
 /// Gets the map query data.
 /// </summary>
 /// <param name="mapServer">The map server.</param>
 /// <param name="layerName">Name of the layer.</param>
 /// <param name="whereClause">The where clause.</param>
 /// <param name="maxRecords">The max records.</param>
 /// <param name="assetType">Type of the asset.</param>
 /// <returns></returns>
 private MapCustomDataTable GetMapQueryData(MapServerProxy mapServer, string layerName, 
     string whereClause,int maxRecords, string assetType)
 {
     #region "Local Variables"
     DataTable dtQSrch = null;
     MapCustomDataTable dtCustomQSrch = null;
     int intLayerID = -1;
     QueryFilter objQSFilter = new QueryFilter();
     MapProcessManager objMapController = null;
     ESRI.ArcGIS.ADF.StringCollection objFieldsColl = null;
     string strFields = string.Empty;
     ESRI.ArcGIS.ADF.ArcGISServer.RecordSet objRS = null;
     #endregion
     try
     {
         if (!string.IsNullOrEmpty(layerName))
         {
             intLayerID = GetLayerID(mapServer, layerName);
             if (intLayerID != -1)
             {
                 //assigning Query Functionality
                 //Declaring Query Filter and assigning properties
                 objMapController = new MapProcessManager();
                 objFieldsColl = new ESRI.ArcGIS.ADF.StringCollection();
                 objQSFilter.WhereClause = whereClause;
                 objFieldsColl = objMapController.GetSubFields(layerName);
                 foreach (string strColumnName in objFieldsColl)
                 {
                     if (!string.IsNullOrEmpty(strFields))
                         strFields = strFields + "," + strColumnName;
                     else
                         strFields = strColumnName;
                 }
                 if (objFieldsColl != null && objFieldsColl.Count > 0) objQSFilter.SubFields = strFields;
                 //Querying for data Table.
                 objRS = mapServer.QueryFeatureData(mapServer.GetMapName(0), intLayerID, objQSFilter);
                 dtQSrch = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToDataTable(objRS);
                 if (dtQSrch != null && dtQSrch.Rows.Count > 0)
                 {
                     dtCustomQSrch = FormatDataTable(dtQSrch,layerName,maxRecords, assetType);
                 }
             }
         }
     }
     catch
     {
         throw;
     }
     finally
     {
         if (dtQSrch != null) dtQSrch.Dispose();
         if (dtCustomQSrch != null) dtCustomQSrch.Dispose();
     }
     return dtCustomQSrch;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Gats the map spatial query data.
 /// </summary>
 /// <param name="mapServer">The map server.</param>
 /// <param name="inputGeometry">The input geometry.</param>
 /// <param name="layerName">Name of the layer.</param>
 /// <param name="maxRecords">The max records.</param>
 /// <param name="returnGeometry">if set to <c>true</c> [return geometry].</param>
 /// <param name="assetType">Type of the asset.</param>
 /// <returns></returns>
 private MapCustomDataTable GatMapSpatialQueryData(MapServerProxy mapServer, 
 ESRI.ArcGIS.ADF.Web.Geometry.Geometry inputGeometry,
 string layerName, int maxRecords, bool returnGeometry, string assetType)
 {
     #region "Local Variables"
     DataTable objDataTable = null;
     MapCustomDataTable objCustomDataTable = null;
     int intLayerID = -1;
     SpatialFilter objSpatailFil;
     MapProcessManager objMapController = null;
     ESRI.ArcGIS.ADF.StringCollection objStrColl = null;
     string strFields = string.Empty;
     ESRI.ArcGIS.ADF.ArcGISServer.RecordSet objRS = null;
     #endregion
     try
     {
         if (!string.IsNullOrEmpty(layerName))
         {
             intLayerID = GetLayerID(mapServer, layerName);
             if (intLayerID != -1)
             {
                 objMapController = new MapProcessManager();
                 objStrColl = new ESRI.ArcGIS.ADF.StringCollection();
                 //creating spatial filter
                 objSpatailFil = new SpatialFilter();
                 //setting geometry to spatial filter
                 objSpatailFil.FilterGeometry = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfGeometry(inputGeometry);
                 objSpatailFil.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                 objStrColl = objMapController.GetSubFields(layerName);
                 foreach (string strColumnName in objStrColl)
                 {
                     if (!string.IsNullOrEmpty(strFields))
                         strFields = strFields + "," + strColumnName;
                     else
                         strFields = strColumnName;
                 }
                 if (objStrColl != null && objStrColl.Count > 0) objSpatailFil.SubFields = strFields;
                 //obtaining queried data table
                 objRS = mapServer.QueryFeatureData(mapServer.GetMapName(0), intLayerID, objSpatailFil);
                 objDataTable = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToDataTable(objRS);
                 //formatting data table
                 if (objDataTable != null && objDataTable.Rows.Count > 0 && returnGeometry == false)
                 {
                     objCustomDataTable = FormatDataTable(objDataTable, layerName,
                          maxRecords, assetType);
                 }
             }
         }
     }
     catch
     {
         throw;
     }
     finally
     {
         if (objDataTable != null) objDataTable.Dispose();
         if (objCustomDataTable != null) objCustomDataTable.Dispose();
     }
     return objCustomDataTable;
 }