Report Generation Status

pinbotpinbot Texas
edited 4:45AM in FastReport .NET


I have a web form that generates a report on the fly. Sometimes the report can be 2000 pages so it can take a little while.

I fire up a background thread to actually create the report. I use a semaphor to let the foreground thread know when the report is completed.

With an asp:timer control I update the web page every 2 seconds to let the user know the report is still being generated. When it is done, I change the status message to a link to the newly created and pdf exported report.


And everything works great.

Is there a way to get the number of pages already completed while the report is being "prepared"?

I'd like the status message to be something like "Your report is being generated. xxx pages so far completed." until the report is done.

Thanks,
Bryan

Comments

  • edited 4:45AM
    Hello,

    You may use progress events:
    ...
          Config.ReportSettings.StartProgress += new EventHandler(ReportSettings_StartProgress);
          Config.ReportSettings.Progress += new ProgressEventHandler(ReportSettings_Progress);
          Config.ReportSettings.FinishProgress += new EventHandler(ReportSettings_FinishProgress);
    ...
    
        private void ReportSettings_StartProgress(object sender, EventArgs e)
        {
        }
    
        private void ReportSettings_Progress(object sender, ProgressEventArgs e)
        {
          // e.Progress is the number of pages prepared
        }
    
        private void ReportSettings_FinishProgress(object sender, EventArgs e)
        {
        }
    
  • pinbotpinbot Texas
    edited 4:45AM

    What is the scope of "Config"?

    I'm using this outside of the report scripting.



    In my ASP.Net web page Page_Load I use:


    FastReport.Utils.Config.WebMode = true;
    FastReport.Report Rpt = new FastReport.Report();
    Rpt.Load(this.Page.Server.MapPath("../App_Data/PropSheets.Frx"));

    if (Session["QuerySQL"]!=null)
    { sql=Session["QuerySQL"].ToString();
    FastReport.Data.TableDataSource tds = (FastReport.Data.TableDataSource) Rpt.GetDataSource("Query1");
    tds.SelectCommand = sql;
    }
    Rpt.Prepare();
  • edited 4:45AM
    It's FastReport.Utils.Config.
  • pinbotpinbot Texas
    edited 4:45AM

    Thanks. I should have seen my "FastReports.Utils.Config.Webmode"....

    I have this in my thread.


    FastReport.Utils.Config.WebMode = true;
    FastReport.Utils.Config.ReportSettings.Progress += new ProgressEventHandler(ReportSettings_Progress);

    And

    private void ReportSettings_Progress(object sender, ProgressEventArgs e)
    {
    Debug.WriteLine("Progress: " + e.Progress.ToString());
    }


    And it does not seem to get called.

    Do I need to do anything else?
  • pinbotpinbot Texas
    edited 4:45AM

    hmm.

    I even tried:

    FastReport.Utils.Config.ReportSettings.Progress += new ProgressEventHandler(this.ReportSettings_Progress);

    To point to the local instance of my event handler.

    Does my event handler have to be in the FastReports namespace?
  • edited 4:45AM
    You may also need to set Config.ReportSettings.ShowProgress = true. The following code works well in my asp.net app:
                Report report = new Report();
                Config.ReportSettings.ShowProgress = true;
                Config.ReportSettings.StartProgress += new EventHandler(ReportSettings_StartProgress);
                Config.ReportSettings.Progress += new ProgressEventHandler(ReportSettings_Progress);
                Config.ReportSettings.FinishProgress += new EventHandler(ReportSettings_FinishProgress);
                report.Load(...);
                report.Prepare();
    
            private void ReportSettings_StartProgress(object sender, EventArgs e)
            {
            }
    
            private void ReportSettings_Progress(object sender, ProgressEventArgs e)
            {
                // if I set breakpoint here it is called.
            }
    
            private void ReportSettings_FinishProgress(object sender, EventArgs e)
            {
            }
    
  • pinbotpinbot Texas
    edited 4:45AM

    That was it.

    Thanks!

    I noticed that when printing the report, the progress event is called twice for each page.

    I've attached a picture of the progress page. Looks much nicer showing how many pages have been generated. This report can be anywhere from 1 page to 2500 depending on the search criteria.



  • Alex_de_KockAlex_de_Kock Bloemfontein, Free State, South Africa
    edited 4:45AM
    Hallo AlexTZ

    Do you know if this will work in FastReports 4.0??

    I have been looking all over to find someway to insert a progress bar in my reports, but with no success.

    I am really no programming expert, so any help whatsoever would be great!

    Thank you

    Alex

    AlexTZ wrote: »
    You may also need to set Config.ReportSettings.ShowProgress = true. The following code works well in my asp.net app:
                Report report = new Report();
                Config.ReportSettings.ShowProgress = true;
                Config.ReportSettings.StartProgress += new EventHandler(ReportSettings_StartProgress);
                Config.ReportSettings.Progress += new ProgressEventHandler(ReportSettings_Progress);
                Config.ReportSettings.FinishProgress += new EventHandler(ReportSettings_FinishProgress);
                report.Load(...);
                report.Prepare();
    
            private void ReportSettings_StartProgress(object sender, EventArgs e)
            {
            }
    
            private void ReportSettings_Progress(object sender, ProgressEventArgs e)
            {
                // if I set breakpoint here it is called.
            }
    
            private void ReportSettings_FinishProgress(object sender, EventArgs e)
            {
            }
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.