示例#1
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();
            }
        }
示例#2
0
        public void SaveAs(string FileName, fyiReporting.RDL.OutputPresentationType type)
        {
            fyiReporting.RDL.OneFileStreamGen sg = null;

            try
            {
                // Must use the RunGetData before each export or there is no data.
                _report.RunGetData(this.Parameters);

                sg = new fyiReporting.RDL.OneFileStreamGen(FileName, true);
                _report.RunRender(sg, type);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowError(ex.Message);
            }
            finally
            {
                if (sg != null)
                {
                    sg.CloseMainStream();
                }
            }
            return;
        }
        /// <summary>
        /// Save the report to the output selected.
        /// </summary>
        /// <param name='report'>
        /// Report.
        /// </param>
        /// <param name='FileName'>
        /// File name.
        /// </param>
        private void ExportReport(Report report, string FileName, OutputPresentationType exportType)
        {
            OneFileStreamGen sg = null;

            try
            {
                sg = new OneFileStreamGen(FileName, true);
                report.RunRender(sg, exportType);
            }
            catch (Exception ex)
            {
                Gtk.MessageDialog m = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Error,
                              Gtk.ButtonsType.Ok, false,
                              ex.Message);

                m.Run();
                m.Destroy();
            }
            finally
            {
                if (sg != null)
                {
                    sg.CloseMainStream();
                }
            }
            return;
        }
示例#4
0
        /// <summary>
        /// Save the file.  The extension determines the type of file to save.
        /// </summary>
        /// <param name="FileName">Name of the file to be saved to.</param>
        /// <param name="ext">Type of file to save.  Should be "pdf", "xml", "html", mht.</param>
        private void SaveAs(Report report, string FileName, string type)
        {
            string ext = type.ToLower();
            OneFileStreamGen sg=null;
            try
            {
                if (ext == "tifb")
                    FileName = FileName.Substring(0, FileName.Length - 1);      // get rid of the 'b'
                sg = new OneFileStreamGen(FileName, true);	// overwrite with this name
                switch(ext)
                {
                    case "pdf":
                        if (this._StampInfo == null)
                            report.RunRender(sg, OutputPresentationType.PDF);
                        else
                            SaveAsPdf(report, sg);
                        break;
                    case "xml":
                        report.RunRender(sg, OutputPresentationType.XML);
                        break;
                    case "mht":
                        report.RunRender(sg, OutputPresentationType.MHTML);
                        break;
                    case "html": case "htm":
                        report.RunRender(sg, OutputPresentationType.HTML);
                        break;
                    case "csv":
                        report.RunRender(sg, OutputPresentationType.CSV);
                        break;
                    case "xlsx":
                        report.RunRender(sg, OutputPresentationType.Excel);
                        break;
                    case "rtf":
                        report.RunRender(sg, OutputPresentationType.RTF);
                        break;
                    case "tif": case "tiff":
                        report.RunRender(sg, OutputPresentationType.TIF);
                        break;
                    case "tifb":
                        report.RunRender(sg, OutputPresentationType.TIFBW);
                        break;
                    default:
                        Console.WriteLine("Unsupported file extension '{0}'.  Must be 'pdf', 'xml', 'mht', 'csv', 'xslx', 'rtf', 'tif', 'tifb' or 'html'", type);
                        returnCode = 8;
                        break;
                }
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
                returnCode = 8;
            }
            finally
            {
                if (sg != null)
                {
                    sg.CloseMainStream();
                }
            }

            if (report.ErrorMaxSeverity > 0)
            {
                // have errors fill out the msgs
                Console.WriteLine("{0} has the following runtime errors:", FileName);
                foreach (string emsg in report.ErrorItems)
                {
                    Console.WriteLine(emsg);		// output message to console
                }
                report.ErrorReset();
            }

            return;
        }
示例#5
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();
            }
        }
示例#6
0
        /// <summary>
        /// Save the file.  The extension determines the type of file to save.
        /// </summary>
        /// <param name="FileName">Name of the file to be saved to.</param>
        /// <param name="type">Type of file to save.  Should be "pdf", "xml", "html", "mhtml", "csv", "rtf", "excel", "tif".</param>
        public void SaveAs(string FileName, fyiReporting.RDL.OutputPresentationType type)
        {
            LoadPageIfNeeded();

            OneFileStreamGen sg = new OneFileStreamGen(FileName, true);	// overwrite with this name
            if (!(type == OutputPresentationType.PDF || type == OutputPresentationType.PDFOldStyle ||
                type == OutputPresentationType.TIF || type  == OutputPresentationType.TIFBW))
            {
                ListDictionary ld = GetParameters();		// split parms into dictionary
                _Report.RunGetData(ld);                     // obtain the data (again)
            }
            try
            {
                switch (type)
                {
                    case  OutputPresentationType.PDF:
                         _Report.ItextPDF = true;
                        _Report.RunRenderPdf(sg, _pgs);
                        break;
                    case OutputPresentationType.PDFOldStyle:
                        _Report.ItextPDF = false;
                        _Report.RunRenderPdf(sg, _pgs);
                        break;
                    case  OutputPresentationType.TIF:
                        _Report.RunRenderTif(sg, _pgs, true);
                        break;
                    case  OutputPresentationType.TIFBW:
                        _Report.RunRenderTif(sg, _pgs, false);
                        break;
                    case OutputPresentationType.CSV:
                        _Report.RunRender(sg, OutputPresentationType.CSV);
                        break;
                    case OutputPresentationType.Word:
                    case OutputPresentationType.RTF:
                        _Report.RunRender(sg, OutputPresentationType.RTF);
                        break;
                    case OutputPresentationType.Excel:
                        _Report.RunRender(sg, OutputPresentationType.Excel);
                        break;
                    case OutputPresentationType.XML:
                        _Report.RunRender(sg, OutputPresentationType.XML);
                        break;
                    case OutputPresentationType.HTML:
                        _Report.RunRender(sg, OutputPresentationType.HTML);
                        break;
                    case OutputPresentationType.MHTML:
                        _Report.RunRender(sg, OutputPresentationType.MHTML);
                        break;
                    default:
                        throw new Exception(Strings.RdlViewer_Error_UnsupportedExtension);
                }
            }
            finally
            {
                if (sg != null)
                {
                    sg.CloseMainStream();
                }

            }
            return;
        }
示例#7
0
        public void SaveAs (string FileName, fyiReporting.RDL.OutputPresentationType type)
        {
            fyiReporting.RDL.OneFileStreamGen sg = null;

            try
            {
                // Must use the RunGetData before each export or there is no data.
                _report.RunGetData(this.Parameters);

                sg = new fyiReporting.RDL.OneFileStreamGen(FileName, true);
                _report.RunRender(sg, type);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowError(ex.Message);
            }
            finally
            {
                if (sg != null)
                {
                    sg.CloseMainStream();
                }
            }
            return;
        }
示例#8
0
		/// <summary>
		/// Save the file.  The extension determines the type of file to save.
		/// </summary>
		/// <param name="FileName">Name of the file to be saved to.</param>
		/// <param name="ext">Type of file to save.  Should be "pdf", "xml", "html", mht.</param>
		private void SaveAs(Report report, string FileName, string type)
		{
			string ext = type.ToLower();
			OneFileStreamGen sg=null;
			try
			{
				bool isOldPdf = false;
				if (System.Environment.OSVersion.Platform == PlatformID.Unix && type=="pdf" ) {

                    if (System.IO.Directory.Exists("/usr/share/fonts/truetype/msttcorefonts")==false)
                    {
						isOldPdf = true;
                    }
                   
                }



                if (ext == "tifb")
                    FileName = FileName.Substring(0, FileName.Length - 1);      // get rid of the 'b'
				sg = new OneFileStreamGen(FileName, true);	// overwrite with this name
				switch(ext)
				{
					case "pdf":	
						if (this._StampInfo == null)
						{
							if (isOldPdf)
							{
								report.RunRender(sg, OutputPresentationType.PDFOldStyle);
							}
							else
							{
								report.RunRender(sg, OutputPresentationType.PDF);
							}
								
						}
						else
							SaveAsPdf(report, sg);
						break;
					case "xml": 
						report.RunRender(sg, OutputPresentationType.XML);
						break;																  
					case "mht": 
						report.RunRender(sg, OutputPresentationType.MHTML);
						break;																  
					case "html": case "htm":
						report.RunRender(sg, OutputPresentationType.HTML);
						break;
                    case "csv":
                        report.RunRender(sg, OutputPresentationType.CSV);
                        break;
                    case "xlsx":
                        report.RunRender(sg, OutputPresentationType.Excel);
                        break;
                    case "rtf":
                        report.RunRender(sg, OutputPresentationType.RTF);
                        break;
                    case "tif": case "tiff":
                        report.RunRender(sg, OutputPresentationType.TIF);
                        break;
                    case "tifb":
                        report.RunRender(sg, OutputPresentationType.TIFBW);
                        break;
					default:
						Console.WriteLine("Unsupported file extension '{0}'.  Must be 'pdf', 'xml', 'mht', 'csv', 'xslx', 'rtf', 'tif', 'tifb' or 'html'", type);
						returnCode = 8;
						break;
				}
			}
			catch(Exception e)
			{
				Console.WriteLine(e.Message);
				returnCode = 8;
			}
			finally
			{
				if (sg != null)
				{
					sg.CloseMainStream();
				}
			}

			if (report.ErrorMaxSeverity > 0) 
			{
				// have errors fill out the msgs 
				Console.WriteLine("{0} has the following runtime errors:", FileName);
				foreach (string emsg in report.ErrorItems)
				{
					Console.WriteLine(emsg);		// output message to console
				}
				report.ErrorReset();
			}

			return;
		}
示例#9
0
        /// <summary>
        /// Save the file.  The extension determines the type of file to save.
        /// </summary>
        /// <param name="FileName">Name of the file to be saved to.</param>
        /// <param name="ext">Type of file to save.  Should be "pdf", "xml", "html", "mhtml", "csv", "rtf", "excel", "tif".</param>
        public void SaveAs(string FileName, string type)
        {
            LoadPageIfNeeded();

            string ext = type.ToLower();
            OneFileStreamGen sg = new OneFileStreamGen(FileName, true);	// overwrite with this name
            if (!(ext == "pdf" || ext == "tif" || ext == "tiff" || ext == "tifbw"))
            {
                ListDictionary ld = GetParameters();		// split parms into dictionary
                _Report.RunGetData(ld);                     // obtain the data (again)
            }
            try
            {
                switch(ext)
                {
                    case "pdf":
                        _Report.RunRenderPdf(sg, _pgs);
                        break;
                    case "tif":
                    case "tiff":
                        _Report.RunRenderTif(sg, _pgs, true);
                        break;
                    case "tifbw":
                        _Report.RunRenderTif(sg, _pgs, false);
                        break;
                    case "csv":
                        _Report.RunRender(sg, OutputPresentationType.CSV);
                        break;
                    case "rtf":
                        _Report.RunRender(sg, OutputPresentationType.RTF);
                        break;
                    case "excel":
                    case "xlsx":
                        _Report.RunRender(sg, OutputPresentationType.Excel);
                        break;
                    case "xml":
                        _Report.RunRender(sg, OutputPresentationType.XML);
                        break;
                    case "html":
                    case "htm":
                        _Report.RunRender(sg, OutputPresentationType.HTML);
                        break;
                    case "mhtml": case "mht":
                        _Report.RunRender(sg, OutputPresentationType.MHTML);
                        break;
                    default:
                        throw new Exception("Unsupported file extension for SaveAs");
                }
            }
            finally
            {
                if (sg != null)
                {
                    sg.CloseMainStream();
                }

            }
            return;
        }
示例#10
0
		/// <summary>
		/// Save the file.  The extension determines the type of file to save.
		/// </summary>
		/// <param name="FileName">Name of the file to be saved to.</param>
		/// <param name="ext">Type of file to save.  Should be "pdf", "xml", "html", "mhtml".</param>
		public void SaveAs(string FileName, string type)
		{
			LoadPageIfNeeded();

			string ext = type.ToLower();
			OneFileStreamGen sg = new OneFileStreamGen(FileName, true);	// overwrite with this name
			try
			{
				switch(ext)
				{
					case "pdf":	
						_Report.RunRenderPdf(sg, _pgs);
						break;
					case "xml": 
						_Report.RunRender(sg, OutputPresentationType.XML);
						break;																  
					case "html": case "htm":
						_Report.RunRender(sg, OutputPresentationType.HTML);
						break;
					case "mhtml": case "mht":
						_Report.RunRender(sg, OutputPresentationType.MHTML);
						break;
					default:
						throw new Exception("Unsupported file extension for SaveAs");
				}
			}
			finally
			{
				if (sg != null)
				{
					sg.CloseMainStream();
				}
			}
			return;
		}