This is a migrated thread and some comments may be shown as answers.

Get report generation start and end time

6 Answers 329 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Soumya
Top achievements
Rank 1
Soumya asked on 08 Apr 2014, 06:03 PM
Hi,

I create reports using standalone report designer. Reports are run on reportviewer in an asp.net webform. Is there anyway to capture report generation start and end time? Also is there anyway to capture timeout message and customize it?

6 Answers, 1 is accepted

Sort by
0
Soumya
Top achievements
Rank 1
answered on 10 Apr 2014, 06:19 AM
Hi,

In addition to my previous query, is there anyway to get value that user has selected for a parameter when a parameter's value is changed in the reportviewer? How can value of global object ExecutionTime be obtained in code behind each time a report is run?
0
Stef
Telerik team
answered on 11 Apr 2014, 02:43 PM
Hello Soumya,

Currently the ASP.NET ReportViewer does not expose such events as start and end of the report generation. You can use the Client-Side API to see when the get methods return result, which will indicate the time the report is loaded.

About getting the running values of report parameters, they can be obtained from the processing equivalent of the report in events as illustrated in the Using Report Events article. To use events, you will need to deserialize the TRDX file and attach to events.

I hope this helps you.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Soumya
Top achievements
Rank 1
answered on 11 Apr 2014, 03:22 PM
Hello Stef,

Thank you for your reply.
I found a way to capture report parameter everytime Preview button is clicked. There are few multivalued parameters for which values are obtained from a datasource in the report. I could not find a way to capture value selected from a multivalued parameter. 
Following is the code where I am trying to capture values of parameter when report is run.
protected void report_ItemDataBound(object sender, EventArgs e)
    {
        start_time = DateTime.Now; //report processing start time
        Telerik.Reporting.Processing.Report rpt = (Telerik.Reporting.Processing.Report)sender;
        var obj = rpt.Parameters;
        
        string s = "";//list of parameters in the running report
        int cnt = 0;
        foreach (var v in obj)
        {
            cnt += 1;
            if (v.Value.AvailableValues == null)
                s += "&" + v.Key + "=" + v.Value.Value;
            if (v.Value.AvailableValues != null)
            {
                s += "&" + v.Key + "=" + v.Value.Value; 
                for (int i = 0; i < v.Value.AvailableValues.Count; i++)
                    s += "&" + v.Key + "[" + i + "]=" + v.Value.Value;
            }
        }
        s = s.Substring(1);
        end_time = DateTime.Now; //report processing end time

        addReportAudit(ID, start_time, end_time, s); //creating audit of report that is run
    }

Following is a sample value of variable 's' 
offset=0&role=Semnox Admin&user=Semnox&loggedInUserId=43&isCorporate=Y&functionId=1008&site=System.Object[]

'site' is a multivalued parameter. When I debug, statement v.Value.Value shows value Object{3} of type Object{string}. But variable 's' has value System.Object[] for the same. Could you please tell me how I could get proper value for the parameter?


0
Nasko
Telerik team
answered on 16 Apr 2014, 12:28 PM
Hello Soumya,

The multivalue parameter selected values are stored in an objects array. If the parameter can have multiple values you need to iterate through the objects array and then append the values of the array's elemets to your string s. We can suggest using the String.Join method for this purpose.

Regards,
Nasko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Soumya
Top achievements
Rank 1
answered on 24 Apr 2014, 09:42 AM
Hello Nasko,

Thank you. It helped. Currently code is as follows.
public void report_ItemDataBound(object sender, EventArgs e)
    {
        start_time = DateTime.Now;
        Telerik.Reporting.Processing.Report rpt = (Telerik.Reporting.Processing.Report)sender;
        var obj = rpt.Parameters;

        string s = "";//list of parameters in the running report
        int cnt = 0;
        foreach (var v in obj)
        {
            cnt += 1;
            if (v.Value.AvailableValues == null)
                s += "&" + v.Key + "=" + v.Value.Value;
            if (v.Value.AvailableValues != null) //If value of parameter is from a datasource in the report
            {
                if (!v.Value.Multivalue)
                    s += "&" + v.Key + "=" + v.Value.Value;
                else //get selected value of multivalue parameter
                {
                    object values = v.Value.Value;
                    if (values == null)
                        values = String.Empty;
                    else
                    {
                        string[] newarr = Array.ConvertAll((object[])values, element => (string)element);
                        s += "&" + v.Key + "=" + string.Join(",", newarr);
                    }
                }
            }
        }
        s = s.Substring(1);
        end_time = DateTime.Now;

        addReportAudit(report_id, start_time, end_time, s, ParafaitCommon.getUserName()); 
    }

I have another query. I would like to capture any error that would occur when generating report. Say value passed for parameter is invalid or report processing has timed out or any other error that might occur. Is there anyway I could capture these error messages and display a message of my own?
0
Stef
Telerik team
answered on 28 Apr 2014, 04:18 PM
Hello Soumya,

Instead of using events, you can use a user function to perform the current custom logic. This user function can be set as an item's Value. User functions can accept directly the report parameters values. For example

TextBox.Value: = ProjectNamespace.CheckValue(Fields.Item,Parameters.Parameter1.Value)
-----------------
 public static object CheckValue(object value, object param)
        {
            //do something with param
            return value;
        }

About handling errors in the report during its processing, you can use the Report.Error event and catch the exception, stop the further processing of the report and throw custom exception.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Soumya
Top achievements
Rank 1
Answers by
Soumya
Top achievements
Rank 1
Stef
Telerik team
Nasko
Telerik team
Share this question
or