?
Solved

Rendering timeout when calling report through C# code

Posted on 2007-09-30
3
Medium Priority
?
7,659 Views
Last Modified: 2013-11-26
The timeout on our SQL 2005 Reporting Services is set to 1800 seconds.  When I call the report through code by making an instance of the reporting service on my web page, it times out after like 45 seconds.

The code being used to render the report is:
    protected void BtnProcessOnDemand_Click(object sender, EventArgs e)
    {
        this.LblError.Visible = false;
        this.LblError.Text = "";
        //initialize variables
        String SITEID = "%";
        String DIVID = "%";
        String BENGROUPID = "%";
        DateTime PREMDATE = System.DateTime.Now;
        if (TxtRptPremDate.Text.Length > 0)
        {
            PREMDATE = Convert.ToDateTime(TxtRptPremDate.Text.ToString());
        }
        else
        {
            LblError.Text = "Please input a premium date.";
            LblError.Visible = true;
            return;
        }

        if (DdlSite.SelectedIndex != 0)
        {
            SITEID = DdlSite.SelectedValue;
            if (DdlDivision.SelectedIndex != 0)
            {
                DIVID = DdlDivision.SelectedValue;
                if (DdlBenGroup.SelectedIndex != 0)
                {
                    BENGROUPID = DdlBenGroup.SelectedValue;
                }
            }
        }

        //if (((Button)sender).CommandName.ToString() != LblHidden.Text)
        //{
            String error = "";
            ReportExecutionService RE = new ReportExecutionService();
            RE.Credentials = new System.Net.NetworkCredential("Username", "Password", "Domain");

            RE.Url = "http://report.ntlbenefit.com/reportserver/reportexecution2005.asmx?wsdl";

            // Render arguments
            DataSet pathdir = SC.get_path();

            DataSet report = SC.get_reportinfo(DdlReportsOD.SelectedValue.ToString());
            byte[] result = null;
            string reportPath = "/" + pathdir.Tables[0].Rows[0]["path_folder"].ToString() + "/" + report.Tables[0].Rows[0]["rpt_link"].ToString();
            string format = DdlFormat.SelectedValue.ToString();
            string historyID = null;
            string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
            // Prepare report parameter.
            ParameterValue[] parameters = new ParameterValue[5];
            parameters[0] = new ParameterValue();
            parameters[0].Name = "SITEID";
            parameters[0].Value = SITEID;
            parameters[1] = new ParameterValue();
            parameters[1].Name = "DIVID";
            parameters[1].Value = DIVID;
            parameters[2] = new ParameterValue();
            parameters[2].Name = "BENGROUPID";
            parameters[2].Value = BENGROUPID;
            parameters[3] = new ParameterValue();
            parameters[3].Name = "PREMDATE";
            parameters[3].Value = PREMDATE.ToString();
            parameters[4] = new ParameterValue();
            parameters[4].Name = "ADMINID";
            parameters[4].Value = Session["AdminID"].ToString();
            //LblError.Text = reportPath;
            //LblError.Visible = true;
            //return;
            DataSourceCredentials[] credentials = null;
            string showHideToggle = null;
            string encoding;
            string mimeType;
            string extension;
            string actualextension;
            actualextension = DdlFormat.SelectedValue.ToString();
            Warning[] warnings = null;
            ParameterValue[] reportHistoryParameters = null;
            string[] streamIDs = null;

            ExecutionInfo execInfo = new ExecutionInfo();
            ExecutionHeader execHeader = new ExecutionHeader();

            RE.ExecutionHeaderValue = execHeader;
            try
            {
                execInfo = RE.LoadReport(reportPath, historyID);
            }
            catch (Exception eload)
            {
                this.LblError.Text = "The requested report is not available, please check back soon.";
                this.LblError.Visible = true;
                return;
            }
            RE.SetExecutionParameters(parameters, "en-us");
            String SessionId = RE.ExecutionHeaderValue.ExecutionID;

            try
            {
                result = RE.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
            }
            catch (SoapException soape)
            {
                error = soape.ToString() + "</ br>";
            }
            // Write the contents of the report to an MHTML file.
       
           
            try
            {
                String guid = Guid.NewGuid().ToString();
                FileStream stream = File.Create(Server.MapPath("~/Temp/" + guid + "." + actualextension), result.Length);
                stream.Write(result, 0, result.Length);
                stream.Close();
                LblHidden.Text = report.Tables[0].Rows[0]["rpt_link"].ToString();
                //this.PnlConfirm.Visible = true;
                LblDisplay.Text = "<iframe width='100%' src='" + "../Temp/" + guid + "." + actualextension + "' height='1200px'></iframe>";
            }
            catch (Exception ex)
            {
                error = ex.ToString() + "</ br>";
            }

            if (error.Length > 0)
            {
                this.LblError.Text = error.ToString();
                this.LblError.Visible = true;
            }
        //}
    }

When developing a sql statement in my webservice I can set how long it takes to time out the connection.  Is there a similar function when rendering from a page.  Some of these reports take 10 to 15 minutes to generate.  

Any help would be greatly appreciated.
0
Comment
Question by:NBAIS
3 Comments
 
LVL 14

Accepted Solution

by:
shahprabal earned 2000 total points
ID: 19994396
can think of couple of suggestions:
-make sure the timeout value is in seconds and not milliseconds
-make sure the sql statement is not timing out...
0
 

Author Comment

by:NBAIS
ID: 19994414
That's what I'm asking, how do you set the timeout with the rendering method?
0
 

Expert Comment

by:weezyuncw
ID: 21315050
ReportExecutionService rs = new ReportExecutionService();
rs.Timeout = System.Threading.Timeout.Infinite;
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

850 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