Common Custom EditorTask


Purpose
The EditorTask includes a comprehensive set of out-of-the-box capabilities. However, many Web editing solutions require customization of the EditorTask to satisfy specific requirements. The EditorTask offers the following options for developing a custom solution:
  • Use the out-of-the-box EditorTask and add custom functionality by handling EditorTask events in a page (the class library project)
  • Create a custom Web control by subclassing the EditorTask and its child controls (the Web project)
This sample presents both options. The sample uses the PostbackManager control, which is included in the Common_PostbackManager sample.  You must build this sample and add a reference to the dll it creates.  The sample is located at:

<ArcGIS install location>\DeveloperKit10.0\Samples\ServerNet\Web_Applications\Common_PostbackManager<language>. It is a utility control that provides a simple way to issue asynchronous requests and manipulate requests made by Web Application Developer Framework (ADF) controls.
 
See the Additional information section below for details of the customizations used in these projects.

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/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 Web Application Developer Framework (ADF) for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
  2. In Windows Explorer, navigate to <ArcGIS install location>\DeveloperKit10.0\Samples\ServerNET\Common_CustomEditorTask. This folder contains the sample's CSharp and VBNet folders.
  3. Open the folder of the language you're going to use—CSharp or VBNet—and copy the Common_CustomEditorTask_<language> folder to c:\inetpub\wwwroot. The <language> variable can be either CSharp or VBNet.
  4. Set up access to the geodatabase by following the steps in the Set up access to the geodatabase section below.
  5. Configure the map document and create the map service by following the steps in the Configure the map document and create the map service section below.
  6. Open the IIS Manager from Control Panel > Administrative Tools > Internet Information Services (IIS) Manager or Internet Information Services.
  7. In the console tree view on the left, navigate to Local Computer > Web Sites > Default Web Site, or navigate to the Web site on which you want to configure the sample.
  8. Open the Common_ CustomEditorTask _<language> folder, right-click the CustomEditorTaskWebApp_<language> folder, and click Properties. The Properties dialog box opens.
  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 Microsoft Visual Studio 2008 and open the Common_CustomEditorTask_<language> solution (for example, Common_CustomEditorTask_CSharp2008.sln) located in c:\inetpub\wwwroot\Common_CustomEditorTask_<language>\Common_CustomEditorTask_<language><vs_version>. The <vs_version> references the Visual Studio version of the solution, 2008.
  11. In Solution Explorer, right-click the CustomEditorTaskWebApp _<language> project and select Set as StartUp Project.
  12. Right-click CustomEditorTaskPage.aspx and select Set As Start Page.
  13. Right-click the custom EditorTask class library project (CustomEditorTask_<language>) and build the project. The custom EditorTask assembly is added to the Web project.
  14. If necessary, set the run time identity of the Web application by following one of the next two steps. If not necessary, proceed to step 17.
  15. At design time, the identity of the user running Visual Studio is used to connect to an ArcGIS Server local data source. At run time, that identity is established by the Web application. Only one identity can be used to define access to the 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 that will be used to access ArcGIS Server local resources at run time. This information is added to the web.config file in a standard ASP.NET identity tag. If the Encrypt identity in web.config check box is checked, the identity tag will be encrypted; otherwise, the username and password are stored as clear text.
  16. Open the web.config file, add an <identity> element in <system.web>, set the impersonate attribute to true, and add a username and password attribute and set them to a valid user account. Since you're working with an ArcGIS Server local data source in this sample, ensure the account has access to the geographic information system (GIS) server resources referenced in the MapResourceManager control.
  17. Open the CustomEditorTaskPage.aspx page in Design view and define the connection properties for the single ArcGIS Server local map resource item in MapResourceManager.
  18. Set the CustomEditorTask1 control properties to define the map and resource, the editable layers (select all), and the editable versions (select all).
  19. Open the StandardEditorTaskPage.aspx page and modify MapResourceManager and EditorTask1 using the same properties as defined in the CustomEditorTaskPage.aspx page.
  20. Save the project.

Set up access to the geodatabase
  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 own data, you need to change portions of the sample code for it to function.
  2. Start ArcCatalog.
  3. Under Database Servers, click Add Database Server, and connect to SQLExpress.
  4. Right-click the SQLExpress instance, select Permissions, and add the ArcGIS Server container account.
  5. Right-click the SQLExpress instance, select Attach, and navigate to the Montgomery.mdf file included with the sample (for example, c:\inetpub\wwwroot\Common_ CustomEditorTask _CSharp\data\Montgomery.mdf). The EditParcels geodatabase is added to the geodatabase list for the SQLExpress instance in ArcCatalog.
  6. Right-click the Montgomery geodatabase, select Administration, select Permissions, and grant the ArcGIS Server container account read and write privileges.

Configure the map document and create the map service
  1. Open Montgomery.mxd in ArcMap. The data source for every layer is invalid, and a red exclamation point is displayed next to each layer name.
  2. Click the red exclamation point next to the Dimension features layer to open the Set Data Source dialog box as shown in the first screen shot below.
  3. Navigate to the SQLExpress instance on which the Montgomery geodatabase is available, select the Montgomery.DBO.Dimensions feature class, and click OK. Data sources for all layers in the map document are repaired.
  4. Save the map document. ArcMap appears as shown in the second screen shot below.
  5. Open ArcCatalog and add a new map service with the following properties: Name= Montgomery; Map document= <path to Montgomery.mxd>; Pooling= Not Pooled; Min instances= 0; Max instances= 6
  6. Start the service.


  7. Screen shot of the Set Data Source dialog box


    Screen shot of the Montgomery.mxd map document

At run time
  1. Browse to the Web page that contains the out-of-the-box EditorTask control (customized via EditorTask events in the page—for example, http://localhost/Common_CustomEditorTask_CSharp/Common_CustomEditorTaskWebApp_CSharp/StandardEditorTaskPage.aspx). A map containing the sample data and a menu with the option of enabling the EditorTask displays.
  2. Click the menu item to open the EditorTask and select a version to edit.
  3. Edit the features pursuant to the customizations described in the Class library project section below.
  4. Browse to the Web page that contains the custom EditorTask control (for example, http://localhost/Common_CustomEditorTask_CSharp/Common_CustomEditorTaskWebApp_CSharp/CustomEditorTaskPage.aspx).
  5. Edit the features pursuant to the customizations described in the Web project section below.

Additional information

Class library project
As discussed in the Purpose section, there are two options for customizing editing. The first is the class library project. It uses the out-of-the-box EditorTask and adds custom functionality by handling EditorTask events in a page. This option gives convenient access to standard EditorTask events in a Web application.
 
The class library project (for example, CustomEditorTask_CSharp) contains the classes and content to create a custom EditorTask control. Note the following customizations:
 
  • On post-tool execute, if a feature was created or modified in the Parcels layer, the time of the edit is written to the respective fields in the feature class.
  • EditExistingFeaturePanel has been replaced by a custom Editor panel. The custom panel subclasses EditExistingFeaturePanel and adds two custom Editor tools: Clip Features and Convert Polygon to Polyline.
  • A set of custom properties on the EditorTask define whether map units are used for snapping. If true, a custom EditorSettingsPanel replaces the existing default panel. The custom panel also contains a custom SnappingPanel that contains the logic necessary to snap using map units (pixel tolerance changes with map scale).
  • Three custom editor panels provide varying levels of control over creating an attribute query to select features in the active edit layer. The Simple Query panel uses a field, operator, and value to select features. The Search Attributes panel enables you to search one or more fields for a value. The Query Builder panel enables you to build a complex query for selecting features.
 
Web project
The second option for customizing editing is the Web project. It creates a custom Web control by subclassing the EditorTask and its child controls. This option is more complex, but provides comprehensive access to the implementation details (including events) of the EditorTask and its subcomponents. It also enables you to package a Web ADF editing solution as a redistributable custom EditorTask control.
 
The Web project (for example, CustomEditorTaskWebApp_CSharp) contains two pages and a set of custom components (Editor tools and panels) in the App_Code folder. One page includes a reference to the custom EditorTask control created in the class library project. The other page contains an out-of-the-box Editor task that is customized by handling events on the EditorTask. Both pages handle the release of server context for non-pooled services via a partial postback request sent when the browser is closed. The request is manager by PostbackManager control added to the web form at design time. It is important to add the reference to PostbackManager_<language>.dll to the web form.The following customizations are made to the out-of-the-box EditorTask:
  • A custom CreateFeaturePanel is added to the Editor. It contains a custom tool that references the prepackaged CreateFeature EditorToolServerAction.
  • A custom Clip Editor tool is added to the existing GeometryToolbar1 in the EditExistingFeaturePanel. The Clip tool only works with polyline and polygon layers.
  • A custom Editor toolbar and a custom Editor command are added to the EditExistingFeaturePanel.
  • On pre-attribute update, if an UPDATEDBY field exists in the active edit layer and an authenticated user has been defined, add the username as a field value.
  • On post-attribute update, if the update was not successful, return the exception message in an alert box.
  • On pre-command execute, cancel actions that delete features in the Parcels Layer.


Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\CustomEditorTask_CSharp.csproj Custom EditorTask class library project file.
Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\ClipFeatures.cs Custom editor tool to clip selected features.
Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\CustomEditExistingFeaturePanel.cs Custom editor panel that subclasses the EditExistingFeaturePanel class.
Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\CustomEditor.cs Custom Editor class.
Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\CustomEditorSettingsPanel.cs Custom editor panel that subclasses the SettingsPanel class.
Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\CustomEditorTask.cs Custom EditorTask that subclasses the out-of-the-box EditorTask.
Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\CustomSnappingPanel.cs Custom editor panel replacing the out-of-the-box SettingsPanel.
Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\PolygonToLine.cs Custom editor command to convert selected polygons to lines.
Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\PolygonToLineLayerEditorPanel.cs Custom editor panel that contains a drop-down list to set the line layer for the PolygonToLine command.
Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\CustomUtilities.cs Basic utility methods and logic for a custom editor task.
Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\SimpleQueryPanel.cs Custom editor panel that enables you to define a simple query using a field, operator, and value to select features.
Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\SearchAttributesPanel.cs Custom editor panel that enables you to search for a value in multiple fields and select features that match the query.
Common_CustomEditorTask_CSharp\CustomEditorTask_CSharp\QueryBuilderPanel.cs Custom editor panel that enables you to define a complex query for selecting editable features.
Common_CustomEditorTask_CSharp\CustomEditorTaskWebApp_CSharp\CustomEditorTaskPage.aspx Web page containing the custom EditorTask control.
Common_CustomEditorTask_CSharp\CustomEditorTaskWebApp_CSharp\CustomEditorTaskPage.aspx.cs Code behind. Only contains code to release server context for non-pooled services.
Common_CustomEditorTask_CSharp\CustomEditorTaskWebApp_CSharp\StandardEditorTaskPage.aspx Web page containing the out-of-the-box EditorTask control.
Common_CustomEditorTask_CSharp\CustomEditorTaskWebApp_CSharp\StandardEditorTaskPage.aspx.cs Code behind. Contains code that works with EditorTask events to customize functionality.
Download the C# files
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\CustomEditorTask_VBNet.vbproj Custom EditorTask class library project file.
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\ClipFeatures.vb Custom editor tool to clip selected features.
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\CustomEditExistingFeaturePanel.vb Custom editor panel that subclasses the EditExistingFeaturePanel class.
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\CustomEditor.vb Custom Editor class.
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\CustomEditorSettingsPanel.vb Custom editor panel that subclasses the SettingsPanel class.
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\CustomEditorTask.vb Custom EditorTask that subclasses the out-of-the-box EditorTask.
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\CustomSnappingPanel.vb Custom editor panel replacing the out-of-the-box SettingsPanel.
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\PolygonToLine.vb Custom editor command to convert selected polygons to lines.
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\PolygonToLineLayerEditorPanel.vb Custom editor panel that contains a drop-down list to set the line layer for the PolygonToLine command.
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\CustomUtilities.vb Basic utility methods and logic for a custom editor task.
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\SimpleQueryPanel.vb Custom editor panel that enables you to define a simple query using a field, operator, and value to select features.
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\SearchAttributesPanel.vb Custom editor panel that enables you to search for a value in multiple fields and select features that match the query.
Common_CustomEditorTask_VBNet\CustomEditorTask_VBNet\QueryBuilderPanel.vb Custom editor panel that enables you to define a complex query for selecting editable features.
Common_CustomEditorTask_VBNet\CustomEditorTaskWebApp_VBNet\CustomEditorTaskPage.aspx Web page containing the custom EditorTask control.
Common_CustomEditorTask_VBNet\CustomEditorTaskWebApp_VBNet\CustomEditorTaskPage.aspx.vb Code behind. Only contains code to release server context for non-pooled services.
Common_CustomEditorTask_VBNet\CustomEditorTaskWebApp_VBNet\StandardEditorTaskPage.aspx Web page containing the out-of-the-box EditorTask control.
Common_CustomEditorTask_VBNet\CustomEditorTaskWebApp_VBNet\StandardEditorTaskPage.aspx.vb Code behind. Contains code that works with EditorTask events to customize functionality.
Download the VB.NET files

Download the files for all languages