日期:2014-05-20  浏览次数:21558 次

水晶报表:无法将请求提交给后台处理
错误提示如下:文件C:\WINDOWS\TEMP\SaleQuoteModulPush{92EAE361-71E6-4EBF-B97F...}.rpt内出错:无法将请求提交给后台处理

但有时刷新后可以正常显示,有时不能。。。目前发现只有有图片的水晶报表才报这类错误。。
我水晶报表后台代码:
C# code
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;

public partial class RptCenter_CrystalReport_OrderUtitityPushRpt : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string orderNo=Request.QueryString["OrderNo"];
        DataSet ds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "rpt_SaleQuoteModul", new SqlParameter("@OrderNo", orderNo));
        
        DataSet FillDetaSet = this.defineDataSet();       
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            addrow(ds, FillDetaSet, i);          
          
        }
        fillRpt(FillDetaSet);
    }

    private DataSet defineDataSet()
    {
        //定义填充DataSet与SaleQuoteModulRpt.xsd呼应
        DataSet FillDetaSet = new DataSet();
        FillDetaSet.Tables.Add("dt");//与SaleQuoteModulRpt.xsd table同名
        FillDetaSet.Tables[0].Columns.Add("CustomerNo", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("CustomerName", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("Salesman", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("SalesmanName", typeof(System.String));

        FillDetaSet.Tables[0].Columns.Add("OrderNo", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("QuoteDate", typeof(System.DateTime));
        FillDetaSet.Tables[0].Columns.Add("ValidDate", typeof(System.DateTime));
        FillDetaSet.Tables[0].Columns.Add("DeliveryTerm", typeof(System.String));

        FillDetaSet.Tables[0].Columns.Add("PaymentTerm", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("State", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("StatutoryFee", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("TransportType", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("NoteText", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("Creater", typeof(System.String));

        FillDetaSet.Tables[0].Columns.Add("PartNo", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("PartDesc", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("PartModel", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("UnitMeas", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("UnitPrice", typeof(System.Decimal));
        FillDetaSet.Tables[0].Columns.Add("PayType", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("NoteTextLine", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("PicName", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("FilePath", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("Photograph", typeof(System.Byte[]));

        FillDetaSet.Tables[0].Columns.Add("EntFullName", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("Address", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("Tel", typeof(System.String));
        FillDetaSet.Tables[0].Columns.Add("Fax", typeof(System.String));
        return FillDetaSet;
    }


    public void addrow(DataSet ds, DataSet FillDetaSet, int i)
    {   
     
        DataRow row = FillDetaSet.Tables[0].NewRow();      

        row["CustomerNo"] = ds.Tables[0].Rows[i]["CustomerNo"].ToString();
        row["CustomerName"] = ds.Tables[0].Rows[i]["CustomerName"].ToString();
        row["Salesman"] = ds.Tables[0].Rows[i]["Salesman"].ToString();
        row["SalesmanName"] = ds.Tables[0].Rows[i]["SalesmanName"].ToString();

        row["OrderNo"] = ds.Tables[0].Rows[i]["OrderNo"].ToString();
        row["QuoteDate"] =(DateTime)ds.Tables[0].Rows[i]["QuoteDate"];
        row["ValidDate"] = (DateTime)ds.Tables[0].Rows[i]["ValidDate"];
        row["DeliveryTerm"] = ds.Tables[0].Rows[i]["DeliveryTerm"].ToString();

        row["PaymentTerm"] = ds.Tables[0].Rows[i]["PaymentTerm"].ToString();     
        row["State"] = ds.Tables[0].Rows[i]["State"].ToString();       
        row["StatutoryFee"] = ds.Tables[0].Rows[i]["StatutoryFee"].ToString();
        row["TransportType"] = ds.Tables[0].Rows[i]["TransportType"].ToString();
        row["NoteText"] = ds.Tables[0].Rows[i]["NoteText"].ToString();
        row["Creater"] = ds.Tables[0].Rows[i]["Creater"].ToString();
   
        row["PartNo"] = ds.Tables[0].Rows[i]["PartNo"].ToString();
        row["PartDesc"] = ds.Tables[0].Rows[i]["PartDesc"].ToString();
        row["PartModel"] = ds.Tables[0].Rows[i]["PartModel"].ToString();
        row["UnitMeas"] = ds.Tables[0].Rows[i]["UnitMeas"].ToString();
        row["UnitPrice"] = (Decimal)ds.Tables[0].Rows[i]["UnitPrice"];
        row["PayType"] = ds.Tables[0].Rows[i]["PayType"].ToString();
        row["NoteTextLine"] = ds.Tables[0].Rows[i]["NoteTextLine"].ToString();
        row["PicName"] = ds.Tables[0].Rows[i]["PicName"].ToString();
        row["FilePath"] = ds.Tables[0].Rows[i]["FilePath"].ToString();
        if (ds.Tables[0].Rows[i]["PicName"].ToString() != "")
        {
            try
            {
                string path = Server.MapPath(ds.Tables[0].Rows[i]["FilePath"].ToString());
                FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
                BinaryReader br = new BinaryReader(fs);                
                row["Photograph"] = br.ReadBytes((int)br.BaseStream.Length);
                fs.Close();
            }
            catch(Exception ex)
            {
                string path = Server.MapPath(@"~\UpLoad\Photograph.jpg");
                FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
                BinaryReader br = new BinaryReader(fs);               
                row["Photograph"] = br.ReadBytes((int)br.BaseStream.Length);
                fs.Close();
            }
        }
        else
        {
            row["Photograph"] = DBNull.Value;
        }
        row["EntFullName"] = ds.Tables[0].Rows[i]["EntFullName"].ToString();
        row["Address"] = ds.Tables[0].Rows[i]["Address"].ToString();
        row["Tel"] = ds.Tables[0].Rows[i]["Tel"].ToString();
        row["Fax"] = ds.Tables[0].Rows[i]["Fax"].ToString();
        FillDetaSet.Tables[0].Rows.Add(row);
    }

    public void fillRpt(DataSet ds)
    {
        ds.ReadXmlSchema(Server.MapPath("~/RptCenter/RptModul/SaleQuoteModulRpt.xsd"));
        crs.ReportDocument.Load(Server.MapPath("SaleQuoteModulPush.rpt"));
        crs.ReportDocument.SetDataSource(ds);       
        crs.DataBind();
        crv.ReportSource = crs;
        crv.DataBind();
        ds.Dispose();
    }
}