Crystal Report超出处理作业限制

时间:2016-12-19 00:55:31

标签: c# asp.net crystal-reports

protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        Response.Buffer = true;
        if (IsPostBack)
        {
            if (dllselection.SelectedValue == "3")
            {
                ReportDocument myDataReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                myDataReport.Load(Server.MapPath("OJT.rpt"));
                myDataReport.SetDatabaseLogon("intranet", "cpgintranet@2016", "192.168.2.5", "INTRANET");
                myDataReport.SetParameterValue("T-ID", TextBox1.Text);
                CrystalReportViewer1.ReportSource = myDataReport;
                CrystalReportViewer1.DataBind();

            }
            else if (dllselection.SelectedValue == "4")
            {
                ReportDocument myDataReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                myDataReport.Load(Server.MapPath("TEFF.rpt"));
                myDataReport.SetDatabaseLogon("intranet", "cpgintranet@2016", "192.168.2.5", "INTRANET");
                myDataReport.SetParameterValue("T-ID", TextBox1.Text);
                CrystalReportViewer1.ReportSource = myDataReport;
                CrystalReportViewer1.DataBind();


            }
        }
    }

 protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Clear();
        Response.Buffer = true;
if (dllselection.SelectedValue == "3")
            {
                ReportDocument myDataReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                myDataReport.Load(Server.MapPath("OJT.rpt"));
                myDataReport.SetDatabaseLogon("intranet", "abc@2016", "192.168.2.88", "INTRANET");
                myDataReport.SetParameterValue("T-ID", TextBox1.Text);
                CrystalReportViewer1.ReportSource = myDataReport;
                CrystalReportViewer1.DataBind();

            }
            else if (dllselection.SelectedValue == "4")
            {
                ReportDocument myDataReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                myDataReport.Load(Server.MapPath("TEFF.rpt"));
                myDataReport.SetDatabaseLogon("intranet", "abc@2016", "192.168.2.88", "INTRANET");
                myDataReport.SetParameterValue("T-ID", TextBox1.Text);
                CrystalReportViewer1.ReportSource = myDataReport;
                CrystalReportViewer1.DataBind();


            }
}

我收到错误:

  

系统配置的最大报告处理作业限制   管理员已经到达。“

在网上研究了这个话题后,我找到了一些解决方案,设置了注册表值,特别是HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Report Application Server\InprocServer\PrintJobLimit为“-1”,但这个解决方案不起作用,如果我在我的代码中添加了crystal report dispose和close函数,我生成的水晶报告将为空。 下面是我的aspx代码:

<asp:DropDownList ID="dllselection"  onchange="javascript:return dropdown(this);" runat="server" Style="border: groove" CssClass="form-control" AutoPostBack="true">
                    <asp:ListItem Text="On Job Training" Value="3"></asp:ListItem>
                    <asp:ListItem Text="Training Effectiveness Form" Value="4"></asp:ListItem>
                </asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="Generate" CssClass="btn btn-success" OnClick="Button1_Click" />
        <div id="dvReport">
            <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" ToolPanelView="None" EnableDatabaseLogonPrompt="False" PrintMode="Pdf" />
        </div>

1 个答案:

答案 0 :(得分:2)

是的,这是设计的。为.net框架提供的晶体运行时允许maximum number of prints。确保它不会发生的方法是在页面卸载事件中彻底清理。

首先,将ReportDocument(myDataReport)提升到后面页面中的私有字段。然后,您将能够处理该报告,然后将其设置为null:

protected void Page_UnLoad(object sender, EventArgs e)
{
    CrystalReportViewer1.Dispose();
    CrystalReportViewer1 = null;
    myDataReport.Close(); // I can't remember if this is part of the reportDucment class
    myDataReport.Dispose();
    myDataReport = null;
    GC.Collect(); // I forgot this line
}

修改添加了GC.Collect

如果转到%temp%(在您的情况下可能会有所不同),您可以告诉您有这个问题。报告的多个副本会在缓存的文件名后附加GUID,在开始之前将它们全部删除。每次运行上述清理时,这些文件都不会累积。