Solved

How to monitor Crystal Report Load

Posted on 2009-03-30
5
512 Views
Last Modified: 2013-11-26
I am using vb.net and crystal reports 2008. I need to be able to monitor the progress of a report as it runs. Currently an end-user has not idea the progress of a report until it has completed. Any suggestions?  i have attached just a short sample of my code.

Thank you
Dim oRpt = New ReportDocument()

 oRpt.Load("c:\\QAReports\MDActivity_Stats.rpt") 
 

CrystalReportViewer1.ParameterFieldInfo = paramFields

CrystalReportViewer1.ReportSource = oRpt

CrystalReportViewer1.Visible = True

Open in new window

0
Comment
Question by:larrystewart
  • 2
  • 2
5 Comments
 
LVL 48

Expert Comment

by:jpaulino
Comment Utility
Hi larrystewart,

Don't know if you have an easy solution for that, but you could start a new form on a new thread, only with a progressbar with a marquee until the load process ends
0
 

Author Comment

by:larrystewart
Comment Utility
How do I know when a load process has completed?
0
 
LVL 48

Expert Comment

by:jpaulino
Comment Utility
But does it take soo many time to load ? Is it only the first report ?
0
 

Accepted Solution

by:
larrystewart earned 0 total points
Comment Utility
I guess I should explain myself further  by using two ways of opening the same report. 1)  If I open the report from the Crystal Report application. The report loads and Crystal shows you the number of records it has processed and how many it has Selected (on the bottom status bar). 2) If I load the same report from with in my vb.net app - the app does not show the report until it has completed reading the records from the database. I would like the user to see that the report is still reading data. Make sense?

Thank you
0
 

Expert Comment

by:camoh
Comment Utility
Here is some helpful information that I found on the SAP Community Network that helped me come up with a work around to show that it is still working on generating my report.

The info below is what I copied from https://forums.sdn.sap.com/thread.jspa?threadID=1112190

********  Start of copied info  *******The following sample code demonstrates how to retrieve the number of pages from your 'ReportDocument' object. Assuming that your 'ReportDocument object' is called 'crReport', use the following VB.NET code to return the number of pages in a report:
  ====================
 
 NOTE:
 
 Logon and parameter field values must be provided prior to executing this code.
 
 ====================
 
 Dim nPages as Integer
 
 nPages = crReport.FormatEngine.GetLastPageNumber(New CrystalDecisions.Shared.ReportPageRequestContext)

********  End of copied info  *******


Below is an example of my code in a vb.net application:

'****** Code for frmReportViewer Class (My Windows form that contains the CrystalReportViewer1 control)******
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class frmReportViewer
    Private WithEvents rs As New clsReportStatus
    Private Delegate Sub BarUpdate(ByVal val As Integer)
    Private Delegate Sub ChangeCursor(ByVal myCursor As Windows.Forms.Cursor)
    Private Delegate Sub ctrlVisible(ByVal meVisible As Boolean)

    Private Sub Report_ProgressBarValue(ByVal val As Integer) Handles rs.ProgressBarValue
        Try
            If Me.InvokeRequired Then
                Dim bu As New BarUpdate(AddressOf Me.Report_ProgressBarValue)
                Me.Invoke(bu, New Object() {val})
            Else
                ProgressBar1.Value = val
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub Report_ctrlVisible(ByVal meVisible As Boolean) Handles rs.ctrlVisible
        Try
            If Me.InvokeRequired Then
                Dim lv As New ctrlVisible(AddressOf Me.Report_ctrlVisible)
                Me.Invoke(lv, New Object() {meVisible})
            Else
                lblWait.Visible = meVisible
                ProgressBar1.Visible = meVisible
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub Report_mCursor(ByVal myCursor As Windows.Forms.Cursor) Handles rs.mCursor
        Try
            If Me.InvokeRequired Then
                Dim mc As New ChangeCursor(AddressOf Me.Report_mCursor)
                Me.Invoke(mc, New Object() {myCursor})
            Else
                Cursor = myCursor
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub frmReportViewer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            If Not rs.Running Then
                rs.StartThread()
            End If
            Application.DoEvents()

            Dim nPages As Integer

            Dim rep As New ReportDocument

            rep = Me.CrystalReportViewer1.ReportSource

            Me.Show()
            Application.DoEvents()
          'Here is where I inserted the line from the SAP Community Network forum            nPages = rep.FormatEngine.GetLastPageNumber(New CrystalDecisions.Shared.ReportPageRequestContext)
            rs.StopThread()
        Catch ex As Exception
            rs.StopThread()
            MessageBox.Show(ex.Message)
        End Try
    End Sub
End Class
 
 
 
 
'****** Code for clsReportStatus Class ******
Public Class clsReportStatus
    Public Event ProgressBarValue(ByVal val As Integer)
    Public Event ctrlVisible(ByVal v As Boolean)
    Public Event mCursor(ByVal myCursor As Windows.Forms.Cursor)
    Private t As System.Threading.Thread
    Private aborting As Boolean = True

    Public ReadOnly Property Running() As Boolean
        Get
            Return Not aborting
        End Get
    End Property

    Public Sub StartThread()
        If aborting Then
            aborting = False
            t = New System.Threading.Thread(AddressOf ReportStatus)
            t.Start()
        End If
    End Sub

    Public Sub StopThread()
        aborting = True
    End Sub

    Private Sub ReportStatus()
        Try
            Dim intPos As Integer = 0
            RaiseEvent mCursor(Cursors.WaitCursor)
            RaiseEvent ProgressBarValue(intPos)
            RaiseEvent ctrlVisible(True)

            Do Until Not Me.Running
                'Do Until intPos = 100
                RaiseEvent ProgressBarValue(intPos)
                System.Threading.Thread.Sleep(300)
                If intPos < 100 Then
                    intPos = intPos + 1
                Else
                    intPos = 1
                End If
                Application.DoEvents()
            Loop

            RaiseEvent ProgressBarValue(100)
            System.Threading.Thread.Sleep(1000)
            RaiseEvent ctrlVisible(False)
            RaiseEvent mCursor(Cursors.Default)

        Catch ex As Exception
            RaiseEvent mCursor(Cursors.Default)
            MessageBox.Show(ex.Message)
            RaiseEvent ctrlVisible(False)
            Me.StopThread()
        End Try
    End Sub
End Class


0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now