Пример #1
0
        public static Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue[] ConvertPeriodicReportParameters(Hashtable parameters)
        {
            Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue[] reportParameters = null;

            reportParameters = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue[parameters.Count];
            // set the report parameters
            if (parameters.Count > 0)
            {
                int i = 0;
                foreach (DictionaryEntry parameter in parameters)
                {
                    try
                    {
                        reportParameters[i]      = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue();
                        reportParameters[i].Name = parameter.Key.ToString();
                        if (parameter.Value is DateTime)
                        {
                            //yyyy'-'MM'-'dd'T'HH':'mm':'ss (SortableDateTimePattern)
                            reportParameters[i].Value = ((DateTime)parameter.Value).ToString("s");
                        }
                        else
                        {
                            reportParameters[i].Value = parameter.Value.ToString();
                        }
                    }
                    catch (Exception Ex)
                    {
                    }
                    i++;
                }
            }

            return(reportParameters);
        }
Пример #2
0
        /// <summary>
        /// Get report parameter's values
        /// </summary>
        /// <remarks>
        /// This method is called in the ReportViewer control
        /// </remarks>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public static Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue[] ConvertReportParameters(Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue[] parameters)
        {
            Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue[] reportParameters = null;

            reportParameters = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue[40];
            reportParameters = parameters;

            return(reportParameters);
        }
Пример #3
0
        /*
         * /// <summary>
         * /// Get report parameter's values
         * /// </summary>
         * /// <remarks>
         * /// This method is called in the export and stream rendering.
         * /// It gets sessionGuid id from querystring and gets parameter value array from session
         * /// </remarks>
         * /// <param name="parameters">It is from query string</param>
         * /// <returns></returns>
         * public static ParameterValue[] GetReportParameters(NameValueCollection parameters)
         * {
         *      Hashtable paras;
         *
         *      ParameterValue[] reportParameters = null;
         *
         *      paras =(Hashtable)HttpContext.Current.Session[Util.GetSessionID()];
         *
         *      reportParameters = Util.GetReportParameters(paras);
         *
         *      return reportParameters;
         * }
         */

        /// <summary>
        /// Get report parameter's values from session
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <returns></returns>
        public static ReportExecution20051.ParameterValue[] GetReportParameters(string sessionID)
        {
            ReportExecution20051.ParameterValue[] reportParameters = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue[0];

            reportParameters = (ReportExecution20051.ParameterValue[])HttpContext.Current.Session[sessionID];

            if (reportParameters == null)
            {
                throw new Exception("SESSION TIMEOUT: The required Browser session ID of " + sessionID + " could not be found (the current browser session = " + HttpContext.Current.Session.SessionID.ToString() + "), session timeout = " + HttpContext.Current.Session.Timeout.ToString() + " minutes. Has " + HttpContext.Current.Session.Timeout.ToString() + " minutes expired since you first displayed the Report?");
            }

            return(reportParameters);
        }
Пример #4
0
        public void ExportDataSetNew(string SP_Name, string Param1, string Param2, string Param3, string CurrentCultureName, ExportType FileType, String FileName, String ReportTitle, String LangInterfaceName, String LangResourceName, String Expanded)
        {
            Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue[] reportParameters = null;
            reportParameters          = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue[9];
            reportParameters[0]       = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue();
            reportParameters[0].Name  = "SP_Name";
            reportParameters[0].Value = SP_Name;
            reportParameters[1]       = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue();
            reportParameters[1].Name  = "Param1";
            reportParameters[1].Value = Param1;
            reportParameters[2]       = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue();
            reportParameters[2].Name  = "Param2";
            reportParameters[2].Value = Param2;
            reportParameters[3]       = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue();
            reportParameters[3].Name  = "Param3";
            reportParameters[3].Value = Param3;
            reportParameters[4]       = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue();
            reportParameters[4].Name  = "CurrentCultureName";
            reportParameters[4].Value = CurrentCultureName;
            reportParameters[5]       = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue();
            reportParameters[5].Name  = "LangInterfaceName";
            reportParameters[5].Value = LangInterfaceName;
            reportParameters[6]       = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue();
            reportParameters[6].Name  = "Expanded";
            reportParameters[6].Value = Expanded;
            reportParameters[7]       = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue();
            reportParameters[7].Name  = "ReportTitle";
            reportParameters[7].Value = ReportTitle;
            reportParameters[8]       = new Bdw.SqlServer.Reporting.ReportExecution20051.ParameterValue();
            reportParameters[8].Name  = "LangResourceName";
            reportParameters[8].Value = LangResourceName;



            String format = "DOC";

            if (FileType == ExportType.CSV)
            {
                format = "CSV";
            }
            ;
            if (FileType == ExportType.PDF)
            {
                format = "PDF";
            }
            ;
            if (FileType == ExportType.Excel)
            {
                format = "XLS";
            }
            ;


            string thecontent;

            string[] streamIDs = null;

            Bdw.SqlServer.Reporting.ReportService20051.ReportingService2005     rs;
            Bdw.SqlServer.Reporting.ReportExecution20051.ReportExecutionService rsExec;


            rs     = GetReportingService();
            rsExec = GetReportExecutionService();
            ReportSettings settings = GetSettings();
            string         encoding;
            string         mimeType;
            string         _historyID = null;

            Bdw.SqlServer.Reporting.ReportExecution20051.Warning[] warnings = null;

            string extension = null;

            Bdw.SqlServer.Reporting.ReportExecution20051.ExecutionInfo ei = rsExec.LoadReport(settings.ReportFolder + "/GridExport", _historyID);
            //rsExec.ExecutionHeaderValue.ExecutionID = SessionID;

            rsExec.SetExecutionParameters(reportParameters, "en-us");

            string Format = "HTML4.0";

            if (FileType == ExportType.PDF)
            {
                Format = "PDF";
            }
            if (FileType == ExportType.Word)
            {
                Format = "WORD";
            }
            if (FileType == ExportType.CSV)
            {
                Format = "CSV";
            }
            if (FileType == ExportType.Excel)
            {
                Format = "EXCEL";
            }
            //string deviceInfo = "<DeviceInfo><HTMLFragment>True</HTMLFragment><Toolbar>False</Toolbar><Section>0</Section><StreamRoot>{Emerging.Systems.MultipartMime}</StreamRoot></DeviceInfo>";
            string deviceInfo = "<DeviceInfo><Encoding>ASCII</Encoding></DeviceInfo>";

            Bdw.SqlServer.Reporting.ReportExecution20051.PageCountMode Exact = new Bdw.SqlServer.Reporting.ReportExecution20051.PageCountMode();

            Exact = Bdw.SqlServer.Reporting.ReportExecution20051.PageCountMode.Actual;

            //byte[] content = rsExec.Render2(Format, deviceInfo, Exact, out extension, out mimeType, out encoding, out warnings, out streamIDs);
            byte[] content = rsExec.Render(Format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);

            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = mimeType;
            Response.AppendHeader("Content-Length", content.Length.ToString());
            Response.AddHeader("content-disposition", "attachment; filename=\"" + FileName + "." + extension + "\"");
            Response.BinaryWrite(content);

            Response.Flush();
            Response.Close();
        }