Ejemplo n.º 1
0
        /// <summary>
        /// RunRenderPdf will render a Pdf given the page structure
        /// </summary>
        /// <param name="sg"></param>
        /// <param name="pgs"></param>
        public void RunRenderPdf(IStreamGen sg, Pages pgs)
        {
            PageNumber = 1;                     // reset page numbers
            TotalPages = 1;

            IPresent ip;

            if (this.ItextPDF)
            {
                ip = new RenderPdf_iTextSharp(this, sg);
            }
            else
            {
                ip = new RenderPdf(this, sg);
            }
            try
            {
                ip.Start();
                ip.RunPages(pgs);
                ip.End();
            }
            finally
            {
                pgs.CleanUp();                          // always want to make sure we cleanup to reduce resource usage
                _Cache = new RCache();
            }

            return;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Renders the report using the requested presentation type.
        /// </summary>
        /// <param name="sg">IStreamGen for generating result stream</param>
        /// <param name="type">Presentation type: HTML, XML, PDF, MHT, or ASP compatible HTML</param>
        /// <param name="prefix">For HTML puts prefix allowing unique name generation</param>
        public void RunRender(IStreamGen sg, OutputPresentationType type, string prefix)
        {
            if (sg == null)
            {
                throw new ArgumentException("IStreamGen argument cannot be null.", "sg");
            }
            RenderHtml rh = null;

            PageNumber = 1;                     // reset page numbers
            TotalPages = 1;
            IPresent        ip;
            MemoryStreamGen msg = null;

            switch (type)
            {
            case OutputPresentationType.PDF:
                ip = new RenderPdf(this, sg);
                _Report.Run(ip);
                break;

            case OutputPresentationType.XML:
                if (_Report.DataTransform != null && _Report.DataTransform.Length > 0)
                {
                    msg = new MemoryStreamGen();
                    ip  = new RenderXml(this, msg);
                    _Report.Run(ip);
                    RunRenderXmlTransform(sg, msg);
                }
                else
                {
                    ip = new RenderXml(this, sg);
                    _Report.Run(ip);
                }
                break;

            case OutputPresentationType.MHTML:
                this.RunRenderMht(sg);
                break;

            case OutputPresentationType.ASPHTML:
            case OutputPresentationType.HTML:
            default:
                ip        = rh = new RenderHtml(this, sg);
                rh.Asp    = (type == OutputPresentationType.ASPHTML);
                rh.Prefix = prefix;
                _Report.Run(ip);
                // Retain the CSS and JavaScript
                if (rh != null)
                {
                    _CSS        = rh.CSS;
                    _JavaScript = rh.JavaScript;
                }
                break;
            }

            sg.CloseMainStream();
            _Cache = new RCache();
            return;
        }
Ejemplo n.º 3
0
 public void Dispose()
 {
     _UserParameters = null;
     _DataSets       = null;
     _Report         = null;
     _Cache          = null;
     _DataSources    = null;
     _CurrentPage    = null;
 }
Ejemplo n.º 4
0
        private void RunRenderMht(IStreamGen sg)
        {
            OneFileStreamGen temp = null;
            FileStream       fs   = null;

            try
            {
                string tempHtmlReportFileName = Path.ChangeExtension(Path.GetTempFileName(), "htm");
                temp = new OneFileStreamGen(tempHtmlReportFileName, true);
                RunRender(temp, OutputPresentationType.HTML);
                temp.CloseMainStream();

                // Create the mht file (into a temporary file position)
                MhtBuilder mhtConverter = new MhtBuilder();
                string     fileName     = Path.ChangeExtension(Path.GetTempFileName(), "mht");
                mhtConverter.SavePageArchive(fileName, "file://" + tempHtmlReportFileName);

                // clean up the temporary files
                foreach (string tempFileName in temp.FileList)
                {
                    try
                    {
                        File.Delete(tempFileName);
                    }
                    catch {}
                }

                // Copy the mht file to the requested stream
                Stream os = sg.GetStream();
                fs = File.OpenRead(fileName);
                byte[] ba = new byte[4096];
                int    rb = 0;
                while ((rb = fs.Read(ba, 0, ba.Length)) > 0)
                {
                    os.Write(ba, 0, rb);
                }
            }
            catch (Exception ex)
            {
                rl.LogError(8, "Error converting HTML to MHTML " + ex.Message +
                            Environment.NewLine + ex.StackTrace);
            }
            finally
            {
                if (temp != null)
                {
                    temp.CloseMainStream();
                }
                if (fs != null)
                {
                    fs.Close();
                }
                _Cache = new RCache();
            }
        }
Ejemplo n.º 5
0
		internal DateTime ExecutionTime;	// start time of report execution

		/// <summary>
		/// Construct a runtime Report object using the compiled report definition.
		/// </summary>
		/// <param name="r"></param>
		public Report(ReportDefn r)
		{
			_Report = r;
			_Cache = new RCache();
			rl = new ReportLog(r.rl);
			_ReportName = r.Name;
			_UserParameters = null;
			_LURuntimeName = new ListDictionary();	// shouldn't be very many of these
			if (r.Code != null)
				_CodeInstance = r.Code.Load(this);
			if (r.Classes != null)
				r.Classes.Load(this);
		}
Ejemplo n.º 6
0
        /// <summary>
        /// Build the Pages for this report.
        /// </summary>
        /// <returns></returns>
        public Pages BuildPages()
        {
            PageNumber = 1;                     // reset page numbers
            TotalPages = 1;

            Pages pgs = new Pages(this);

            pgs.PageHeight = _Report.PageHeight.Points;
            pgs.PageWidth  = _Report.PageWidth.Points;
            try
            {
                Page p = new Page(1);                                           // kick it off with a new page
                pgs.AddPage(p);

                // Create all the pages
                _Report.Body.RunPage(pgs);

                if (pgs.LastPage.IsEmpty() && pgs.PageCount > 1)                // get rid of extraneous pages which
                {
                    pgs.RemoveLastPage();                                       //   can be caused by region page break at end
                }
                // Now create the headers and footers for all the pages (as needed)
                if (_Report.PageHeader != null)
                {
                    _Report.PageHeader.RunPage(pgs);
                }
                if (_Report.PageFooter != null)
                {
                    _Report.PageFooter.RunPage(pgs);
                }
                // clear out any runtime clutter
                foreach (Page pg in pgs)
                {
                    pg.ResetPageExpressions();
                }

                pgs.SortPageItems();             // Handle ZIndex ordering of pages
            }
            catch (Exception e)
            {
                rl.LogError(8, "Exception running report\r\n" + e.Message + "\r\n" + e.StackTrace);
            }
            finally
            {
                pgs.CleanUp();                          // always want to make sure we clean this up since
                _Cache = new RCache();
            }

            return(pgs);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Construct a runtime Report object using the compiled report definition.
 /// </summary>
 /// <param name="r"></param>
 public Report(ReportDefn r)
 {
     _Report         = r;
     _Cache          = new RCache();
     rl              = new ReportLog(r.rl);
     _ReportName     = r.Name;
     _UserParameters = null;
     _LURuntimeName  = new ListDictionary();             // shouldn't be very many of these
     if (r.Code != null)
     {
         _CodeInstance = r.Code.Load(this);
     }
     if (r.Classes != null)
     {
         r.Classes.Load(this);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Construct a runtime Report object using the compiled report definition.
        /// </summary>
        /// <param name="r"></param>
        public Report(ReportDefn r)
        {
            this.FontFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts);


            _Report         = r;
            _Cache          = new RCache();
            rl              = new ReportLog(r.rl);
            _ReportName     = r.Name;
            _UserParameters = null;
            _LURuntimeName  = new ListDictionary();             // shouldn't be very many of these
            if (r.Code != null)
            {
                _CodeInstance = r.Code.Load(this);
            }
            if (r.Classes != null)
            {
                r.Classes.Load(this);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// RunRenderTif will render a TIF given the page structure
        /// </summary>
        /// <param name="sg"></param>
        /// <param name="pgs"></param>
        public void RunRenderTif(IStreamGen sg, Pages pgs, bool bColor)
        {
            PageNumber = 1;             // reset page numbers
            TotalPages = 1;

            RenderTif ip = new RenderTif(this, sg);

            ip.RenderColor = bColor;
            try
            {
                ip.Start();
                ip.RunPages(pgs);
                ip.End();
            }
            finally
            {
                pgs.CleanUp();          // always want to make sure we cleanup to reduce resource usage
                _Cache = new RCache();
            }

            return;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Renders the report using the requested presentation type.
        /// </summary>
        /// <param name="sg">IStreamGen for generating result stream</param>
        /// <param name="type">Presentation type: HTML, XML, PDF, MHT, or ASP compatible HTML</param>
        /// <param name="prefix">For HTML puts prefix allowing unique name generation</param>
        public void RunRender(IStreamGen sg, OutputPresentationType type, string prefix)
        {
            if (sg == null)
                throw new ArgumentException("IStreamGen argument cannot be null.", "sg");
            RenderHtml rh=null;

            PageNumber = 1;		// reset page numbers
            TotalPages = 1;
            IPresent ip;
            MemoryStreamGen msg = null;
            switch (type)
            {
                case OutputPresentationType.PDF:
                    ip = new RenderPdf(this, sg);
                    _Report.Run(ip);
                    break;
                case OutputPresentationType.PDFOldStyle:
                    ip = new RenderPdf(this, sg);
                    this.ItextPDF = false;
                    _Report.Run(ip);
                    break;
                case OutputPresentationType.TIF:
                    ip = new RenderTif(this, sg);
                    _Report.Run(ip);
                    break;
                case OutputPresentationType.TIFBW:
                    RenderTif rtif = new RenderTif(this, sg);
                    rtif.RenderColor = false;
                    ip = rtif;
                    _Report.Run(ip);
                    break;
                case OutputPresentationType.XML:
                    if (_Report.DataTransform != null && _Report.DataTransform.Length > 0)
                    {
                        msg = new MemoryStreamGen();
                        ip = new RenderXml(this, msg);
                        _Report.Run(ip);
                        RunRenderXmlTransform(sg, msg);
                    }
                    else
                    {
                        ip = new RenderXml(this, sg);
                        _Report.Run(ip);
                    }
                    break;
                case OutputPresentationType.MHTML:
                    this.RunRenderMht(sg);
                    break;
                case OutputPresentationType.CSV:
                    ip = new RenderCsv(this, sg);
                    _Report.Run(ip);
                    break;
                case OutputPresentationType.RTF:
                    ip = new RenderRtf(this, sg);
                    _Report.Run(ip);
                    break;
                case OutputPresentationType.Excel:
                    ip = new RenderExcel(this, sg);
                    _Report.Run(ip);
                    break;
                case OutputPresentationType.ASPHTML:
                case OutputPresentationType.HTML:
                default:
                    ip = rh = new RenderHtml(this, sg);
                    rh.Asp = (type == OutputPresentationType.ASPHTML);
                    rh.Prefix = prefix;
                    _Report.Run(ip);
                    // Retain the CSS and JavaScript
                    if (rh != null)
                    {
                        _CSS = rh.CSS;
                        _JavaScript = rh.JavaScript;
                    }
                    break;
            }

            sg.CloseMainStream();
            _Cache = new RCache();
            return;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// RunRenderPdf will render a Pdf given the page structure
        /// </summary>
        /// <param name="sg"></param>
        /// <param name="pgs"></param>
        public void RunRenderPdf(IStreamGen sg, Pages pgs)
        {
            PageNumber = 1;		// reset page numbers
            TotalPages = 1;

            IPresent ip;
            if (this.ItextPDF)
                ip = new RenderPdf_iTextSharp(this, sg);
            else
                ip=new RenderPdf(this, sg);
            try
            {
                ip.Start();
                ip.RunPages(pgs);
                ip.End();
            }
            finally
            {
                pgs.CleanUp();		// always want to make sure we cleanup to reduce resource usage
                _Cache = new RCache();
            }

            return;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Renders the report using the requested presentation type.
        /// </summary>
        /// <param name="sg">IStreamGen for generating result stream</param>
        /// <param name="type">Presentation type: HTML, XML, PDF, MHT, or ASP compatible HTML</param>
        /// <param name="prefix">For HTML puts prefix allowing unique name generation</param>
        public void RunRender(IStreamGen sg, OutputPresentationType type, string prefix, Pages pgs)
        {
            if (sg == null)
            {
                throw new ArgumentException("IStreamGen argument cannot be null.", "sg");
            }
            RenderHtml rh = null;


            PageNumber = 1;             // reset page numbers
            TotalPages = 1;
            IPresent        ip;
            MemoryStreamGen msg = null;

            switch (type)
            {
            case OutputPresentationType.PDF:
            case OutputPresentationType.RenderPdf_iTextSharp:
                ip = new RenderPdf_iTextSharp(this, sg);
                _Report.Run(ip);
                break;

            case OutputPresentationType.PDFOldStyle:
                ip            = new RenderPdf(this, sg);
                this.ItextPDF = false;
                _Report.Run(ip);
                break;

            case OutputPresentationType.TIF:
                ip = new RenderTif(this, sg);
                _Report.Run(ip);
                break;

            case OutputPresentationType.TIFBW:
                RenderTif rtif = new RenderTif(this, sg);
                rtif.RenderColor = false;
                ip = rtif;
                _Report.Run(ip);
                break;

            case OutputPresentationType.XML:
                if (_Report.DataTransform != null && _Report.DataTransform.Length > 0)
                {
                    msg = new MemoryStreamGen();
                    ip  = new RenderXml(this, msg);
                    _Report.Run(ip);
                    RunRenderXmlTransform(sg, msg);
                }
                else
                {
                    ip = new RenderXml(this, sg);
                    _Report.Run(ip);
                }
                break;

            case OutputPresentationType.MHTML:
                this.RunRenderMht(sg, pgs);
                break;

            case OutputPresentationType.CSV:
                ip = new RenderCsv(this, sg);
                _Report.Run(ip);
                break;

            case OutputPresentationType.RTF:
                ip = new RenderRtf(this, sg);
                _Report.Run(ip);
                break;

            case OutputPresentationType.Excel:
                ip = new RenderExcel(this, sg);
                _Report.Run(ip);
                break;

            case OutputPresentationType.ASPHTML:
            case OutputPresentationType.HTML:
            default:
                ip        = rh = new RenderHtml(this, sg);
                rh.Asp    = (type == OutputPresentationType.ASPHTML);
                rh.Prefix = prefix;
                _Report.Run(ip);
                // Retain the CSS and JavaScript
                if (rh != null)
                {
                    _CSS        = rh.CSS;
                    _JavaScript = rh.JavaScript;
                }
                break;
            }

            sg.CloseMainStream();
            _Cache = new RCache();
            return;
            ////if (this.ItextPDF)
            ////    ip = new RenderPdf_iTextSharp(this, sg);
            ////else
            //    switch (type)
            //    {
            //        case OutputPresentationType.PDF:
            //        case OutputPresentationType.RenderPdf_iTextSharp:
            //            ip = new RenderPdf_iTextSharp(this, sg);
            //            RunRender(ref ip, ref pgs);
            //            break;
            //        case OutputPresentationType.PDFOldStyle:
            //            ip = new RenderPdf(this, sg);
            //            this.ItextPDF = false;
            //            RunRender(ref ip, ref pgs);
            //            break;
            //        case OutputPresentationType.TIF:
            //            ip = new RenderTif(this, sg);
            //            RunRender(ref ip, ref pgs);
            //            break;
            //        case OutputPresentationType.TIFBW:
            //            RenderTif rtif = new RenderTif(this, sg);
            //            rtif.RenderColor = false;
            //            ip = rtif;
            //            RunRender(ref ip, ref pgs);
            //            break;
            //        case OutputPresentationType.XML:
            //            if (_Report.DataTransform != null && _Report.DataTransform.Length > 0)
            //            {
            //                var msg = new MemoryStreamGen();
            //                ip = new RenderXml(this, msg);
            //                RunRender(ref ip, ref pgs);
            //                RunRenderXmlTransform(sg, msg);
            //            }
            //            else
            //            {
            //                ip = new RenderXml(this, sg);
            //                RunRender(ref ip, ref pgs);
            //            }
            //            break;
            //        case OutputPresentationType.MHTML:
            //            this.RunRenderMht(sg,pgs);
            //            break;
            //        case OutputPresentationType.CSV:
            //            ip = new RenderCsv(this, sg);
            //            RunRender(ref ip, ref pgs);
            //            break;
            //        case OutputPresentationType.RTF:
            //            ip = new RenderRtf(this, sg);
            //            RunRender(ref ip, ref pgs);
            //            break;
            //        case OutputPresentationType.Excel:
            //            ip = new RenderExcel(this, sg);
            //            RunRender(ref ip, ref pgs);
            //            break;
            //        case OutputPresentationType.ASPHTML:
            //        case OutputPresentationType.HTML:
            //        default:
            //            ip = rh = new RenderHtml(this, sg);
            //            rh.Asp = (type == OutputPresentationType.ASPHTML);
            //            rh.Prefix = prefix;
            //            RunRender(ref ip, ref pgs);
            //            // Retain the CSS and JavaScript
            //            if (rh != null)
            //            {
            //                _CSS = rh.CSS;
            //                _JavaScript = rh.JavaScript;
            //            }
            //            break;
            //    }

            //pgs.CleanUp();      // always want to make sure we cleanup to reduce resource usage
            //_Cache = new RCache();

            //return;



            //         PageNumber = 1;		// reset page numbers
            //TotalPages = 1;
            //IPresent ip;
            //MemoryStreamGen msg = null;
            //switch (type)
            //{
            //             case OutputPresentationType.PDF:
            //             case OutputPresentationType.RenderPdf_iTextSharp:
            //                 ip =new RenderPdf_iTextSharp(this, sg);
            //                 _Report.Run(ip);
            //                 break;
            //             case OutputPresentationType.PDFOldStyle:
            //                 ip = new RenderPdf(this, sg);
            //                 this.ItextPDF = false;
            //                 _Report.Run(ip);
            //                 break;
            //             case OutputPresentationType.TIF:
            //                 ip = new RenderTif(this, sg);
            //                 _Report.Run(ip);
            //                 break;
            //             case OutputPresentationType.TIFBW:
            //                 RenderTif rtif = new RenderTif(this, sg);
            //                 rtif.RenderColor = false;
            //                 ip = rtif;
            //                 _Report.Run(ip);
            //                 break;
            //             case OutputPresentationType.XML:
            //		if (_Report.DataTransform != null && _Report.DataTransform.Length > 0)
            //		{
            //			msg = new MemoryStreamGen();
            //			ip = new RenderXml(this, msg);
            //			_Report.Run(ip);
            //			RunRenderXmlTransform(sg, msg);
            //		}
            //		else
            //		{
            //			ip = new RenderXml(this, sg);
            //			_Report.Run(ip);
            //		}
            //		break;
            //	case OutputPresentationType.MHTML:
            //		this.RunRenderMht(sg);
            //		break;
            //             case OutputPresentationType.CSV:
            //                 ip = new RenderCsv(this, sg);
            //                 _Report.Run(ip);
            //                 break;
            //             case OutputPresentationType.RTF:
            //                 ip = new RenderRtf(this, sg);
            //                 _Report.Run(ip);
            //                 break;
            //             case OutputPresentationType.Excel:
            //                 ip = new RenderExcel(this, sg);
            //                 _Report.Run(ip);
            //                 break;
            //             case OutputPresentationType.ASPHTML:
            //	case OutputPresentationType.HTML:
            //	default:
            //		ip = rh = new RenderHtml(this, sg);
            //		rh.Asp = (type == OutputPresentationType.ASPHTML);
            //		rh.Prefix = prefix;
            //		_Report.Run(ip);
            //		// Retain the CSS and JavaScript
            //		if (rh != null)
            //		{
            //			_CSS = rh.CSS;
            //			_JavaScript = rh.JavaScript;
            //		}
            //		break;
            //}

            //sg.CloseMainStream();
            //         _Cache = new RCache();
            //         return;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Renders the report using the requested presentation type.
        /// </summary>
        /// <param name="sg">IStreamGen for generating result stream</param>
        /// <param name="type">Presentation type: HTML, XML, PDF, MHT, or ASP compatible HTML</param>
        /// <param name="prefix">For HTML puts prefix allowing unique name generation</param>
        public void RunRender(IStreamGen sg, OutputPresentationType type, string prefix)
        {
            if (sg == null)
            {
                throw new ArgumentException("IStreamGen argument cannot be null.", "sg");
            }

            //RenderHtml rh=null;

            PageNumber = 1;                     // reset page numbers
            TotalPages = 1;
            IPresent        ip;
            MemoryStreamGen msg = null;

            switch (type)
            {
            case OutputPresentationType.PDF:
                ip = new RenderPdf(this, sg);
                _Report.Run(ip);
                break;

            case OutputPresentationType.PDFOldStyle:
                ip            = new RenderPdf(this, sg);
                this.ItextPDF = false;
                _Report.Run(ip);
                break;

            //case OutputPresentationType.TIF:
            //    ip = new RenderTif(this, sg);
            //    _Report.Run(ip);
            //    break;
            //case OutputPresentationType.TIFBW:
            //    RenderTif rtif = new RenderTif(this, sg);
            //    rtif.RenderColor = false;
            //    ip = rtif;
            //    _Report.Run(ip);
            //    break;
            case OutputPresentationType.XML:
                if (_Report.DataTransform != null && _Report.DataTransform.Length > 0)
                {
                    msg = new MemoryStreamGen();
                    ip  = new RenderXml(this, msg);
                    _Report.Run(ip);
                    RunRenderXmlTransform(sg, msg);
                }
                else
                {
                    ip = new RenderXml(this, sg);
                    _Report.Run(ip);
                }
                break;

            case OutputPresentationType.MHTML:
                this.RunRenderMht(sg);
                break;

            case OutputPresentationType.CSV:
                ip = new RenderCsv(this, sg);
                _Report.Run(ip);
                break;

            case OutputPresentationType.RTF:
                ip = new RenderRtf(this, sg);
                _Report.Run(ip);
                break;
                //case OutputPresentationType.Excel:
                //    ip = new RenderExcel(this, sg);
                //    _Report.Run(ip);
                //    break;
                //case OutputPresentationType.ASPHTML:
                //case OutputPresentationType.HTML:
                //default:
                //    ip = rh = new RenderHtml(this, sg);
                //    rh.Asp = (type == OutputPresentationType.ASPHTML);
                //    rh.Prefix = prefix;
                //    _Report.Run(ip);
                //    // Retain the CSS and JavaScript
                //    if (rh != null)
                //    {
                //        _CSS = rh.CSS;
                //        _JavaScript = rh.JavaScript;
                //    }
                //    break;
            }

            sg.CloseMainStream();
            _Cache = new RCache();
            return;
        }
Ejemplo n.º 14
0
        ICollection _UserParameters; // User parameters

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Construct a runtime Report object using the compiled report definition.
        /// </summary>
        /// <param name="r"></param>
        public Report(ReportDefn r)
        {
            this.FontFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts);

            _Report = r;
            _Cache = new RCache();
            rl = new ReportLog(r.rl);
            _ReportName = r.Name;
            _UserParameters = null;
            _LURuntimeName = new ListDictionary();	// shouldn't be very many of these
            if (r.Code != null)
                _CodeInstance = r.Code.Load(this);
            if (r.Classes != null)
                r.Classes.Load(this);
        }
Ejemplo n.º 15
0
        private void RunRenderMht(IStreamGen sg)
        {
            OneFileStreamGen temp = null;
            FileStream fs=null;
            try
            {
                string tempHtmlReportFileName = Path.ChangeExtension(Path.GetTempFileName(), "htm");
                temp = new OneFileStreamGen(tempHtmlReportFileName, true);
                RunRender(temp, OutputPresentationType.HTML);
                temp.CloseMainStream();

                // Create the mht file (into a temporary file position)
                MhtBuilder mhtConverter = new MhtBuilder();
                string fileName = Path.ChangeExtension(Path.GetTempFileName(), "mht");
                mhtConverter.SavePageArchive(fileName, "file://" + tempHtmlReportFileName);

                // clean up the temporary files
                foreach (string tempFileName in temp.FileList)
                {
                    try
                    {
                        File.Delete(tempFileName);
                    }
                    catch{}
                }

                // Copy the mht file to the requested stream
                Stream os = sg.GetStream();
                fs = File.OpenRead(fileName);
                byte[] ba = new byte[4096];
                int rb=0;
                while ((rb = fs.Read(ba, 0, ba.Length)) > 0)
                {
                    os.Write(ba, 0, rb);
                }

            }
            catch (Exception ex)
            {
                rl.LogError(8, "Error converting HTML to MHTML " + ex.Message +
                                    Environment.NewLine + ex.StackTrace);
            }
            finally
            {
                if (temp != null)
                    temp.CloseMainStream();
                if (fs != null)
                    fs.Close();
                _Cache = new RCache();
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// RunRenderTif will render a TIF given the page structure
        /// </summary>
        /// <param name="sg"></param>
        /// <param name="pgs"></param>
        public void RunRenderTif(IStreamGen sg, Pages pgs, bool bColor)
        {
            PageNumber = 1;		// reset page numbers
            TotalPages = 1;

            RenderTif ip = new RenderTif(this, sg);
            ip.RenderColor = bColor;
            try
            {
                ip.Start();
                ip.RunPages(pgs);
                ip.End();
            }
            finally
            {
                pgs.CleanUp();		// always want to make sure we cleanup to reduce resource usage
                _Cache = new RCache();
            }

            return;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Build the Pages for this report.
        /// </summary>
        /// <returns></returns>
        public Pages BuildPages()
        {
            PageNumber = 1;		// reset page numbers
            TotalPages = 1;

            Pages pgs = new Pages(this);
            pgs.PageHeight = _Report.PageHeight.Points;
            pgs.PageWidth = _Report.PageWidth.Points;
            try
            {
                Page p = new Page(1);				// kick it off with a new page
                pgs.AddPage(p);

                // Create all the pages
                _Report.Body.RunPage(pgs);

                if (pgs.LastPage.IsEmpty() && pgs.PageCount > 1) // get rid of extraneous pages which
                    pgs.RemoveLastPage();			//   can be caused by region page break at end

                // Now create the headers and footers for all the pages (as needed)
                if (_Report.PageHeader != null)
                    _Report.PageHeader.RunPage(pgs);
                if (_Report.PageFooter != null)
                    _Report.PageFooter.RunPage(pgs);
                // clear out any runtime clutter
                foreach (Page pg in pgs)
                    pg.ResetPageExpressions();

                pgs.SortPageItems();             // Handle ZIndex ordering of pages
            }
            catch (Exception e)
            {
                rl.LogError(8, "Exception running report\r\n" + e.Message + "\r\n" + e.StackTrace);
            }
            finally
            {
                pgs.CleanUp();		// always want to make sure we clean this up since
                _Cache = new RCache();
            }

            return pgs;
        }