ArcGIS Add Dynamic Data



Description:

This sample illustrates the managements of shallowly stateful operations with stateless pooled ArcGIS Server map server objects. Shallowly stateful means state is managed by the client instead of by the server object. Pooled server objects are designed to be stateless, so any stateful changes must be made and reset within server content. Since pooled server objects reside in a pool, any stateful changes that are not reset will be visible by the next client who access that server object.

A list of pages and a description of their content is listed below. In most cases, session state is managed in the page codefile. Since the samples are designed to work with a pooled server object, the changes are applied when the server context is created and removed before server context is released - essentially resetting the map server object to its original state.



Sample data location: <ArcGIS install location>\DeveloperKit\SamplesNet\Server\data\USA
Products:
Server: C#, VB.NET

Platforms: Windows

Minimum ArcGIS Release: 9.3

How to use:
  1. Design Time:
    1. Verify that the appropriate services are available (see description for more details).
    2. Verify that the Web ADF for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
    3. In Windows Explorer, navigate to <ArcGIS install location>\DeveloperKit\SamplesNet\Server\Web_Applications and unzip ArcGIS_AddDynamicDataCSharp.zip or ArcGIS_AddDynamicDataVBNet.zip to a location of your choice. You should see either a CSharp or VBNet folder appear where you unzipped the files.
    4. In Windows Explorer, open the directory referencing the language of your choice: CSharp or VBNet. Copy the folder, ArcGIS_AddDynamicData_<language>, to c:\inetpub\wwwroot. The <language> variable may be either CSharp or VBNet.
    5. Open the IIS Manager from Control Panel > Administrative Tools > Internet Information Services (IIS) Manager or Internet Information Services
    6. In the console tree view on the left, navigate to Local Computer > Web Sites > Default Web Site.
    7. Expand Default Web Site then right-click the ArcGIS_AddDynamicData_<language> folder and click Properties.
    8. On the Directory tab, click the Create button in the Application Settings section of this panel. Click OK to dismiss the Properties dialog.
    9. Launch Microsoft Visual Studio. Open the solution for the version of the Visual Studio you are using. The Visual Studio version is appended to the solution file name. For example, the Visual Studio 2008 solution file is ArcGIS_AddDynamicData_CSharp2008.sln and located in the c:\inetpub\wwwroot\ArcGIS_AddDynamicData_CSharp folder.
    10. In the Solution Explorer, right-click Default.aspx and select 'Set As Start Page'.
    11. Open the Default.aspx.cs page. In the getServerContext() method, change the servername variable to the name of the machine on which the server object manager (SOM) is running. Also, change the mapserverobject variable to the name of the map server object running on the SOM.
    12. Open the layers.catalog file. This file contains a list of data layer names and paths to datasets that will be added dynamically in Default.aspx. The path to the datasets (in the example, shapefiles) must be valid from the perspective of the server object container (SOC) machines. The dynamic layers and data layers within the server object specified in the previous step must share the same geographic area to be concurrently visible. The sample references data in the <ArcGIS install location>\DeveloperKit\SamplesNet\Server\data\NorthAmerica.
    13. In the codefile for Default_ADF.aspx (e.g. Default_ADF.aspx.cs) search for the region named "Create Layer" (AddLayer method). Modify the dynamic layer properties to point to the location of a data layer on disk. By default, the canada.shp shapefile, located in c:\temp\data, is the dynamic layer. Grant the server object container account (SOC) permission to access this location.
    14. Open the Default_ADF.aspx page in design view. Select the MapResourceManager and click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog should display.
    15. Add or change the MapResourceItem associated with an ArcGIS Server map service. In this case, the USA_Data map service will work.
    16. If necessary, set the runtime identity of the Web application:
      1. At design-time, the identity of the user running Visual Studio is used to connect to an ArcGIS Server local data source. At runtime, that identity is established by the Web application. Only one identity can be used to define access to all ArcGIS Server local data sources in a single Web application. This identity can be explicitly defined when building the Web ADF application in Visual Studio by right-clicking the Web project in Solution Explorer, and selecting the Add ArcGIS Identity option. Enter the identity credentials which will be used to access ArcGIS Server local resources at runtime. This information will be added to the web.config file within a standard ASP.NET identity tag. If the "Encrypt identity in web.config" checkbox is checked, the identity tag will be encrypted, otherwise the username and password will be stored as clear text.
        -or-
      2. Open the web.config file and add an <identity> element within <system.web>. Set the impersonate attribute to "true". Add a userName and password attribute and set them to a valid user account. If working with ArcGIS Server Local data sources, make sure the account has access to the GIS Server resources referenced in the Map control.
    17. Other pages in this sample do not require specific changes as long as the data referenced above is used.
    18. Save the project.
    19. Click the "Debug" drop-down menu and choose "Start".
  2. Run Time:
    1. Browse to viewer's URL (for example, http://localhost/ArcGIS_AddDynamicData_CSharp) -or- start the Web application within Visual Studio 2005.
    2. In Default.aspx:
      1. Select a layer to add dynamically from the drop down list.
      2. Click the Add Layer button and the layer should be added dynamically.
      3. Click the Change Extent button and the extent of the map should shift. Note that the dynamic layer is still visible.
      4. Select another layer from the drop down list and click the Add Layer button. The new dynamic layer is drawn within the map. The original dynamic layer is removed. The sample is only designed to add one dynamic layer at a time.
    3. In Default_ADF.aspx:
      1. Click the Add Layer button to add the Canada.shp shapefile to the map. The Toc shows the newly added layer. Note that the layer is still visible in the map and the Toc as you navigate the map.
      2. Click the Remove Layer button to remove the layer from the map and toc.
    4. In CustomMapHandler_ADF.aspx:
      1. Click the Add Layer button to add the Canada.shp shapefile to the map. The Toc shows the newly added layer. Note that the layer is still visible in the map and the Toc as you navigate the map. This sample uses the custom MapHandler. Note, the Map.EnableMapHandler property on all other pages is false, thus all server-side operations iterate through page lifecycle.
      2. Click the Remove Layer button to remove the layer from the map and toc.
    5. In ChangeRenderer_ADF.aspx:
      1. Click the Change Renderer button to change the renderer for the states layer in the map. The Toc also shows changes to the renderer
    6. In MoveLayer_ADF.aspx:
      1. Click the Move Layer button to move the highways layer to the bottom of the layer list. The Toc shows the highways layer at the bottom of the layer list.
    7. In RemoveLayer_ADF.aspx:
      1. Click the Remove Layer button to remove the highways layer from the Map and Toc.

Download the C# files
Default.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddDynamicData_CSharp/Default.aspx.cs Code behind the aspx file. Manages server contents and session state.
layers.catalog Text file containing file system paths to data layers.
Default_ADF.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddDynamicData_CSharp/Default_ADF.aspx.cs Code behind the aspx file. Manages server contents and session state.
CustomMapHandler_ADF.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddDynamicData_CSharp/CustomMapHandler_ADF.aspx.cs Code behind the aspx file. Manages server contents and session state. Calls methods in ServerObjectStateModifier.cs where required.
ChangeRenderer_ADF.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddDynamicData_CSharp/ChangeRenderer_ADF.aspx.cs Code behind the aspx file. Manages server contents and session state.
RemoveLayer_ADF.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddDynamicData_CSharp/RemoveLayer_ADF.aspx.cs Code behind the aspx file. Manages server contents and session state.
MoveLayer_ADF.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddDynamicData_CSharp/MoveLayer_ADF.aspx.cs Code behind the aspx file. Manages server contents and session state.
ArcGIS_AddDynamicData_CSharp/App_Code/CustomMapHandler.cs Custom MapHandler, enabled via entries in the web.config. Calls methods in ServerObjectStateModifier.cs where required.
ArcGIS_AddDynamicData_CSharp/App_Code/ServerObjectStateModifier.cs Manages stateful changes to a stateless server object.
ArcGIS_AddDynamicData_CSharp/App_Code/Utility.cs Utility class for common actions.
Download the VB.NET files
Default.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddDynamicData_VBNet/Default.aspx.vb Code behind the aspx file. Manages server contents and session state.
layers.catalog Text file containing file system paths to data layers.
Default_ADF.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddDynamicData_VBNet/Default_ADF.aspx.vb Code behind the aspx file. Manages server contents and session state.
CustomMapHandler_ADF.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddDynamicData_VBNet/CustomMapHandler_ADF.aspx.vb Code behind the aspx file. Manages server contents and session state. Calls methods in ServerObjectStateModifier.vb where required.
ChangeRenderer_ADF.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddDynamicData_VBNet/ChangeRenderer_ADF.aspx.vb Code behind the aspx file. Manages server contents and session state.
RemoveLayer_ADF.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddDynamicData_VBNet/RemoveLayer_ADF.aspx.vb Code behind the aspx file. Manages server contents and session state.
MoveLayer_ADF.aspx Contains Web user interface to interact with server-side code.
ArcGIS_AddDynamicData_VBNet/MoveLayer_ADF.aspx.vb Code behind the aspx file. Manages server contents and session state.
ArcGIS_AddDynamicData_VBNet/App_Code/CustomMapHandler.vb Custom MapHandler, enabled via entries in the web.config. Calls methods in ServerObjectStateModifier.vb where required.
ArcGIS_AddDynamicData_VBNet/App_Code/ServerObjectStateModifier.vb Manages stateful changes to a stateless server object.
ArcGIS_AddDynamicData_VBNet/App_Code/Utility.vb Utility class for common actions.

Download the files for all languages