示例#1
0
        private string HtmlExport(SectionDocument document, string pageRange)
        {
            if (!Directory.Exists(_htmlPath))
            {
                Directory.CreateDirectory(_htmlPath);
            }

            using (var htmlExport = new HtmlExport())
                htmlExport.Export(document, _htmlFilePath, pageRange);
            return(GetHtmlString());
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            if (!context.Request.Url.AbsolutePath.EndsWith(HandlerExtension))
            {
                if (!context.Request.Url.AbsolutePath.EndsWith(HandlerCacheExtension))
                {
                    return;
                }

                // return image
                var keyName   = Path.GetFileName(context.Request.FilePath);
                var cacheItem = context.Cache[keyName];
                context.Response.BinaryWrite((byte[])cacheItem);
                return;
            }

            var rpxFile     = context.Server.MapPath(context.Request.Url.LocalPath);
            var htmlHandler = new HtmlOutputHandler(context.Cache, Path.GetFileNameWithoutExtension(rpxFile));

            context.Response.ContentType = "text/html";
            try
            {
                using (var report = new SectionReport())
                    using (var reader = XmlReader.Create(rpxFile))
                    {
                        report.ResourceLocator = new DefaultResourceLocator(new Uri(Path.GetDirectoryName(rpxFile) + @"\"));
                        report.LoadLayout(reader);
                        report.Run(false);
                        using (var html = new HtmlExport {
                            IncludeHtmlHeader = true
                        })
                            html.Export(report.Document, htmlHandler, "");
                        report.Document.Dispose();
                    }
            }
            catch (ReportException eRunReport)
            {
                // Failure running report, just report the error to the user.
                context.Response.Write(Properties.Resource.Error);
                context.Response.Write(eRunReport.ToString());
                return;
            }

            context.Response.BinaryWrite(htmlHandler.MainPageData);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SectionReport rpt = new SectionReport();

            System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Server.MapPath("~") + @"\RpxReports\NwindLabels.rpx");
            rpt.LoadLayout(xtr);
            xtr.Close();
            try
            {
                rpt.Run(false);
            }
            catch (ReportException eRunReport)
            {
                // Show error message to the user when there is a failure in generating the report.
                Response.Clear();
                Response.Write("<h1>Error running report:</h1>");
                Response.Write(eRunReport.ToString());
                return;
            }
            // Used when the page output is already getting created.
            Response.Buffer = true;
            // Clear the output contents from the buffer stream.
            Response.ClearContent();
            // Clear any headers from the buffer stream (such as the content type for an HTML page).
            Response.ClearHeaders();
            // Notify the browser that cache should not be created.
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            // Specify the appropriate viewer for the browser.
            Response.ContentType = "text/html";
            // Create an instance of the HTMLExport class.
            HtmlExport html = new HtmlExport {
                IncludeHtmlHeader = true
            };

            // Export the report to HTML in this session's webcache.
            RpxHandler.HtmlOutputHandler output = new RpxHandler.HtmlOutputHandler(Cache, "Custom HTML");
            html.Export(rpt.Document, output, string.Empty);
            Response.BinaryWrite(output.MainPageData);
            // Send all buffered content to the client
            Response.End();
        }
示例#4
0
        static void Main(string[] args)
        {
            TextWriterTraceListener myWriter = new TextWriterTraceListener(System.Console.Out);

            Trace.Listeners.Add(myWriter);
            PFCDocAnalyzer pfcDoc = new PFCDocAnalyzer();
            KTKDocAnalyzer ktkDoc = new KTKDocAnalyzer();

            PowerScriptCompiler.AddAnalyzer(pfcDoc);
            PowerScriptCompiler.AddAnalyzer(ktkDoc);
            Workspace workspace = Workspace.Load(args[0], args[1]);

            workspace.Compile();
            ktkDoc.ResolveReferenceLinks(workspace.MainTarget, true);

            HtmlExport export = new HtmlExport();

            export.Export(workspace, args[2]);

            workspace.Close();
        }