Using
the GeoprocessingTask control
-
Add supporting controls to the page
In order to take full advantage of the GeoprocessingTask control, a number of
supporting controls must be available. Set up a Web application with
MapResourceManager, GeoprocessingResourceManager,
and Map controls using their discussion topics as
a guide. Be sure to point the GeoprocessingResourceManager to an available
ArcGIS Server-based geoprocessing resource. Add a
TaskResults control using that control's discussion topic as
a guide. At runtime, the TaskResults control displays the results of
GeoprocessingTask. Users can then interact with the results to change map
extent, display selected features, or re-execute the task. TaskResults also
displays a message to the user while the task executes.
The GeoprocessingResourceManager provides the information to the
GeoprocessingTask control for creating the user interface. The geoprocessing
resource inputs and behavior are determined by how the model was constructed.
See the ArcGIS Server Help
for information on creating and publishing geoprocessing models.
To hide the geoprocessing input form at application startup and allow the
user to call up the form from a link on the page, add a Menu control from
the standard ASP.NET Navigation tools, and then add a
TaskManager from the ArcGIS Web Controls toolbox group. If you want to
display the geoprocessing form immediately upon application startup, you
can skip adding these controls.
Be sure to set the BuddyControl property of the TaskManager to the Menu control
you added. Also set the Map property of the TaskResults control to the Map
control you added, if you want users to see results highlighted on the map when
selected.
-
Add a GeoprocessingTask control
In Visual Studio, display the prepared Web form in design
mode, select the Toolbox and expand the ArcGIS Web Controls
tab. Drag and drop a GeoprocessingTask control into the
TaskManager control, or if you did not add a TaskManager control, just drag the
GeoprocessingTask onto the page. Your page might resemble the following layout,
which was arranged using a table:

-
Set the required properties for the GeoprocessingTask control
In design mode, click the GeoprocessingTask, which displays the smart tag
arrow in the upper right of the control. Click on this arrow to display the
smart tag menu. This menu displays common properties that you can set, though
others are available in the Properties window for the control.

a. Task results container : Click the first item in the smart
tag menu to choose the Task Results container, or click the
TaskResultsContainers property button in the Properties window. This brings up
the BuddyControl collection editor. Click Add to add an item to the collection.
With the TaskResults1 item selected, in the right side of the dialog, click the
drop-down list and select the TaskResults control you added earlier. This is
where the GeoprocessingTask places results that are found when the user
executes a query.

b. Set up the query: Click the
second item in the smart tag menu for choosing the task definition, or click
the TaskDefinition attribute button in the Properties window. This opens the
TaskDefinition Editor dialog. In this dialog, select the
GeoprocessingResourceManager added earlier. Then select the geoprocessing
resource from the Resource drop-down list. Finally, select a Task from the
third drop-down list. If no tasks are available, check that the geoprocessing
service contains at least one valid tool. See the
ArcGIS Server Help for more information on creating geoprocessing
services.

c. Visibility of the QueryAttributesTask control: If you added
Menu and TaskManager controls, you can have the query form not display at
startup. Instead, the form displays when the user clicks the query link in the
Menu control. To hide the query form at startup, select the QueryAttributesTask
control, and in the Property window, set the Visible property to false.
-
Setting the position of geoprocessing form
By default, the GeoprocessingTask form appears in a floating window,
which the user may drag to a new position within the web page. The opening
position does not necessarily correspond to its position on the web page design
form. If preferred, the geoprocessing form window may be fixed at a specific
position.
To fix the position of the form at a specific location, set the
position style of the GeoprocessingTask or a containing control or DIV. To
set the style, switch the Web page from Design view to HTML view in Visual
Studio. Find the GeoprocessingTask in the page listing. Insert a style
attribute within the control tag, and set its position properties to specific
values. Use "position:absolute" to set the query form at an exact position on
the page. Use "position:relative" to fix the position relative to its placement
to other controls. In the following example, relative placement is used to
ensure the query window is placed within a table cell:
<td>
<esriTasks:GeoprocessingTask style="position:relative;top:5px;left:0px;"
ID="GeoprocessingTask1" runat="server" ...>
</esriTasks:GeoprocessingTask >
<td>
When fixing the position of the geoprocessing form window, you may want to set
the CloseButton, Draggable, ExpandCollapseButton, HeightResizable
and WidthResizable properties to false to disallow modifying the
query form. Setting Draggable to false disallows moving the form.
-
Other properties for GeoprocessingTask
Some of the properties that you may wish to modify for your application
include:
-
Title: Displayed at the top of the geoprocessing form to the user.
You should change this from the default, which is the ID of the control. Choose
a title that describes what the geoprocessing task does. An example would be
"Buffer points...".
-
AsyncStatusCheckInterval: Interval in seconds at
which the application checks for the status of the task execution.
Geoprocessing tasks are run asynchronously so that the user may perform other
operations in the Web application while the task executes. As the task
executes, the Web application retrieves the results on the next interval's
check. These results may contain data and information indicating the progress
of the task, as well as the final results of the task. These will be displayed
as retrieved. You can adjust this property based on the expected time to
execute the geoprocessing task. Default is 10 seconds.
-
FeatureSelectionColor: After task results display, and the
user checks the box next to a feature, the feature is highlighted with this
color on the map.
-
ShowDetailsInTable: Whether to display feature attributes in
the results for each feature
-
Using the GeoprocessingTask in the web application
If a TaskManager and Menu controls are used to bring up the geoprocessing task
form, the user clicks on the link for the geoprocessing task. This displays the
geoprocessing entry form. The number and format of form entry items depends on
the design of the geoprocessing model. The following is one example of a
geoprocessing input form, but the form will vary considerably based on the
model used.

The user interacts with the form to enter required values, then clicks Submit.
In the above example, the user activates the add-point tool to click on the map
to add points, then sets the buffer distance before submitting the form.
The results are displayed as they are retrieved in the TaskResults control
output. See TaskResults for a discussion
and examples of using the results from a task.
Members
Properties
The following table provides a list of properties of
interest. For complete reference information, see
the GeoprocessingTask control in the library reference section.
|
Property Name |
Type |
Description |
| AsyncStatusCheckInterval |
int |
The interval in milliseconds between job status checks for asynchronous
geoprocessing tasks. |
| DrawResultsOnMapServer |
bool |
Whether results can be drawn on map server if geoprocessing
resource has a map server available. |
| FeatureSelectionColor |
Color |
The Color of selected features. |
| HideOnSubmit |
bool |
Whether to hide the task dialog on submit. |
| ListOutputFeatures
|
bool |
Whether the features of output layers will be listed. Only applicable if
features are drawn on the web tier. If DrawResultsOnMapServer is true and a
result map server is available, the drawn features will not be listed under the
output layer. |
| MaxFileUploadSize |
int |
The maximum file upload size in MB for GPDataFile parameter support and for
uploading result information for asynchronous tasks. |
| NavigationPath |
string |
The path to the task as it would appear in a hierarchical data control buddied
to the task's TaskManager. |
| ShowFieldAttributes |
bool |
Whether the results of this task will have the field attributes. |
| ShowLegend
|
bool |
Whether the results of this task will have a legend. Legend is only available
if GroupResultsByTable is true. |
| TaskDefinition |
string |
The task in the geoprocessing resource that this control works with. |
| TaskResultsContainers |
BuddyControl Collection |
The controls in which results from this task are displayed.
|
| VirtualDirectory |
string |
The relative path to the virtual directory in which files can be written, such
as " /arcgisoutput" |