ArcGIS Server task message process and custom task

Source: Internet
Author: User

1. First, you must understand the task message transmission process ()

1. After the client triggers a task event, the executetask () method is executed. This method calls another startjob () method and assigns each jobid to it, used to track this asynchronous request.

2. The startjob () method will provide a series of parameters to Microsoft's webform_docallback () method. Finally, the webform_docallback () method is used for asynchronous requests, and the parameter _ callbackarg is used to pass in the callback of Microsoft's asynchronous requests.

In the main raisecallbackevent. In this way, the parameter is passed to the callback method of the server.

3. The server callback method calls the getcallbackreasult () method during processing. This method will be based on different parameters passed in, perform different processing (for example, if the input parameter is "eventarg = shown", the display page is displayed)

4. If the input parameter of getcallbackreasult () is (eventarg = starttaskactivityindicator), The executetask () method is executed. This method is the main method of the task to process the main business logic. The result processed by this method is results. After the method is executed, the displayreasults () method is called and the result is returned through processcallbackreasutl ().

 

 

Ii. Custom tasks

The class of the custom task must inherit the floatingpaneltask class, and write the createchildcontrols (), executetask (), and getcallbackreasut () Methods of the parent class.

1. The createchildcontrols () method is executed during Task instantiation. This method mainly defines the interface of the task. You can customize some controls through controls. the add () method adds controls to tasks.

Must have an event that can trigger executetask (for example, The onclick event of the button can be:

String. Format ("executetask ({0}, \" {1} \ ");", getagrstring, this. callbackfunctionstring)
Here, getagrstring is the input parameter)

2. The getcallbackreasut () method is executed after the executetask () method is triggered by the client. You can use this. callbackeventargument obtains the parameters passed by the client, and puts the parameters related to logical processing in this. input.

3. The executetask () method is the core of the task. After the getcallbackreasut () method is executed, the parameter processing result can be obtained from this. Input and saved in this. reasults.

 

Iii. Examples of custom tasks,

(Get the actual server and the string injected into the task text box)

Right-click solution> Add project> class library (name changed to mytask)

 

Usingsystem;

Usingsystem. Collections. Generic;

Usingsystem. LINQ;

Usingsystem. text;

Usingsystem. Web. UI. webcontrols;

Usingsystem. Collections. Specialized;

Using ESRI. ArcGIS. ADF. Web. UI. webcontrols;

Usingsystem. Web. UI. htmlcontrols;

 

Namespacemytask

{

Public class mytask: ESRI. ArcGIS. ADF. Web. UI. webcontrols. floatingpaneltask

{

Private textbox TXT = NULL;

Private htmlinputbutton BTN = NULL;

Protected override voidcreatechildcontrols ()

{

Controls. Clear ();

Base. createchildcontrols ();

TXT = new Textbox ();

TXT. ID = "txt1 ";

BTN = new htmlinputbutton ();

BTN. ID = "btn1 ";

BTN. value = "OK ";

Controls. Add (txt); // add textbox to task

Controls. Add (BTN); // Add the buttont to the task

String getagrstring = string. Format ("'txtboxvalue = '+ document. getelementbyid (' {0} '). Value", TXT. clientid); // use the textbox value as a parameter

String onclickcc = string. format ("executetask ({0}, \" {1} \ ");", getagrstring, this. callbackfunctionstring); // defines executetask and Passes parameters to it

BTN. Attributes. Add ("onclick", onclickcc); // registers the method for the button. This method can execute the executetask method.

}

 

 

/// <Summary>

///
Obtain the parameters and perform different processing based on different parameters.

/// </Summary>

/// <Returns> </returns>

Public override stringgetcallbackresult ()

{

Namevaluecollection namecolltion = callbackutility. parsestringintonamevaluecollection (this. callbackeventargument );

This. Input = namecolltion ["txtboxvalue"]; // obtain the textbox value.

Return base. getcallbackresult ();

}

 

Public override void executetask ()

{

This. Results = NULL;

String txtvalue = This. Input. tostring ();

String heading = string. Format ("the time on the server is {0}", datetime. Now. tow.datestring ());

String detail = string. Format ("the value in the textbox is: {0}", txtvalue );

Simpletaskresult STR = newsimpletaskresult (heading, detail );

This. Results = STR; // Save the processing result to reasus.

}

 

Public overridelist <ESRI. ArcGIS. ADF. Web. UI. webcontrols. gisresourceitemdependency> getgisresourceitemdependencies ()

{

List <ESRI. ArcGIS. ADF. Web. UI. webcontrols. gisresourceitemdependency> List = newlist <ESRI. ArcGIS. ADF. Web. UI. webcontrols. gisresourceitemdependency> ();

Return list;

}

}

}

 

Press F6 to compile the toolbox.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.