Пример #1
0
        public static void RenderReport(string reportName, string schoolyear, string schoolcode, string publishCycle, string userID)
        {
            try
            {
                MyADO.MyParameterRS[] reportParameters = new MyADO.MyParameterRS[4];
                setParameterArray(reportParameters, 0, "UserID", userID);
                setParameterArray(reportParameters, 1, "SchoolYear", schoolyear);
                setParameterArray(reportParameters, 2, "SchoolCode", schoolcode);
                setParameterArray(reportParameters, 3, "PublishCycle", publishCycle);

                string rFormat = WebConfig.ReportFormat();
                Byte[] result  = GetReportR2(reportName, reportParameters);

                if (result.Length != 0)
                {
                    HttpContext.Current.Response.AppendHeader("content-disposition", "filename=" + reportName + "." + rFormat);
                    HttpContext.Current.Response.ContentType = getReportContentType(rFormat);

                    HttpContext.Current.Response.OutputStream.Write(result, 0, result.GetLength(0));

                    HttpContext.Current.Response.End();
                }
                else
                {
                    HttpContext.Current.Response.Redirect("PDFPageFile2.aspx?");
                }
            }
            catch (Exception ex)
            {
                string showmsg = ex.Message;
            }
        }
Пример #2
0
        public static void RenderReport(string _reportName, MyADO.MyParameterRS[] _reportParameter)
        {
            try
            {
                Byte[] result  = GetReportR2(_reportName, _reportParameter);
                string rFormat = WebConfig.ReportFormat();
                HttpContext.Current.Response.AppendHeader("content-disposition", "filename=" + _reportName + "." + rFormat);
                HttpContext.Current.Response.ContentType = getReportContentType(rFormat);

                HttpContext.Current.Response.OutputStream.Write(result, 0, result.GetLength(0));

                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                string showmsg = ex.Message;
            }
        }
Пример #3
0
        public static Byte[] GetReportR2(string _reportName, MyADO.MyParameterRS[] _reportParameter)

        {
            Byte[] result;
            try
            {
                ReportingWebService.ReportExecutionService RS = new ReportingWebService.ReportExecutionService();
                //  CredentialCache cache = new CredentialCache();
                string accessUser        = WebConfig.ReportUser();
                string accessRWSPW       = WebConfig.ReportPW();
                string accessDomain      = WebConfig.DomainName();
                string reportingServices = WebConfig.ReportServices();
                string currentDB         = DBConnection.CurrentDB;
                string report            = WebConfig.ReportPathWS() + currentDB + "/" + _reportName;
                string format            = WebConfig.ReportFormat();

                RS.Url         = reportingServices;
                RS.Credentials = new System.Net.NetworkCredential(accessUser, accessRWSPW, accessDomain);


                string historyID = null;
                string devInfo   = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";

                string encoding = "";
                string mimeType = "";
                ReportingWebService.Warning[] warnings = new ReportingWebService.Warning[0];
                string[] streamIDs = null;


                ReportingWebService.ServerInfoHeader sh = new ReportingWebService.ServerInfoHeader(); //'ServerInfoHeader
                RS.ServerInfoHeaderValue = sh;                                                        //'ServerInfoHeaderValue = sh
                                                                                                      // ReportingWebService.Warning warning = new ReportingWebService.Warning();

                int pLeng = _reportParameter.Length;
                ReportingWebService.ParameterValue[] rptParameters = new ReportingWebService.ParameterValue[pLeng];


                int i = 0;
                foreach (MyADO.MyParameterRS para in _reportParameter)
                {
                    rptParameters[i]       = new ReportingWebService.ParameterValue();
                    rptParameters[i].Name  = para.pName;
                    rptParameters[i].Value = para.pValue.ToString();
                    i += 1;
                }



                // ReDim rptParameters(cnt - 1)


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


                execInfo = RS.LoadReport(report, historyID);

                RS.SetExecutionParameters(rptParameters, "en-us");

                string extension = "";
                string SessionId = RS.ExecutionHeaderValue.ExecutionID;
                //   Console.WriteLine("SessionID: {0}", RS.ExecutionHeaderValue.ExecutionID);

                result = RS.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);

                return(result);
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                return(new Byte[0]);
            }
        }