Welcome Guest Search | Active Topics | Sign In | Register

ProgressBar and Response Options
Guybrush
Posted: Wednesday, January 28, 2009 3:01:46 AM
Rank: Newbie
Groups: Member

Joined: 1/28/2009
Posts: 2
Hello users,

I have one problem with the EO Progressbar. Generally the Progressbar works fine. I create an Excelfile on the serverside and the user (client) can after that download or save the file with a popup window based on the response command. The file creation works fine with the progressbar. But the popup window would not be shown. Is the response command the problem? Sorry for my english :-)

Here the code:

Code: Visual Basic.NET
Private Sub ProgressBar1_RunTask( _
ByVal sender As Object, ByVal e As EO.Web.ProgressTaskEventArgs) _
Handles ProgressBar1.RunTask

        Dim xlsapp As New myExcel()
        xlsapp.Workbookadd(Server.MapPath("\Verkauf\Konzessionaere\Excel\Konzessionaere_tmp.xls"))
        xlsapp.SelectWB(1)

        e.UpdateProgress(10)

        Dim i As Integer = 4 
        Dim db As New myDB("INFRA")
        Dim RD_Kon As SqlDataReader = db.ExecuteReader("SELECT * FROM Konz ORDER BY Land, Ort, Such")
        e.UpdateProgress(20)

        While RD_Kon.Read()
            xlsapp.value(2, i, RD_Kon("Knd").ToString) 'Kunde
            xlsapp.value(3, i, RD_Kon("Such").ToString) 'Suchbegriff
            xlsapp.value(4, i, RD_Kon("Bez").ToString) 'Firma
            xlsapp.value(5, i, RD_Kon("Bez2").ToString) 'BEZ1
            xlsapp.value(6, i, RD_Kon("Bez3").ToString) 'BEZ1
            xlsapp.value(7, i, RD_Kon("Internet").ToString) 'Internetadresse
            xlsapp.value(8, i, RD_Kon("Strasse").ToString) 'Strasse
            xlsapp.value(10, i, RD_Kon("Ort").ToString) 'Ort
            xlsapp.value(11, i, RD_Kon("Land").ToString) 'Ort
            xlsapp.value(12, i, RD_Kon("Tel").ToString) 'Telefon
            xlsapp.value(13, i, RD_Kon("Fax").ToString) 'Fax
            xlsapp.value(14, i, RD_Kon("EMail").ToString) 'E-Mail
        End While
        db.Close()

        e.UpdateProgress(30)
        xlsapp.value(2, i + 4, "Stand per " & Date.Now.ToString) 'Ort
        e.UpdateProgress(40)

        Dim File As String = Server.MapPath("\Verkauf\Konzessionaere\Excel\TMP\Konzessionaere_" & Date.Now.Date.Day & "." & Date.Now.Date.Month & "." & Date.Now.Date.Year & ".xls")

        e.UpdateProgress(50)

        xlsapp.Save(File)
        e.UpdateProgress(60)
        xlsapp.Close()
        e.UpdateProgress(100)

        System.Threading.Thread.Sleep(50)
        Dim Datei As New System.IO.FileInfo(File)
        If Datei.Exists Then
            Response.Clear()
            Response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}", Datei.Name))
            Response.AddHeader("Content-Length", Datei.Length.ToString())
            Response.ContentType = "application/octet-stream"
            Response.WriteFile(Datei.FullName)
            Response.End()
        Else
            Dim box As New myMsgBox(Page)
            box.alert("Datei nicht gefunden!")
        End If
    End Sub


can everyone help me? Think
eo_support
Posted: Wednesday, January 28, 2009 7:23:34 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,089
Hi,

RunTask is a very special event. You can not change anything else in the page except for updating the ProgressBar status. In order to perform any additional action, you will need to use the second argument of UpdateProgress. Please see this demo for details on how to perform additional action (such as display a message box):

http://demo.essentialobjects.com/Default.aspx?path=ProgressBar\_i2

Thanks!
Guybrush
Posted: Wednesday, January 28, 2009 11:08:02 AM
Rank: Newbie
Groups: Member

Joined: 1/28/2009
Posts: 2
Hello,

Many thanks for your answer. I don't understand the demo. how I must use the second argument? I find only a additional string parameter. Can I call a function there? Can you give me an example how I can resolve the problem with the response command (excel download)? This would be great Angel
eo_support
Posted: Wednesday, January 28, 2009 11:27:15 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,089
Hi,

UpdateProgress takes two parameters. The first parameter is a number. This parameter is used by the progress bar. You use this parameter to tell the progress bar where the progress indicator should move to.

The second parameter is a string. This parameter is for you to use. The progress bar does not use this parameter in any way (that's why this parameter is optional).

In order to use the second parameter, you will need to know JavaScript. The flow is like this:

1. You pass a value through the second parameter. Since the progress bar does not use this parameter, you would pass whatever makes sense to you. For example, you can pass "Hello!" to the second parameter;

2. UpdateProgress takes "Hello" and pass it to the client side for you. It will then call your ClientSideOnValueChanged handler (you will need to open the sample project source code to see this). This is a JavaScript handler you would provide (again, check the sample source code for the correct syntax). Once you provide this handler, the progress bar would call your handler every time the indicator moves (that is, every time UpdateProgress is called on the server side);

3. Inside your ClientSideOnValueChanged handler (note now you are on client side with JavaScript), you will be able to retrieve the value you passed down from the server through UpdateProgress. You can use then this value whatever way you want;

Our sample uses the second parameter to pass an additional status string to the client and then use JavaScript to display this to the client (You will see it displays “Running” after you click the Start link).

The point is, you can only do two things inside RunTask: 1. Update the progress indicator; 2. Pass an additional value to the client side for your JavaScript to use. So you will be passing this value in your server side code (C# or VB.NET), and use this value in your client side code (JavaScript). Passing what value and how to use that value would be entirely up to you.

You may also want to go through this page if you are not already familiar with our client side JavaScript interface:

http://doc.essentialobjects.com/ViewDoc.aspx?book=1&t=clientapi_howto.html

Hope this helps.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.