web progress wheel on valentina reports

Hi guys!

I would like to add a progress wheel when my user clicks on the “print report” button.
the button launches a typical valentina reports (output in pdf) and depending on the amount of data, it can take up to 20 seconds before report is displayed.
but I don’t know when stop the progress wheel…

this is my report launch code (in the action event of the button)…any hints?

ciro

  if TxtDataIni.Text.Len>0 and TxtDataFin.Text.Len>0 then
    Try
      // Open server project
      Dim projPath As FolderItem 
      if Statistiche.SpTipSta.ListIndex=0 then
        if DebugBuild then
          projPath = GetFolderItem( "e:\\xojo\\Statistiche1.vsp" )
        else
          projPath = GetFolderItem( "Statistiche1.vsp" )
        end if
      end if
      if Statistiche.SpTipSta.ListIndex=1 then
        // stampa buoni giornaliera
        if DebugBuild then
          projPath = GetFolderItem( "e:\\xojo\\Statistiche2.vsp" )
        else
          projPath = GetFolderItem( "Statistiche2.vsp" )
        end if
        // forzo la data finale = iniziale
        TxtDataFin.Text=TxtDataIni.text
        'TxtDataFin=TxtDataIni
      end if
      if Statistiche.SpTipSta.ListIndex=2 then
        // stampa buoni mensile
        if DebugBuild then
          projPath = GetFolderItem( "e:\\xojo\\Statistiche2.vsp" )
        else
          projPath = GetFolderItem( "Statistiche2.vsp" )
        end if
        // sistemo la data iniziale
        if TxtDataIni.Text.Mid(1,2)<>"01" then
          TxtDataIni.Text="01"+TxtDataIni.Text.Mid(3,8)
        end if
        // forzo la data finale = fine mese
        if TxtDataIni.Text.Mid(4,2)="01" or TxtDataIni.Text.Mid(4,2)="03" or TxtDataIni.Text.Mid(4,2)="05" or TxtDataIni.Text.Mid(4,2)="07" or TxtDataIni.Text.Mid(4,2)="08"or TxtDataIni.Text.Mid(4,2)="10"or TxtDataIni.Text.Mid(4,2)="12" then
          TxtDataFin.Text="31"+TxtDataIni.Text.Mid(3,8)
        end if
        if TxtDataIni.Text.Mid(4,2)="04"or TxtDataIni.Text.Mid(4,2)="06"or TxtDataIni.Text.Mid(4,2)="09"or TxtDataIni.Text.Mid(4,2)="11" then
          TxtDataFin.Text="30"+TxtDataIni.Text.Mid(3,8)
        end if
        if TxtDataIni.Text.Mid(4,2)="02" then
          TxtDataFin.Text="28"+TxtDataIni.Text.Mid(3,8)
          // verifichiamo se bisestile
          dim annobisestile as Integer = 2000
          While annobisestile < 2080
            annobisestile=annobisestile+4
            if TxtDataFin.Text.mid(7,4)=annobisestile.ToText then
              TxtDataFin.Text="29"+TxtDataIni.Text.Mid(3,8)
            end if
          Wend
        end if
      end if
      
      Dim proj As VProject = New VProject( projPath )
      proj.Open
      
      // Sistemiamo i filtri
      Dim annosco as string
      Dim tipscuini,scuini,claini,sezini,nomeini,fasciaini As String
      Dim tipscufin,scufin,clafin,sezfin,nomefin,fasciafin As String
      Dim tipcirdid As String
      Dim dieini,diefin as string
      Dim saldoini,saldofin as string
      
      // SISTEMIAMO L'ENCODING 
      annosco = DefineEncoding(Login_Page.SpAnnoSco.Text, Encodings.UTF8 )
      
      tipscuini = DefineEncoding(SpTipScuIni.Text.Trim, Encodings.UTF8 )
      scuini = DefineEncoding(SpScuIni.Text.Trim, Encodings.UTF8 )
      claini = DefineEncoding(SpClaIni.Text, Encodings.UTF8 )
      sezini = DefineEncoding(SpSezIni.Text, Encodings.UTF8 )
      nomeini = DefineEncoding(TxtAluIni.Text, Encodings.UTF8 )
      fasciaini = DefineEncoding(SpFasIni.Text, Encodings.UTF8 )
      saldoini =DefineEncoding(TxtSaldoIni.Text, Encodings.UTF8 )
      saldofin = DefineEncoding(TxtSaldoFin.Text, Encodings.UTF8 )
      
      tipscufin = DefineEncoding(SpTipScuFin.Text.Trim, Encodings.UTF8 )
      scufin = DefineEncoding(SpScuFin.Text.Trim, Encodings.UTF8 )
      clafin = DefineEncoding(SpClaFin.Text, Encodings.UTF8 )
      sezfin = DefineEncoding(SpSezFin.Text, Encodings.UTF8 )
      nomefin = DefineEncoding(TxtAluFin.Text, Encodings.UTF8 )
      fasciafin = DefineEncoding(SpFasFin.Text, Encodings.UTF8 )
      
      tipcirdid = DefineEncoding(SpCirDid.Text, Encodings.UTF8 )
      
      dieini = DefineEncoding(SpDieIni.Text, Encodings.UTF8 )
      diefin = DefineEncoding(SpDieFin.Text, Encodings.UTF8 )
      
      saldoini = DefineEncoding(TxtSaldoIni.Text, Encodings.UTF8 )
      saldofin = DefineEncoding(TxtSaldoFin.Text, Encodings.UTF8 )
      
      // Print report as PDF to RAM
      Dim datasource As String = "mssql://host = '"+FiveStars_Scuola.host.Replace( "\", "\\\" )+"', user = '"+FiveStars_Scuola.user+"', password = '"+FiveStars_Scuola.pass+"', dbname = '"+FiveStars_Scuola.dbnm+"'"
      'datasource = DefineEncoding( datasource, Encodings.UTF8 )
      
      Dim report As VReport 
      if Statistiche.SpTipSta.ListIndex=0 then
        report= proj.MakeNewReport( "Report_Statistiche1", datasource)
      end if
      if Statistiche.SpTipSta.ListIndex=1 then
        report= proj.MakeNewReport( "Report_Statistiche2", datasource)
      end if
      if Statistiche.SpTipSta.ListIndex=2 then
        report= proj.MakeNewReport( "Report_Statistiche3", datasource)
      end if
      'if Statistiche.SpTipSta.ListIndex=3 then
      'Dim report As VReport = proj.MakeNewReport( "Report_Statistiche4", datasource)
      'end if
      report.SetParameterValue( "Param1", annosco )
      
      if SpTipMov.Text = "Versamenti" then
        report.SetParameterValue( "Param2","CS" )
      end if
      if SpTipMov.Text = "Pasti" then
        report.SetParameterValue( "Param2","SS" )
      end if
      
      if Statistiche.SpTipo.Text="Tutti" then
        report.SetParameterValue( "Param3", "" )
      end if
      if Statistiche.SpTipo.Text="Studente" then
        report.SetParameterValue( "Param3", "S" )
      end if
      if Statistiche.SpTipo.Text="Insegnante" then
        report.SetParameterValue( "Param3", "I" )
      end if
      if Statistiche.SpTipo.Text="Collaboratore ATA" then
        report.SetParameterValue( "Param3", "C" )
      end if
      if Statistiche.SpTipo.Text="Altro" then
        report.SetParameterValue( "Param3", "A" )
      end if
      
      // FILTRI INIZIALI
      if SpTipScuIni.Text<>"Tutte" then
        report.SetParameterValue( "Param4", tipscuini )
      end if
      if SpScuIni.Text<>"Tutte" then
        report.SetParameterValue( "Param5", scuini )
      end if
      if SpClaIni.Text<>"Tutte" then
        report.SetParameterValue( "Param6", claini )
      end if
      if SpSezIni.Text<>"Tutte" then
        report.SetParameterValue( "Param7", sezini )
      end if
      if TxtAluIni.Text.Trim.Len>0 then
        report.SetParameterValue( "Param8", nomeini )
      end if
      if SpFasIni.Text<>"Tutte" then
        report.SetParameterValue( "Param9", fasciaini )
      end if
      
      // FILTRI FINALI
      if SpTipScuFin.Text<>"Tutte" then
        report.SetParameterValue( "Param10", tipscuini )
      end if
      if SpScuFin.Text<>"Tutte" then
        report.SetParameterValue( "Param11", scuini )
      end if
      if SpClaFin.Text<>"Tutte" then
        report.SetParameterValue( "Param12", claini )
      end if
      if SpSezFin.Text<>"Tutte" then
        report.SetParameterValue( "Param13", sezini )
      end if
      if TxtAluFin.Text.Trim.Len>0 then
        report.SetParameterValue( "Param14", nomeini )
      end if
      if SpFasFin.Text<>"Tutte" then
        report.SetParameterValue( "Param15", fasciafin )
      end if
      
      // range date
      report.SetParameterValue( "Param16", TxtDataIni.Text.Mid(7,4)+"-"+TxtDataIni.Text.Mid(4,2)+"-"+TxtDataIni.Text.Mid(1,2) )
      report.SetParameterValue( "Param17", TxtDataFin.Text.Mid(7,4)+"-"+TxtDataFin.Text.Mid(4,2)+"-"+TxtDataFin.Text.Mid(1,2) )
      
      if SpCirDid.Text<>"Tutti" then
        report.SetParameterValue( "Param18", tipcirdid )
      end if
      
      if SpDieIni.Text<>"Tutte" then
        report.SetParameterValue( "Param19", dieini )
      end if
      if SpDieFin.Text<>"Tutte" then
        report.SetParameterValue( "Param20", diefin )
      end if
      
      // range saldo
      report.SetParameterValue( "Param21", replace(saldoini,",","."))
      report.SetParameterValue( "Param22",replace(saldofin,",","."))
      
      // iscrizione
      if SpIscrizione.Text="Iscritti" then
        report.SetParameterValue( "Param23","I")
      end if
      if SpIscrizione.Text="Non Iscritti" then
        report.SetParameterValue( "Param23","N")
      end if
      if SpIscrizione.Text="Tutti" then
        report.SetParameterValue( "Param23","T")
      end if
      
      Dim data As String = report.PrintToBuffer( EVReportPrintType.kToPDF, 1 )
      
      // Prepare download
      mPDF = New WebFile
      mPDF.MimeType = "application/pdf"
      mPDF.FileName = "report.pdf"
      mPDF.ForceDownload = true
      mPDF.Data = data
      
      // Close project and connection
      proj.Close
      'conn.Close
      
      // Show PDF in browser
      ShowURL( mPDF.URL )
      
    Exception err As VException
      Dim errNumber As Integer = err.ErrorNumber
      Dim errString As String = err.Message
      msgbox(errString)
    End
  else
    MsgBox("Inserire Range Date!")
  end if

Your code is a bit long. Have you tried to hide the progress wheel before or after

ShowURL( mPDF.URL )

?

The progress wheel will never appear. Remember… web apps queue up all of the commands and send them to the browser when the event loop ends.

If you want to do this, you’ll need to use a WebThread to do the report processing so that your code shows the progress wheel and then starts the thread. When the run event finishes, hide the progress wheel.