52
Building and Extending Tasks for ArcGIS Server Building and Extending Tasks for ArcGIS Server .NET Web Applications .NET Web Applications Rex Hansen, Sentha Sivabalan Rex Hansen, Sentha Sivabalan ESRI Developer Summit 2008 ESRI Developer Summit 2008 1

Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Building and Extending Tasks for ArcGIS Server Building and Extending Tasks for ArcGIS Server .NET Web Applications.NET Web Applications

Rex Hansen, Sentha SivabalanRex Hansen, Sentha Sivabalan,,

ESRI Developer Summit 2008ESRI Developer Summit 2008 11

Page 2: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Schedule

• 75 minute session60 65 minute lecture– 60 – 65 minute lecture

– 10 – 15 minutes Q & A following the lecture

• Cell phones and pagersp p g

• Please complete the session survey – we take your feedback very seriously!

Page 3: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Introductions

• Who are we?ArcGIS Server NET Developers– ArcGIS Server .NET Developers

• Who are you?y– Experience With ASP.NET?– Experience With AJAX?– New Web ADF Developers?– Current Web ADF Developers?

Page 4: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Session agendaSession agenda

•• ASP.NET Developer ReviewASP.NET Developer Review•• Web ADF Task Framework OverviewWeb ADF Task Framework Overview•• Web ADF Task Framework OverviewWeb ADF Task Framework Overview•• Working with Task Framework controlsWorking with Task Framework controls•• Extending Web ADF TasksExtending Web ADF Tasks•• Extending Web ADF TasksExtending Web ADF Tasks•• Creating custom Web TasksCreating custom Web Tasks•• New 9 3 features (where applicable)New 9 3 features (where applicable)•• New 9.3 features (where applicable)New 9.3 features (where applicable)•• Best practicesBest practices

ESRI Developer Summit 2008ESRI Developer Summit 2008 44

Page 5: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Web Application Development takes many formsWeb Application Development takes many forms

•• Server Side developmentServer Side developmentTraditional ASP NET/JSF/Cold FusionTraditional ASP NET/JSF/Cold Fusion–– Traditional ASP.NET/JSF/Cold FusionTraditional ASP.NET/JSF/Cold Fusion

–– Some JavaScript, most logic is on the web or server tierSome JavaScript, most logic is on the web or server tier–– At 9.2, the ADF was mostly server developmentAt 9.2, the ADF was mostly server development

•• Client Side developmentClient Side development–– All things happen on client All things happen on client -- JavaScriptJavaScript

O l t lk t i th h HTTP/G t/P t/P tO l t lk t i th h HTTP/G t/P t/P t–– Only talk to services through HTTP/Get/Post/PutOnly talk to services through HTTP/Get/Post/Put–– Limited platform/environmentLimited platform/environment

•• HybridHybridHybridHybrid–– A well balanced combination of client and server logicA well balanced combination of client and server logic

–– At 9.3, Web ADF “is” a Hybrid development platformAt 9.3, Web ADF “is” a Hybrid development platform

9.3 Tech Transfer Sessions9.3 Tech Transfer Sessions 55

Page 6: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

What does it take to become an ADF Developer?What does it take to become an ADF Developer?-- Web Development 101Web Development 101 ---- Web Development 101 Web Development 101 --

•• Must be familiar with Web DevelopmentMust be familiar with Web DevelopmentS ASP NETS ASP NET–– Server: ASP.NETServer: ASP.NET•• C# OR VB.NETC# OR VB.NET

Client: ASP NET AJAXClient: ASP NET AJAX––Client: ASP.NET AJAXClient: ASP.NET AJAX•• JavaScriptJavaScript•• Partial Post backsPartial Post backs•• Application ServicesApplication Services

––HTML/CSSHTML/CSS

•• Have Familiarity with IISHave Familiarity with IIS––Performance, Scalability, ASP.NET Worker ProcessPerformance, Scalability, ASP.NET Worker Process

9.3 Tech Transfer Sessions9.3 Tech Transfer Sessions 66

Page 7: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

ASP.NET Page and Server Control DevelopersASP.NET Page and Server Control Developers

•• Add functionality to a page/User control or package in Add functionality to a page/User control or package in control librarycontrol libraryyy

•• Handle user actions, process input and generate resultsHandle user actions, process input and generate results•• Page development easier, but less flexiblePage development easier, but less flexibleg p ,g p ,

Page DeveloperPage DeveloperServer Control Server Control

DeveloperDeveloper

Out-of-the-box Web Controls

Extend Web Controls

Page\Web Control Events

DeveloperDeveloper

Custom Actions\Events User Controls

Composite Web Controls

ESRI Developer Summit 2008ESRI Developer Summit 2008 77

Page 8: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Web Application Developer FrameworkWeb Application Developer FrameworkWeb Application Developer FrameworkWeb Application Developer Framework

Web ControlsWeb Controls

Web ServerWeb Server

Web BrowserWeb BrowserTasksTasks

Web Controls

Web Server

Web BrowserTasks

Web ADF JavaScript

Library

Web ADF JavaScript

Library

Web ADF JavaScript

Library

Web ADF JavaScript

Library

Web ControlsWeb ControlsWeb BrowserWeb Browser

TaskFramework

TaskFramework

Web ADF JavaScript

Library

Web ADF JavaScript

Library

Web ControlsWeb Browser

TaskFramework

ADF Core classesADF Core classes

Common Data Source APICommon Data Source API \ S\ S ics

ics

ADF Core classes

Common Data Source API \ S ics

Arc

GIS

Serv

er

Arc

GIS

Serv

er

Arc

IMS

Arc

IMS

Arc

Web

Arc

Web

OG

C\

WM

SO

GC

\W

MS

Gra

ph

Gra

ph

Arc

GIS

Serv

er

Arc

IMS

Arc

Web

OG

C\

WM

S

Gra

ph

ArcGISSArcGISS

ArcIMSArcIMS ArcWebArcWeb OGC\WMSOGC\WMS

Data SourcesData SourcesArcGISS

ArcIMS ArcWeb OGC\WMS

Data Sources

9.3 Tech Transfer Sessions9.3 Tech Transfer Sessions9.3 Tech Transfer Sessions9.3 Tech Transfer Sessions 8888

ServerServer WMSWMSServer WMS

Page 9: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Web Tasks

• Visual components designed to perform a set of related actions and generate resultsactions and generate results

• Encapsulate a workflow• Encapsulate a workflow– UI for gathering input– Perform some action based on inputsp– Generate results

Page 10: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Web ADF Tasks in the boxWeb ADF Tasks in the box

•• Search Search –– Search Attributes of a layerSearch Attributes of a layer

•• Find AddressFind Address–– Use locator services to perform geocoding tasksUse locator services to perform geocoding tasks

•• Find PlaceFind PlaceG tt h i A W bG tt h i A W b–– Gazetteer search using ArcWeb Gazetteer search using ArcWeb

•• QueryQuery–– Perform queries against layer attributesPerform queries against layer attributes

•• GeoprocessingGeoprocessing•• GeoprocessingGeoprocessing–– Gather inputs for published Geoprocessing tools and models and execute Gather inputs for published Geoprocessing tools and models and execute

using this taskusing this task•• EditorEditor

–– Web Web based geodatabase editing (versioned and nonbased geodatabase editing (versioned and non--versioned edits are versioned edits are allowed)allowed)

•• PrintPrintSi l i ti th t id b i ti f th b li tiSi l i ti th t id b i ti f th b li ti•• Simple printing that provides web printing for the web applicationSimple printing that provides web printing for the web application

9.3 Tech Transfer Sessions9.3 Tech Transfer Sessions 1010

Page 11: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

The ADF Task Framework

• Utilized by out-of-the-box ADF Tasks• Extensible Framework provides for:

– Organization of tasks– Feedback when a task is executing– Management of resultsManagement of results

• Display • Visualization on Map• Delete Refresh Re run• Delete, Refresh, Re-run

– Distribution and configuration oftasks in Visual Studio and Manager

CustomTask

Page 12: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

TaskManager control

• Convenient, not required• Organizes tasks in a Web application• Organizes tasks in a Web application• Generates hierarchical XML at run time

– XML can be bound to ASP NET menu or tree viewXML can be bound to ASP.NET menu or tree view– BuddyControl property controls binding

Run timeDesign time

XML + System.Web.UI.WebControls.Menu

Page 13: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

TaskResults control

• Displays results of tasksADO NET dataset

Design time– ADO.NET dataset

• Run time– Results presented as p

nodes in tree view– Context menu for zoom

or pan to a feature Run timeor pan to a feature, highlight a feature in a result set, or remove task results

Run time

task results

Page 14: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Working with Working with TaskResultsTaskResults

•• Use to display results, with or without a custom taskUse to display results, with or without a custom task•• Provides access to Map instanceProvides access to Map instance•• Provides access to Map instanceProvides access to Map instance•• Setup results as nested nodes for display and useSetup results as nested nodes for display and use•• MethodsMethods•• MethodsMethods

–– CreateTaskResultsNodeCreateTaskResultsNode–– CreateDataTableNodeCreateDataTableNode create nodes

–– CreateAndAddDataRowNodesCreateAndAddDataRowNodes–– SetupTaskResultNodeSetupTaskResultNode

S t C t tMS t C t tMconfigure nodes

–– SetupContextMenuSetupContextMenu

ESRI Developer Summit 2008ESRI Developer Summit 2008 1414

Page 15: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Display results in Display results in TaskResultsTaskResults

•• Call Call DisplayResultsDisplayResults() method to display results in a the () method to display results in a the TaskResultsTaskResults control or Mapcontrol or MapTaskResultsTaskResults control or Mapcontrol or Map–– Three supported result types:Three supported result types:

•• SimpleTaskResultSimpleTaskResultpp–– header and bodyheader and body

•• DataSetDataSet–– Each Each DataTableDataTable added as a node. If added as a node. If DataTableDataTable is is GraphicsLayerGraphicsLayer, ,

rendered in Map.rendered in Map.

•• TaskResultNodeTaskResultNode–– Used to package diverse result typesUsed to package diverse result types

ESRI Developer Summit 2008ESRI Developer Summit 2008 1515

Page 16: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Using Using TaskResultNodeTaskResultNode

•• MapResourceNodeMapResourceNodeCreate node from a map resource definition add to mapCreate node from a map resource definition add to map–– Create node from a map resource definition, add to mapCreate node from a map resource definition, add to map

•• GraphicsLayerNodeGraphicsLayerNode–– Create node from Web ADF Create node from Web ADF GraphicsLayerGraphicsLayer, add to map, add to mapp yp y , p, p

•• FeatureNodeFeatureNode–– Create node from a Create node from a DataRowDataRow with Web ADF geometrywith Web ADF geometry

•• ContextMenusContextMenus–– Preconfigured for node type and contentPreconfigured for node type and content–– Accessible via Accessible via TaskResultsTaskResults propertiesproperties

•• e.g.e.g. GraphicsLayerContextMenuGraphicsLayerContextMenu

ESRI Developer Summit 2008ESRI Developer Summit 2008 1616

e.g. e.g. GraphicsLayerContextMenuGraphicsLayerContextMenu

Page 17: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

How to leverage the Task FrameworkHow to leverage the Task Framework

•• Different Skill levels can take advantage of the Different Skill levels can take advantage of the Task Frame ork in different a sTask Frame ork in different a sTask Framework in different waysTask Framework in different ways––Add results directly to the Add results directly to the TaskResultsTaskResults container container

C t U C t lC t U C t l––Create a User ControlCreate a User Control––Develop a custom Task to distribute and integrate Develop a custom Task to distribute and integrate

withwith ArcGISArcGIS Server ManagerServer Managerwith with ArcGISArcGIS Server ManagerServer Manager––Extend existing Task to modify behaviorExtend existing Task to modify behavior

9.3 Tech Transfer Sessions9.3 Tech Transfer Sessions 1717

Page 18: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Page and Control Development in the ADFPage and Control Development in the ADF

•• Page developers Page developers –– Display results or create User Control tasksDisplay results or create User Control tasks•• Server Control developers Server Control developers –– Create custom redistributable tasksCreate custom redistributable tasks

Page DeveloperPage Developer Server ControlServer ControlD lD l

Out-of-the-box Web Controls

Extend Web Controls

Page\Web Control Events

Page DeveloperPage Developer DeveloperDeveloper

Extend ADF Web Tasks

Custom Actions\Events User Controls Composite Web

ControlsCustom Tools

and CommandsCreate Custom

Web TasksUser Control

Tasks

ESRI Developer Summit 2008ESRI Developer Summit 2008 1818

Page 19: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Demo Custom Tool Demo Custom Tool -- TaskResultsTaskResults

ESRI Developer Summit 2008ESRI Developer Summit 2008 1919

Page 20: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

User Control TasksUser Control Tasks

•• Easiest way to create a taskEasiest way to create a taskDD dd d t t UId t t UI––DragDrag--andand--drop to create UIdrop to create UI

––Add code for behaviorAdd code for behavior

T b l d t th C d G ll fi tT b l d t th C d G ll fi t•• To be released to the Code Gallery firstTo be released to the Code Gallery first

ESRI Developer Summit 2008ESRI Developer Summit 2008 2020

Page 21: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

User Control Task ImplementationUser Control Task Implementation

•• Create user controlCreate user control•• Inherit from Inherit from UserControlTaskPanelUserControlTaskPanel

––Implement Implement ExecuteTaskExecuteTask

•• Use input parameterUse input parameter•• Return result as outputReturn result as outputReturn result as outputReturn result as output

––Call Call StartStart on execute button clickon execute button click

•• In your web applicationIn your web application•• In your web applicationIn your web application––Add a Add a UserControlTaskUserControlTask to your to your TaskManagerTaskManager

Add your user control task panel to your applicationAdd your user control task panel to your application

ESRI Developer Summit 2008ESRI Developer Summit 2008 2121

––Add your user control task panel to your applicationAdd your user control task panel to your application––Point Point UserControlTaskUserControlTask to your panelto your panel

Page 22: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

User Control DemoUser Control Demo

ESRI Developer Summit 2008ESRI Developer Summit 2008 2222

Page 23: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

When to create a User Control TaskWhen to create a User Control Task

Advantages:Advantages:E t t d W b M i A li tiE t t d W b M i A li ti––Easy way to extend your Web Mapping ApplicationEasy way to extend your Web Mapping Application

Disadvantages:Disadvantages:––Not easy to distributeNot easy to distribute––Requires IDE configurationRequires IDE configuration––Not configurable in ManagerNot configurable in Manager

Use to create a taskUse to create a task––For use in one web applicationFor use in one web application––For sharing with developers who can do simple For sharing with developers who can do simple

fi ti i Vi l St di NETfi ti i Vi l St di NET

ESRI Developer Summit 2008ESRI Developer Summit 2008 2323

configuration in Visual Studio .NETconfiguration in Visual Studio .NET

Page 24: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

When you need to create a custom Web Task?When you need to create a custom Web Task?

When you need to:When you need to:C t di t ib t bl UI tC t di t ib t bl UI t•• Create a distributable UI componentCreate a distributable UI component

•• Integrate into ManagerIntegrate into Manager

ESRI Developer Summit 2008ESRI Developer Summit 2008 2424

Page 25: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Custom Web Task ImplementationCustom Web Task Implementation

•• You are creating a custom Web control!You are creating a custom Web control!–– Extend Extend FloatingPanelTaskFloatingPanelTask abstract base abstract base classclass–– Implements Implements ITaskITask which defines Web Task contractwhich defines Web Task contract

CustomTaskCustomTask

ICallbackEventHandlerICallbackEventHandlerESRI.ArcGIS.ADF.Web.UI.WebControls ESRI.ArcGIS.ADF.Web.UI.WebControls

FloatingPanelTaskFloatingPanelTask

ICallbackEventHandlerICallbackEventHandlerIBuddyControlSupportIBuddyControlSupportITaskITask

ASP.NET Web ControlsASP.NET Web Controls

Page 26: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Key methods and propertiesKey methods and properties

MethodsMethods•• CreateChildControlsCreateChildControls t th i l i t ft th i l i t f•• CreateChildControlsCreateChildControls –– create the visual interfacecreate the visual interface

•• GetCallbackResultGetCallbackResult –– parse input, return callback resultsparse input, return callback results

•• ExecuteTaskExecuteTask execute the task and generate resultsexecute the task and generate results•• ExecuteTaskExecuteTask –– execute the task and generate resultsexecute the task and generate results

PropertiesPropertiesPropertiesProperties•• InputInput –– store input data from the userstore input data from the user

•• ResultsResults –– after task execution generate results for use in aafter task execution generate results for use in aResultsResults after task execution, generate results for use in a after task execution, generate results for use in a TaskResultsTaskResults controlcontrol

•• CallbackResultsCallbackResults –– collection of results designed to update collection of results designed to update browser content using Web ADF JavaScriptbrowser content using Web ADF JavaScript

Page 27: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Custom Task Classes in this SessionCustom Task Classes in this Session

IT kIT kRequiredRequired OptionalOptional

Visual Studiointegration class

ITaskITask

TaskTask

CustomTaskCustomTaskDesignerDesignerTaskDesignerTaskDesigner

FloatingFloatingPanelTaskPanelTask

IWebConfiguratorIWebConfigurator

CustomTaskCustomTaskWebConfiguratorWebConfigurator

Managerintegration

Web control

CustomCustomTaskResultsTaskResults

ITaskResultsContainerITaskResultsContainer

WebConfiguratorWebConfigurator

CustomTaskCustomTask

Web control

TaskResultsTaskResultsTaskResultsTaskResults

Custom TaskWeb control

Page 28: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Design Task Runtime Interface for user inputDesign Task Runtime Interface for user input

•• Override Override CreateChildControlsCreateChildControlsCreate content user will interact with in the browserCreate content user will interact with in the browser–– Create content user will interact with in the browserCreate content user will interact with in the browser

–– Called on every Called on every postbackpostback\\callback during Page Load callback during Page Load DevTask.cs

[System.Web.UI.ToolboxData("<{0}:DevTask runat=\"server\" > </{0}:DevTask>")]

public class DevTask: ESRI.ArcGIS.ADF.Web.UI.WebControls.FloatingPanelTask

{

i b b l llprivate System.Web.UI.WebControls.TextBox textBox = null;

protected override void CreateChildControls()

{

base.CreateChildControls();

textBox = new System.Web.UI.WebControls.TextBox();

textBox.ID = "textBox";

C t l Add(t tB )Controls.Add(textBox);

Page 29: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Utilize ADF JavaScript to execute task Utilize ADF JavaScript to execute task

•• Task and FloatingPanelTask include Web ADF Task and FloatingPanelTask include Web ADF JavaScript to support task executionJavaScript to support task executionJavaScript to support task executionJavaScript to support task execution

•• Manage events in browser to execute taskManage events in browser to execute taskdi l t k j

i i i

DevTask.cs

display_task.js

function executeTask(...

function startActivityIndicator{...

protected override void CreateChildControls()

{

. . .

string getArgumentJS = string.Format("'textBoxValue=' +

function startJob{...

document.getElementById('{0}').value", textBox.ClientID);

string onClick = string.Format("executeTask({0},\"{1}\");",

getArgumentJS, CallbackFunctionString);

b tt Att ib t Add(" li k" Cli k)button.Attributes.Add("onclick", onClick);

}

Page 30: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Processing user inputProcessing user input

•• Override Override GetCallbackResultGetCallbackResultEvent arguments packaged inEvent arguments packaged in callbackArgcallbackArg variablevariable–– Event arguments packaged in _Event arguments packaged in _callbackArgcallbackArg variablevariable

–– Call to Call to GetCallbackResultGetCallbackResult in base class in base class executes task and executes task and returns returns CallbackResultsCallbackResults

•• InputInput property stores user inputproperty stores user input–– Storage format determined by developerStorage format determined by developer

public override string GetCallbackResult()

{

DevTask.cs

System.Collections.Specialized.NameValueCollection keyValColl =

CallbackUtility.ParseStringIntoNameValueCollection(_callbackArg);

Input = keyValColl["textBoxValue"];

return base GetCallbackResult();return base.GetCallbackResult();

}

Page 31: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Generating ResultsGenerating Results

•• Override Override ExecuteTaskExecuteTask methodmethod•• ResultsResults property stores content to be displayed in a property stores content to be displayed in a

TaskResultsTaskResults controlcontrol–– SimpleTaskResultSimpleTaskResult

D t tD t t–– DatasetDataset–– TaskResultNodeTaskResultNode

DevTask cs

public override void ExecuteTask()

{

string textBoxValue = Input as string;

DevTask.cs

g p g;

ESRI.ArcGIS.ADF.Web.UI.WebControls.SimpleTaskResult simpleresult =

new ESRI.ArcGIS.ADF.Web.UI.WebControls.SimpleTaskResult(heading, detail);

Results = simpleresult;

Page 32: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Executing the TaskExecuting the Task

•• Input parameter Input parameter EventArgEventArg equals “equals “executeTaskexecuteTask””•• FloatingPanelTask GetCallbackResultFloatingPanelTask GetCallbackResult methodmethod callscalls•• FloatingPanelTask.GetCallbackResultFloatingPanelTask.GetCallbackResult method method calls calls

ExecuteTaskExecuteTaskbli id t i G tC llb kR lt()

FloatingPanelTask.cs

DevTask cs public override string GetCallbackResult()

{

. . .

string eventArg = keyValColl["EventArg"];

GetCallbackResult()

base.GetCallbackResult

DevTask.cs

. . .

else if (eventArg == "executeTask")

{

ExecuteTask();

ExecuteTask()

ExecuteTask();

DisplayResults(taskJobID, Input, Results);

}

return CallbackResults.ToString();

}

Page 33: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Working with CallbackResultsWorking with CallbackResults

•• Upon task execution, callback response string is Upon task execution, callback response string is returned from custom taskreturned from custom task GetCallbackResultGetCallbackResult methodmethodreturned from custom task returned from custom task GetCallbackResultGetCallbackResult methodmethod

•• CallbackResultsCallbackResults are callback messages formatted to be are callback messages formatted to be processed by Web ADF JavaScriptprocessed by Web ADF JavaScriptp y pp y p

•• All Web ADF controls maintain a All Web ADF controls maintain a CallbackResultsCallbackResultscollection collection

P h W b ADF t l d t llb kP h W b ADF t l d t llb k

public override void ExecuteTask()

DevTask.cs

Push Web ADF control and custom callbackPush Web ADF control and custom callbackresults into task callback resultsresults into task callback results

{

map.CenterAt(MyPoint);

CallbackResults.CopyFrom(map.CallbackResults);

}}

Page 34: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Simple Task DemoSimple Task Demo

ESRI Developer Summit 2008ESRI Developer Summit 2008 3434

Page 35: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Visual Studio IntegrationVisual Studio Integration

•• Expose custom propertiesExpose custom properties•• ExtendExtend TaskDesignerTaskDesigner to manage smartto manage smart tagstags

CustomTask

•• Extend Extend TaskDesignerTaskDesigner to manage smart to manage smart tagstags•• Create a custom Create a custom WinFormWinForm dialog for developer inputdialog for developer input

Follow standard technique for integrating ASP.NET Follow standard technique for integrating ASP.NET Web controls in Visual Studio Web controls in Visual Studio

Page 36: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Define Define task task properties as attributesproperties as attributes

•• Set properties at designSet properties at design--time, change runtime behaviortime, change runtime behaviorDevTask.cs

public string ButtonText

{

get

{{

object o = StateManager.GetProperty("buttonText");

return (o == null) ? "Execute Task" : o as string;

}

set

{

StateManager.SetProperty("buttonText", value);

}}

}

MyPage.aspx (design-time)

<devTask:DevTask ID="DevTask1" runat="server" ButtonText="Custom Text">

</devTask:DevTask>

Page 37: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Extend TaskDesignerExtend TaskDesigner

•• Access to visual interface (e.g. Access to visual interface (e.g. WinFormWinForm) ) for modifying for modifying task properties at designtask properties at design--timetimetask properties at designtask properties at design--timetime

[System.ComponentModel.Designer(typeof(DevTaskDesigner))]

DevTask.cs

public class DevTask: ESRI.ArcGIS.ADF.Web.UI.WebControls.FloatingPanelTask

{

D T kD i

public class DevTaskDesigner : TaskDesigner

{

public DevTaskDesigner()

DevTaskDesigner.cs

p g ()

: base()

{

verbs.Add(new DesignerVerb("Edit the button text",

new EventHandler(OnEditButtonText)));

}

Page 38: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Visual Studio Integration DemoVisual Studio Integration Demo

ESRI Developer Summit 2008ESRI Developer Summit 2008 3838

Page 39: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Manager IntegrationManager IntegrationCustom

•• Create a custom Web control to beCreate a custom Web control to berendered at runtime inrendered at runtime in ManagerManager

Task

rendered at runtime in rendered at runtime in ManagerManager•• Implement Implement IWebConfiguratorIWebConfigurator interfaceinterface

–– Provides UI to configure task in ManagerProvides UI to configure task in Managerg gg g–– Generates markup for configured task Generates markup for configured task

Page 40: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Design Web control to modify custom task Design Web control to modify custom task

•• To configure a task in Manager requires a custom Web To configure a task in Manager requires a custom Web controlcontrolcontrolcontrol

public class DevTaskWebConfigurator:

DevTaskWebConfigurator.cs

public class DevTaskWebConfigurator: ESRI.ArcGIS.ADF.Web.UI.WebControls.CompositeControl

{

private System.Web.UI.WebControls.Button okButton;

protected override void CreateChildControls()

{

okButton = new System.Web.UI.WebControls.Button();

okButton.Click += new EventHandler(okButton_Click);

Page 41: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

IWebConfigurator implementation IWebConfigurator implementation

•• PropertiesProperties–– ControlToConfigureControlToConfigure: returns an instance of the Task: returns an instance of the TaskControlToConfigureControlToConfigure: returns an instance of the Task: returns an instance of the Task–– AdditionalControlsAdditionalControls: returns other controls in same Page as the : returns other controls in same Page as the

TaskTask–– ValidateResourcesValidateResources: determine if a required resource is available: determine if a required resource is available

•• MethodsMethodsGetGISResourceItemDependenciesGetGISResourceItemDependencies –– reset task if dependentreset task if dependent–– GetGISResourceItemDependenciesGetGISResourceItemDependencies –– reset task if dependent reset task if dependent resource is removedresource is removed

•• Event Event HandlersHandlers–– WebConfigurationCompleteEventHandlerWebConfigurationCompleteEventHandler: : write markup to pagewrite markup to page

Page 42: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Configure custom task propertiesConfigure custom task properties

•• ControlToConfigureControlToConfigure returns an instance of the custom returns an instance of the custom tasktasktasktask

•• Handle Handle OnWebConfigurationCompleteOnWebConfigurationComplete eventeventDevTaskWebConfigurator.cs

public class DevTaskWebConfigurator: ESRI.ArcGIS.ADF.Web.UI.WebControls.IWebConfigurator

{i

DevTaskWebConfigurator.cs

private DevTask TaskInstance = null;

private void okButton_Click(object sender, EventArgs e)

{

TaskInstance.ButtonText = buttonText.Text;

OnWebConfigurationComplete(new WebConfigurationCompleteEventArgs(TaskInstance, getDesignTimeTag()));

Page 43: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Resource validation in ManagerResource validation in Manager

•• Implement Implement ValidateResourcesValidateResources to determine if a valid to determine if a valid resource is availableresource is available

public bool ValidateResources(out string message)

{

DevTaskWebConfigurator.cs

ArrayList mrms = new ArrayList();

Utility.FindControls(typeof(MapResourceManager),AdditionalControls, ref mrms);

•• Implement Implement GetGISResourceItemDependenciesGetGISResourceItemDependencies to reset to reset task when dependent resource is removedtask when dependent resource is removed

DevTask cs

public override List<GISResourceItemDependency> GetGISResourceItemDependencies()

{

List<GISResourceItemDependency> list = new List<GISResourceItemDependency>();

DevTask.cs

list.Add(new GISResourceItemDependency(typeof(MapResourceItem), mritem,

typeof(MapResourceManager), mrmanager));

Page 44: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Generating Web Mapping Application outputGenerating Web Mapping Application output

•• Create output string of declarative content for the Web Create output string of declarative content for the Web Mapping ApplicationMapping ApplicationMapping ApplicationMapping Application

private string getDesignTimeTag()

DevTaskWebConfigurator.cs

{

string openTag = string.Format("<devTask:DevTask ID=\"{0}\" runat=\"server\", TaskInstance.ID);

StringBuilder trcTag = new StringBuilder();

trcTag.Append("<TaskResultsContainers>");

trcTag.Append("<esri:BuddyControl Name=\"TaskResults1\" />");

d(" / k l i ")trcTag.Append("</TaskResultsContainers>");

string endTag = "</devTask:DevTask>";

. . .

return alltags.ToString();

Page 45: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Register with custom task and ManagerRegister with custom task and Manager

•• Add attribute to custom taskAdd attribute to custom task

[WebConfigurator(typeof(DevTaskWebConfigurator))]

public class DevTask: ESRI.ArcGIS.ADF.Web.UI.WebControls.FloatingPanelTask

{

DevTask.cs

•• Modify Tasks xmlModify Tasks xml

{

•• Modify Tasks.xmlModify Tasks.xml–– Located in <Located in <ArcGISArcGIS Instance>Instance>\\ManagerManager\\App_DataApp_Data

Tasks xml

<Task Name="DevTask" DisplayName="DevSummit Task" Type="DevTaskProject.DevTask, DevTaskProject, Version=1.1.0.0,

Culture=neutral, PublicKeyToken=a284737434b9d17c" TagP efi "de Task" />

Tasks.xml

TagPrefix="devTask" />

Page 46: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Manager Integration DemoManager Integration Demo

ESRI Developer Summit 2008ESRI Developer Summit 2008 4646

Page 47: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Extending Out of the box TasksExtending Out of the box Tasks

•• All out of the box Tasks are extensibleAll out of the box Tasks are extensible•• Change input processing and result contentChange input processing and result content•• Change input processing and result contentChange input processing and result content

–– Graphics results renderingGraphics results rendering–– Custom Custom ContextMenusContextMenus–– Node click behaviorNode click behavior–– Custom callback results (e.g. zoom to results)Custom callback results (e.g. zoom to results)

•• Need to understand the key public methods and Need to understand the key public methods and properties in a custom Taskproperties in a custom Task

ESRI Developer Summit 2008ESRI Developer Summit 2008 4747

Page 48: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Extending DemoExtending Demo

ESRI Developer Summit 2008ESRI Developer Summit 2008 4848

Page 49: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

Best Practices

• Start with Task or FloatingPanelTask base classesAlready provides some implementation code– Already provides some implementation code

• Prepare for Callback and Partial Postback patterns– IsAsyncy

• Define a standard and unique tag prefix– Arbitrary tag prefix may conflict with other custom tasks

• Embed resources - images, JavaScript• Sign and register (GAC) when integrating with Manager

Page 50: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

What’s New in 9.3What’s New in 9.3

•• Web Mapping Template using ASP.NET AJAX partial Web Mapping Template using ASP.NET AJAX partial postbackpostback pattern (watch forpattern (watch for IsCallbackIsCallback))postbackpostback pattern (watch for pattern (watch for IsCallbackIsCallback))

•• Hover over results in Hover over results in TaskResultsTaskResults control, highlight control, highlight feature in mapfeature in mappp

•• Easier to declare Web Tasks which do not require Web Easier to declare Web Tasks which do not require Web configuration (e.g. “default markup”)configuration (e.g. “default markup”)

•• 9.3 final will include an interface9.3 final will include an interface\\abstract class to create abstract class to create a User control Web task a User control Web task

ESRI Developer Summit 2008ESRI Developer Summit 2008 5050

Page 51: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

SummarySummary

•• Web ADF Task Framework provides consistent Web ADF Task Framework provides consistent architecture for processing user input and generatingarchitecture for processing user input and generatingarchitecture for processing user input and generating architecture for processing user input and generating resultsresults

•• Application requirements determine the extent to which Application requirements determine the extent to which pp qpp qthe task framework is utilizedthe task framework is utilized

•• Page developers Page developers –– use the task framework to display use the task framework to display resultsresults

•• Control developers Control developers –– use the task framework to use the task framework to l t UI d ti l i i di t ib t bll t UI d ti l i i di t ib t blencapsulate UI and execution logic in a distributable encapsulate UI and execution logic in a distributable

component component –– Add functionality to Manager generated applicationsAdd functionality to Manager generated applications

ESRI Developer Summit 2008ESRI Developer Summit 2008 5151

Add functionality to Manager generated applications Add functionality to Manager generated applications

Page 52: Building and Extending Tasks for ArcGIS Server .NET Web ... · Building and Extending Tasks for ArcGIS Server .NET Web Applications Rex Hansen, Sentha Sivabalan ... • C# OR VB.NET

In Conclusion…In Conclusion…

•• All sessions are recorded and will be available on EDNAll sessions are recorded and will be available on EDNSlides and code will also be availableSlides and code will also be available–– Slides and code will also be availableSlides and code will also be available

•• Please fill out session surveys!Please fill out session surveys!Please fill out session surveys!Please fill out session surveys!

•• Still have questions?Still have questions?Still have questions?Still have questions?1.1.Tech talk, Demo Theatres, Meet the TeamTech talk, Demo Theatres, Meet the Team2.2.“Ask a Developer” link on web page“Ask a Developer” link on web page

•• www.esri.com/devsummit/techquestionswww.esri.com/devsummit/techquestions

ESRI Developer Summit 2008ESRI Developer Summit 2008 5252