ArcGIS Checkout and check-in geodata


Purpose
This sample demonstrates how to work with an ArcGIS for Server geodata Web service. The Web application allows you to check out data in the current map extent from a geodatabase hosted by a geodata service. A personal geodatabase (child replica) is available for download to the client machine and can be edited with ArcMap. For this sample, store the personal geodatabase changes in a delta database. Check in the edits via the Web application by uploading the delta database and importing the changes from the child replica to the parent replica via the geodata service. Replication requires that the geodatabase hosting the parent replica be an ArcSDE geodatabase. In addition, data used in the replication process must meet the following requirements:
  • The database user must have write access to the data.
  • All data must be registered as versioned.
  • The data cannot be versioned with the option to move edits to base.
Use the following steps to set up the ArcSDE geodatabase using Structured Query Language (SQL) Express. A map document is available to create a map service that enables a client (via the Application Developer Framework [ADF]) to interactively define an extent used to check out data.
Note: Local (DCOM) connections are only supported for ArcGIS for Server versions prior to 10.1.

How to use

Data has been provided for your use with this sample. It can be found at <Your ArcGIS Developer Kit Install directory>/Samples/data/Montgomery/MontgomerySimple.mxd and <Your ArcGIS Developer Kit Install directory>/Samples/data/Montgomery/Montgomery.mdf.
If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

At design time
  1. Verify that the appropriate service is available (see the Purpose section for 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 Developer Kit install location>\Samples\ServerNet. This folder contains ArcGIS_Checkout_Checkin_geodata CSharp and VBNet folders.
  4. Open the folder of the language you are going to use (that is, CSharp or VBNet) and copy the ArcGIS_Checkout_Checkin_Geodata_<language> folder to c:\inetpub\wwwroot. The <language> variable can be CSharp or VBNet.
  5. Set up access to the geodatabase by following the steps in the Additional information section.
  6. Configure a map document and create the service by following the steps in the Additional information section.
  7. Open IIS Manager from Control Panel, Administrative Tools, Internet Information Services (IIS) Manager, or Internet Information Services.
  8. In the console tree view on the left, navigate to Local Computer, Web Sites, Default Web Site. Expand Default Web Site, right-click the ArcGIS_Checkout_Checkin_Geodata_<language> folder, and click Properties. The Properties dialog box appears.
  9. Click the Directory tab, click the Create button in the Application Settings section, then click OK to close the Properties dialog box.
  10. Start Visual Studio 2010 and open the ArcGIS_Checkout_Checkin_Geodata_<language> solution (for example, ArcGIS_Checkout_Checkin_Geodata_CSharp2010.sln) located in c:\inetpub\wwwroot\ArcGIS_Checkout_Checkin_Geodata_<language>\ArcGIS_Checkout_Checkin_Geodata_<language><vs_version>.
  11. In the Solution Explorer, right-click Default.aspx, and select Set As Start Page.
  12. Open the Default.aspx page in Design view, open the properties window of the MapResourceManager control, and click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog box appears.
  13. Add or change the MapResourceItem associated with an ArcGIS for Server local map service that contains a feature class with the restrictions defined in the Purpose section.
  14. Open the code behind page (for example, Default.aspx.cs) and set two member variables to define the Web service host name (m_hostName) and the geodata service name (m_serviceName). The variables are listed at the top of the file.
  15. Save the project.
  16. At run time, a personal geodatabase stores the checkout features on the client with the .mdb file extension. To download a .mdb file from an ASP.NET application, you can use a pre-packaged httphandler. By default, the personal geodatabase is exported to the output directory of the map service associated with the ResourceItem added in a previous step. The output directory must be exposed as a Web application in IIS to work. Add a web.config file to the directory with the content specified in the Web.config file contents subsection of the Additional information section.
  17. In Visual Studio, click the Debug drop-down menu and click Start.

At run time
  1. Browse to the viewer uniform resource locator (URL), for example, http://localhost/ArcGIS_Checkout_Checkin_Geodata_CSharp, or start the Web application in Visual Studio.
  2. Navigate to an area of the map that contains features you want to edit. Features that intersect the map extent will be checked out.
  3. Click the Check Out button and save the features locally as a personal geodatabase (.mdb file).
  4. Start ArcMap.
  5. Use the Add Data command to add the data from the checkout personal geodatabase to your map.
  6. Edit the data.
  7. When finished, save your edits.
  8. Click the Export Data Changes Message button on the Distributed Geodatabase toolbar. The Export Changes Wizard appears, and the replica from which to export changes is automatically set.
  9. To save changes, select the DeltaGeodatabase option and type the path to a new personal geodatabase (.mdb). A personal geodatabase is created.
  10. Return to your Web application, click Browse, and browse to the delta database (the personal geodatabase) created in the previous step.
  11. Click Check In. The Web application updates the versioned geodatabase (accessed via an ArcGIS for Server map service) with your edits. The edits are visible in the map.

Additional information

Set up access to the geodatabase

Do the following steps:
  1. You must have access to SQLExpress, configured for use with ArcSDE workgroup geodatabases, to use the data packaged with this sample. If you use your data, you need to change portions of the sample code for it to function.
  2. Start ArcCatalog, click Add Database Server under Database Servers, and connect to SQLExpress.
  3. Right-click the SQLExpress instance, select Permissions, and add the ArcGIS for Server container account.
  4. Right-click the SQLExpress instance, select Attach, and navigate to the Montgomery.mdf file included the samples data (for example, c:\iArcGIS\ProgramFiles\DeveloperKit10.0\Samples\Data\Montgomery.mdf). The Montgomery geodatabase is added to the geodatabase list for the SQLExpress instance in ArcCatalog.
  5. Right-click the Montgomery geodatabase, select Administration, Permissions, then grant the ArcGIS for Server container account (ArcGISSOC) read and write privileges. 
  6. Make sure all the data is RegisteredAsVersioned. The "Register As Versioned" tool from Versions toolset in DataManagement tools can be used to register the data as versioned.

Configure the map document and create the map service

Do the following steps:
  1. Open the MontgomerySimple.mxd file in ArcMap. Because the data source for every layer is invalid, a red exclamation point shows next to each layer name.
  2. Click the red exclamation point next to the Dimension features layer. The Set Data Source dialog box appears. See the following screen shot:


  3. Navigate to the SQLExpress instance where the Montgomery geodatabase is available, select the Montgomery.DBO.Dimensions feature class in the Montgomery.DBO.Landbase feature dataset, and click OK. Data sources for the layers in the map document are repaired.
  4. Save the map document. The following screen shot shows how the ArcMap window appears:


  5. Open ArcCatalog and add a new map service with the following properties:
    • Name—MontgomerySimple
    • Map document—<path to MontgomerySimple.mxd>
    • Pooling—Pooled, Min instances: 0, Max instances 2
  6. Start the service.
  7. Add a new geodata service with the following properties:
    • Name—MontgomerySimple
    • Use a map document—<path to MontgomerySimple.mxd>
    • Pooling—Pooled, Min instances: 0, Max instances 2
  8. Alternatively, you can add both services at the same time in ArcCatalog by right-clicking the .mxd file, selecting Publish to ArcGIS Server, and selecting the check box next to the Map and Geodata services.
  9. Since this sample demonstrates replication, the replication capability must be enabled on the geodata service. In ArcCatalog, stop the MontgomerySimple geodata service, open its Properties dialog box, click the Capabilities tab, and select the Replication check box.
  10. Restart the service.

File contents for web.config

The following are the contents of the web.config file:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<connectionStrings/>
<system.web>
<authentication mode="Windows"/>
<httpHandlers>
<remove verb="*" path="*.mdb" />
<add path="*.mdb" verb="*" type="System.Web.StaticFileHandler" />
</httpHandlers>
</system.web>
</configuration>


ArcGIS_Checkout_Checkin_Geodata_CSharp\Default.aspx User interface (UI) for the Web application.
ArcGIS_Checkout_Checkin_Geodata_CSharp\Default.aspx.cs The code behind the UI. Contains code that works directly with the geodata server object.
Download the C# files
ArcGIS_Checkout_Checkin_Geodata_VBNet\Default.aspx User interface (UI) for the Web application.
ArcGIS_Checkout_Checkin_Geodata_VBNet\Default.aspx.vb The code behind the (UI). Contains code that works directly with the geodata server object.
Download the VB.NET files

Download the files for all languages