|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionThe purpose of this article is to show how to get progress notifications of current web service progress. This will be achieved by using AJAX enabled web page, async call to web service and some easy CSS trick to display progress bar. Also this article show how to manage state of web service. First look at web service code. To manage state of a web service we use class named ProgressValues and Cache object. Values are stored in Cache with unique ID. public class ProgressValues { public bool AbortPressed = false; public int step = 0; public int value = 0; } ProgressValues pw = new ProgressValues(); Context.Cache[UID] = pw; Second. Web page have AJAX Timer which is disabled by default and start tick when user press start button and also have AJAX UpdatePanel to display progress bar, controls and GridView without full page postbacks. Third. When user click "Start Process" buton we made async execution of a web service and pass values of IAsyncResult to Session object by following lines of code: MyService.Test ts = new MyService.Test(); IAsyncResult my_ar; // AsyncResult for async execution of service my_ar = ts.BeginGo(UID, steps, values, null, null); // Start async execution of web service Session["my_ar"] = my_ar; // Remember AsyncResult in Session for later use Fourth. When tick event occur we get IAsyncResult from Session and update controls with following lines of code: IAsyncResult my_ar = (IAsyncResult)Session["my_ar"]; // Get IAsyncResult from Session pw = ts.GetProcessValues(Session["WebServiceUID"].ToString()); // Get ProgressValues from web service if (my_ar.IsCompleted) // Async execution of service done Using the codeFirst of all - you need Microsoft AJAX installed on you web server. Second you need to compile/deploy/start "TestService" project into your web server, then add Web References to "Test project" with name "MyService". If you make this then Proxy class for you servce will be exists and you can use this proxy class in "Test" project.
|
||||||||||||||||||||||