[CLOSED] Progress bar

  1. #1

    [CLOSED] Progress bar

    I wrote a Coolite desktop application to print out student cards. When our users decides to print out an entire list of cards at once, I would like to display a progress bar showing which card is being printed. I receive a boolean from my DAL stating if the card is printed correctly or not. When the case is true, I would like the progress bar to continue printing the next item. How can I achieve this?
  2. #2

    RE: [CLOSED] Progress bar

    Hi,

    Does the following example is what you required?
    https://examples1.ext.net/#/Miscella...r_side_update/
  3. #3

    RE: [CLOSED] Progress bar

    Sort of, but I don't understand the code with the longaction and task manager. The problem is I call 2 ajax methods, 1 to print the current selection in the grid and 1 to print the complete list accordingly to the button that's pressed.

    Function to print complete list
    This function passes all the cards to my data provider which returns a boolean if all rows where inserted successfully. What I would like to do now, is show a progress bar and insert the cards one by one, updating the progress bar if this was successful.
    ...
    oCards = clsDataProvider.GetCards(sDirection, oFilters, oQuickSearch, sSort, sView)
    
    bBatchCardsPrinted = clsDataProvider.InsertDummyCards(oCards, sView)
    ...
    Function to print current selection
    This function submits the data in my grid to print the current selection. In my submit data function I use the same function as above (bBatchCardsPrinted = clsDataProvider.InsertDummyCards(oCards, sView).
    Me.oToolbarButtonBatchPrintCards.AddScript("{0}.submitData(false);", Me.oGridPanelCards.ClientID)

    What I would like to do is show the progress bar when one of the two functions is called, pass the according oCards array list to the update progress function. Can you help me with this?
  4. #4

    RE: [CLOSED] Progress bar

    What I forgot to mention: The progress bar needs to be displayed in a message box.
  5. #5

    RE: [CLOSED] Progress bar

    Hi,

    I am not sure that I clear understood your business requirements. Let me explain how to update progress bar during long server side action

    1. Start long action. You shoud start task in ThreadPool. It allows to finish current request. TaskManager will poll the server to retrieve current status

    2. Show MessageBox with porogress bar

    3. Start task of TaskManager to poll server with current status. You should save the status (for example, in the Session) to allow TaskManager handler to retrieve it

    4. When task is ready you should hide the MessageBox


    Please see the following example

    <%@ Page Language="C#" %>
    <%@ Import Namespace="System.Threading"%>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>    
        
        <script runat="server">
            protected void StartLongAction(object sender, AjaxEventArgs e)
            {
                this.Session["LongActionProgress"] = 0;
                ThreadPool.QueueUserWorkItem(LongAction);
                Ext.Msg.Show(new MessageBox.Config
                                 {
                                    Title = "Please wait...",
                                    ProgressText = "Step 0 of 10...",
                                    Progress = true,
                                    Width = 250
                                 });
                TaskManager1.StartTask("longactionprogress");
            }
    
            private void LongAction(object state)
            {
                for (int i = 0; i < 10; i++)
                {
                    Thread.Sleep(1000);
                    this.Session["LongActionProgress"] = i+1;
                }
                this.Session.Remove("LongActionProgress");
            }
    
            protected void RefreshProgress(object sender, AjaxEventArgs e)
            {
                object progress = this.Session["LongActionProgress"];
                if(progress != null)
                {
                    Ext.Msg.UpdateProgress(((int)progress) / 10f, string.Format("Step {0} of {1}...", progress.ToString(), 10));
                }
                else
                {
                    TaskManager1.StopTask("longactionprogress");
                    Ext.Msg.Hide();
                }
            }
    
        </script>
        
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <ext:Button ID="ShowProgress1" runat="server" Text="Start long action">
                <AjaxEvents>
                    <Click OnEvent="StartLongAction"></Click>
                </AjaxEvents>
            </ext:Button>
            
            <br />
            
            <ext:TaskManager ID="TaskManager1" runat="server">
                <Tasks>
                    <ext:Task 
                        TaskID="longactionprogress"
                        Interval="1000" 
                        AutoRun="false"
                        OnStart="
                            #{ShowProgress1}.setDisabled(true);"
                        OnStop="
                            #{ShowProgress1}.setDisabled(false);">
                        <AjaxEvents>
                            <Update OnEvent="RefreshProgress" />
                        </AjaxEvents>                    
                    </ext:Task>
                </Tasks>
            </ext:TaskManager>
      
        </form>
    </body>
    </html>
  6. #6

    RE: [CLOSED] Progress bar

    Where exactly should I place the function that inserts the card? And what does the for loop do?
  7. #7

    RE: [CLOSED] Progress bar

    Hi,

    You should place it inside method which you pass to the QueueUserWorkItem (in my example it is LongAction method).
    In my example for loop using to emulate long action only

Similar Threads

  1. [CLOSED] Progress bar Issue
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 27, 2010, 11:35 AM
  2. [CLOSED] Progress bar
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 11, 2010, 3:01 PM
  3. [CLOSED] progress bar
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 09, 2009, 8:53 AM
  4. Progress Bar
    By fabiomarcos in forum 1.x Help
    Replies: 1
    Last Post: Jan 27, 2009, 12:18 PM
  5. Progress bar
    By flaviodamaia in forum 1.x Help
    Replies: 1
    Last Post: Sep 11, 2008, 12:31 PM

Posting Permissions