Common Extend tasks


Purpose
This sample demonstrates how to customize task controls included with the Web Application Developer Framework (ADF). Customizing out-of-the-box tasks usually involves extending the respective task class, overriding the necessary methods, and modifying results. This sample provides a page developer perspective for extending a Web ADF task by including the appropriate class files in the App_Code folder for the Web application. This technique is valuable if you want to modify an ADF task for a specific application.
 
The following ADF tasks have been extended in this sample:
  • ExtendFindAddressTask.cs—Modifies the symbology and attributes for match candidates returned as the result of a geocode operation. The base FindAddressTask generates results in a graphics dataset that contains match candidates in a feature graphics layer. The feature graphics layer has a layer format to define symbology and attribute display characteristics. The default renderer and fields collection for attributes are changed. The layer format is updated to reflect the changes. The FindAddressTaskWebSite.aspx page shows how the extended FindAddressTask is integrated in a page.
  • ExtendGPTask.cs—Modifies the symbology of results returned from a geoprocessing resource. If a geoprocessing resource generates feature set output, it can be rendered using a map service or returned as features to the client. If the underlying geoprocessing service is buddied to a map service and the GPTask's DrawResultsOnMapServer property is true, feature set results are rendered using the map service. In this case, the GPTask adds the results as a MapResourceNode, which can be accessed and modified by overriding the GetCallbackResults() method. The MapResourceNode contains a map resource added dynamically to the MapResourceManager and rendered in the Map. If a map service is not available, or the DrawResultsOnMapServer property is false, results are sent to the GPTask and packaged as a GraphicsLayerNode. The GraphicsLayerNode contains a feature graphics layer drawn by the Web ADF in the Web or client tier. In both cases, ExtendGPTask.cs illustrates how to change the transparency of results. The GPTaskWebSite.aspx page shows how the extended GPTask is integrated in a page.
  • ExtendQueryTask.cs—Extends the QueryAttributesTask to add a custom context menu to query results, maintains a single set of results from the same task, and constructs a hyperlink attribute. Results are returned as a System.Data.DataSet that contains one or more feature graphics layers, one for each layer that generated results. Results are repackaged as a TaskResultsNode containing one or more GraphicsLayerNodes and FeatureNodes. The QueryTaskWebSite.aspx page shows how the extended QueryAttributeTask is integrated in a page.
To extend an ADF task and redistribute it for multiple applications, follow the server control developer path and create a custom class library. Creating a custom server control is presented in the Common Custom controls sample.

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/GP/BufferTools, <Your ArcGIS Developer Kit Install directory>/Samples/data/California/CaliforniaProjected.mxd, <Your ArcGIS Developer Kit Install directory>/Samples/data/BloomfieldTownship/RoadCenterline_Locator and <Your ArcGIS Developer Kit Install directory>/Samples/data/USA/USA.mxd.
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 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. This folder contains the Common_ExtendTasks CSharp and VBNet folders.
  3. Open the folder of the language you're going to use—CSharp or VBNet—and copy the Common_ExtendTasks_<language> folder to c:\inetpub\wwwroot. The <language> variable can be either CSharp or VBNet.
  4. Start Microsoft Visual Studio 2008 and open the Common_ExtendTasks_<language><vs_version> solution (for example, Common_ExtendTasks_CSharp2008.sln) located in c:\inetpub\wwwroot\Common_ExtendTasks_<language>. The <vs_version> references the Visual Studio version of the solution, 2008 or 2010.
  5. In Solution Explorer, display one of the Web pages illustrating the use of extended tasks, and configure the extended task appropriately.
  6. Right-click the Web page you've configured and select Set As Start Page.

At run time
  1. Start the Web application.
  2. In FindAddressTaskWebSite.aspx, type in an address and execute the geocode operation. The symbology changes and limited fields are displayed for match candidates in the TaskResults control and MapTips callout.
  3. In GPTaskWebSite.aspx, add the required inputs and submit the job. Note the transparency of the feature results displayed in the map.
  4. In QueryTaskWebSite.aspx, enter query parameters and execute the query. Note the custom context menu on feature nodes in the TaskResults control. Also, one field contains hyperlink text which, when clicked, opens a new browser window and initiates a search on the clicked item.
  5. Execute the task again. A single set of selected feature is maintained in the TaskResults control.

Common_ExtendTasks_CSharp\App_Code\ExtendFindAddressTask.cs Extended FindAddressTask.
Common_ExtendTasks_CSharp\App_Code\ExtendGPTask.cs Extended GPTask.
Common_ExtendTasks_CSharp\App_Code\ExtendQueryTask.cs Extended QueryAttributesTask.
Common_ExtendTasks_CSharp\App_Code\Utility.cs Shared utility methods.
Common_ExtendTasks_CSharp\FindAddressTaskWebSite.aspx Basic page contains extended FindAddressTask.
Common_ExtendTasks_CSharp\FindAddressTaskWebSite.aspx.cs Code behind.
Common_ExtendTasks_CSharp\GPTaskWebSite.aspx Basic page contains extended GPTask.
Common_ExtendTasks_CSharp\GPTaskWebSite.aspx.cs Code behind.
Common_ExtendTasks_CSharp\QueryTaskWebSite.aspx Basic page contains extended QueryAttributesTask.
Common_ExtendTasks_CSharp\QueryTaskWebSite.aspx.cs Code behind.
Download the C# files
Common_ExtendTasks_VBNet\App_Code\ExtendFindAddressTask.vb Extended FindAddressTask.
Common_ExtendTasks_VBNet\App_Code\ExtendGPTask.vb Extended GPTask.
Common_ExtendTasks_VBNet\App_Code\ExtendQueryTask.vb Extended QueryAttributesTask.
Common_ExtendTasks_VBNet\App_Code\Utility.vb Shared utility methods.
Common_ExtendTasks_VBNet\FindAddressTaskWebSite.aspx Basic page contains extended FindAddressTask.
Common_ExtendTasks_VBNet\FindAddressTaskWebSite.aspx.vb Code behind.
Common_ExtendTasks_VBNet\GPTaskWebSite.aspx Basic page contains extended GPTask.
Common_ExtendTasks_VBNet\GPTaskWebSite.aspx.vb Code behind.
Common_ExtendTasks_VBNet\QueryTaskWebSite.aspx Basic page contains extended QueryAttributesTask.
Common_ExtendTasks_VBNet\QueryTaskWebSite.aspx.vb Code behind.
Download the VB.NET files

Download the files for all languages