Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //Initialize the engine
            Report.Init();

            //Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/Windward OData - Template.docx");
            FileStream output   = File.Create("../../../Samples/OData Report.pdf");

            //Create report process
            Report myReport = new ReportPdf(template, output);

            //Run the report process
            myReport.ProcessSetup();

            //Datasource connection code for 'ODataSample' (datasource name inside template)
            IReportDataSource ODataSampleData = new ODataDataSourceImpl("Url=http://services.odata.org/northwind/northwind.svc/;Version=3");
            var dataSources = new Dictionary <string, IReportDataSource>()
            {
                { "ODataSample", ODataSampleData }
            };

            myReport.ProcessData(dataSources);
            myReport.ProcessComplete();

            //Close out of our template file and output
            output.Close();
            template.Close();

            //Open the finished report
            string fullPath = Path.GetFullPath("../../../Samples/OData Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }
        public void DB2Report()
        {
            // Initialize the engine
            Report.Init();

            // Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/Windward Trucking 2 - Template.docx");
            FileStream output   = File.Create("../../../Samples/Xml Report.pdf");

            // Create report process
            Report myReport = new ReportPdf(template, output);


            // Open an inputfilestream for our data file
            FileStream Xml = File.OpenRead("../../../Samples/Windward Trucking 2 - Data.xml");

            // Open a data object to connect to our xml file
            IReportDataSource data = new XmlDataSourceImpl(Xml, false);

            // Run the report process
            myReport.ProcessSetup();
            // The second parameter is "" to tell the process that our data is the default data source
            myReport.ProcessData(data, "");
            myReport.ProcessComplete();

            // Close out of our template file and output
            output.Close();
            template.Close();
            Xml.Close();

            // Opens the finished report
            string fullPath = Path.GetFullPath("../../../Samples/Xml Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }
Exemplo n.º 3
0
        void printButton_Click(object sender, RoutedEventArgs e)
        {
            if (_vm.SelectedProtocol == null)
            {
                MessageBox.Show("Please select an analysis protocol first", "No Protocol Selected", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var reportService = new ReportPdf();
            var reportData    = CreateReportData();

            System.Windows.Forms.PrintDialog printDlg = new System.Windows.Forms.PrintDialog();
            MigraDocPrintDocument            printDoc = new MigraDocPrintDocument();

            printDoc.Renderer = new MigraDoc.Rendering.DocumentRenderer(reportService.CreateReport(reportData));
            printDoc.Renderer.PrepareDocument();

            printDoc.DocumentName = Window.GetWindow(this).Title;
            //printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
            printDlg.Document       = printDoc;
            printDlg.AllowSelection = true;
            printDlg.AllowSomePages = true;
            //Call ShowDialog
            if (printDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                printDoc.Print();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string basePath = Request.PhysicalApplicationPath + "\\";

            // Initialize the engine. License and configuration settings in web.config.
            Report.Init();

            // Open template file
            FileStream template = File.OpenRead(basePath + "Oracle - Template.docx");

            // Create report process
            Report myReport = new ReportPdf(template);

            // SQL data source
            string strConn = "Data Source=oracle.windward.net:1521;Persist Security Info=True;User ID=HR;Password=HR;";
            // you can also use the "Oracle.ManagedDataAccess.Client" connector if installed (.NET 4.0 or later only)
            IReportDataSource data = new AdoDataSourceImpl("Oracle.DataAccess.Client", strConn);

            // Run the report process
            myReport.ProcessSetup();
            //the second parameter is the name of the data source
            myReport.ProcessData(data, "ORACLE");
            myReport.ProcessComplete();

            // Close out of our template file
            template.Close();

            // Opens the finished report
            //Response.ContentType = "application/pdf"; // this would have the pdf open in the browser (disable content-disposition:attachment if you want this)
            Response.ContentType = "application/save"; // this is used with content-disposition to give the proper name of the file
            Response.AppendHeader("content-disposition", "attachment; filename=\"Report.pdf\"");
            Response.BinaryWrite(((MemoryStream)myReport.GetReport()).ToArray());
            Response.End();   // Must be called for MS Office documents
        }
        static void Main(string[] args)
        {
            // Initialize the engine
            Report.Init();

            // Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/Windward Trucking 2 - Template.docx");
            FileStream output   = File.Create("../../../Samples/Xml Report.pdf");

            // Create report process
            Report myReport = new ReportPdf(template, output);

            // Open a data object to connect to our xml file
            string            url  = Path.GetFullPath("../../../Samples/Windward Trucking 2 - Data.xml");
            string            xsd  = null;
            IReportDataSource data = new SaxonDataSourceImpl(string.Format("Url={0}", url), xsd);


            // Run the report process
            myReport.ProcessSetup();
            // The second parameter is "" to tell the process that our data is the default data source
            myReport.ProcessData(data, "sax");
            myReport.ProcessComplete();

            // Close out of our template file and output
            data.Close();
            output.Close();
            template.Close();

            // Opens the finished report
            string fullPath = Path.GetFullPath("../../../Samples/Xml Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }
        public void DB2Report()
        {
            // Initialize the engine
            Report.Init();

            // Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/DB2 - Templates.xlsx");
            FileStream output   = File.Create("../../../Samples/DB2 Report.pdf");

            // Create report process
            Report myReport = new ReportPdf(template, output);


            // DB2 data source
            string            strConn = "server=db2.windward.net;database=Sample;User ID=demo;Password=demo;";
            IReportDataSource data    = new AdoDataSourceImpl("IBM.Data.DB2", strConn);

            //run the report process
            myReport.ProcessSetup();
            //the second parameter is the name of the data source
            myReport.ProcessData(data, "DB2");;
            myReport.ProcessComplete();

            //close out of our template file and output
            output.Close();
            template.Close();

            string fullPath = Path.GetFullPath("../../../Samples/DB2 Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }
        public void Client_PostTemplateAsync()
        {
            var dataSources = new Dictionary<string, DataSource>()
            {
                {"MANF_DATA_2009", new XmlDataSource(File.OpenRead(SampleTemplatesFolder + @"\Manufacturing.xml"))}
            };

            var templateFilePath = SampleTemplatesFolder + @"\Manufacturing.docx";
            var outputFilePath = SampleTemplatesFolder + @"\AsyncOutput.pdf";
            using (var templateFile = File.OpenRead(templateFilePath))
            {
                var report = new ReportPdf(uri, templateFile);
                report.Process(dataSources);

                while (report.GetStatus() == Report.Status.Working)
                    Thread.Sleep(100);

                if (report.GetStatus() == Report.Status.Ready)
                {
                    File.WriteAllBytes(outputFilePath, report.GetReport());

                    report.Delete();
                }
            }
        }
Exemplo n.º 8
0
        public void Client_VariablesTest()
        {
            var ds = new XmlDataSource(File.OpenRead(SampleTemplatesFolder + @"\Manufacturing.xml"));

            ds.Variables = new List <TemplateVariable>()
            {
                new TemplateVariable()
                {
                    Name = "Var1", Value = "hi there"
                }
            };

            var dataSources = new Dictionary <string, DataSource>()
            {
                { "", ds }
            };

            var templateFilePath = SampleTemplatesFolder + @"\Variables.docx";
            var outputFilePath   = SampleTemplatesFolder + @"\VariablesOutput.pdf";

            using (var templateFile = File.OpenRead(templateFilePath))
            {
                using (var outputFile = File.Create(outputFilePath))
                {
                    var report = new ReportPdf(uri, templateFile, outputFile);
                    report.Process(dataSources);
                }
            }
        }
        public void OracleReport()
        {
            // Initialize the engine
            Report.Init();

            // Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/Oracle - Template.docx");
            FileStream output   = File.Create("../../../Samples/Oracle Report.pdf");

            // Create report process
            Report myReport = new ReportPdf(template, output);


            // Oracle data source
            string            strConn = "Data Source=oracle.windward.net:1521;Persist Security Info=True;User ID=HR;Password=HR;";
            IReportDataSource data    = new AdoDataSourceImpl("Oracle.DataAccess.Client", strConn);

            //run the report process
            myReport.ProcessSetup();
            //the second parameter is the name of the data source
            myReport.ProcessData(data, "ORACLE");
            myReport.ProcessComplete();

            //close out of our template file and output
            output.Close();
            template.Close();

            string fullPath = Path.GetFullPath("../../../Samples/Oracle Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }
        static void Main(string[] args)
        {
            // Initialize the engine
            Report.Init();

            // Open template file and create output file
            FileStream template = File.OpenRead("../../../../../Data/Samples/Source/WW-Common List.docx");
            FileStream output = File.Create("../../../../../Data/Samples/Destination/Xml Common List.docx");

            // Create report process
            Report myReport = new ReportPdf(template, output);

            // Open an inputfilestream for our data file
            FileStream Xml = File.OpenRead("../../../../../Data/Data Source/WW-Customers.xml");

            // Open a data object to connect to our xml file
            IReportDataSource data = new XmlDataSourceImpl(Xml, false);

            // Run the report process
            myReport.ProcessSetup();
            // The second parameter is "" to tell the process that our data is the default data source
            myReport.ProcessData(data, "Customers");
            myReport.ProcessComplete();

            // Close out of our template file and output
            output.Close();
            template.Close();
            Xml.Close();

            // Opens the finished report
            string fullPath = Path.GetFullPath("../../../../../Data/Samples/Destination/Xml Common List.docx");
            System.Diagnostics.Process.Start(fullPath);
        }
Exemplo n.º 11
0
        private static void Main()
        {
            Stopwatch sw             = new Stopwatch();
            var       noOfIterations = TotalRecords / noOfRecordsPerFile;

            for (var i = 0; i < noOfIterations; i++)
            {
                var reportService = new ReportPdf();

                sw.Restart();
                var reportData = CreateReportData();
                var path       = GetTempPdfPath();
                reportService.Export(path, reportData);
                sw.Stop();
                Console.WriteLine("Time taken" + sw.Elapsed.TotalSeconds);
                Process.Start(path);
            }
            sw.Reset();
            sw.Start();
            Console.WriteLine();
            ReportPdf.CombinePDFs(@"D:\GeneratedPDF", "ConcatenatedDocument1_tempfile.pdf");
            sw.Stop();
            Console.WriteLine("Time taken to combine the pdf" + sw.Elapsed.TotalSeconds);
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            //Initialize the engine
            Report.Init();

            //Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/Sharepoint with OData - Template.docx");
            FileStream output   = File.Create("../../../Samples/Sharepoint Report.pdf");

            //Create report process
            Report myReport = new ReportPdf(template, output);

            //Run the report process
            myReport.ProcessSetup();

            //Datasource connection code for 'ODataSample' (datasource name inside template)
            IReportDataSource ODataSampleData = new ODataDataSourceImpl("http://sharepointdemo.windward.net/_vti_bin/listdata.svc/", "windwarddemo\\demo", "demo", FileUtils.CONNECT_MODE.CREDENTIALS, 2);
            var dataSources = new Dictionary <string, IReportDataSource>()
            {
                { "sp", ODataSampleData }
            };

            myReport.ProcessData(dataSources);
            myReport.ProcessComplete();

            //Close out of our template file and output
            output.Close();
            template.Close();

            //Open the finished report
            string fullPath = Path.GetFullPath("../../../Samples/Sharepoint Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }
        static void Main(string[] args)
        {
            // Initialize the engine
            Report.Init();

            // Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/template.docx");
            FileStream output   = File.Create("../../../Samples/Report.pdf");

            // Create report process
            Report myReport = new ReportPdf(template, output);

            // Salesforce data source
            SFDataSourceImpl data = new SFDataSourceImpl(@"*****@*****.**", @"w1ndw@rd", "BtqoH7pIR6rkR0fwh1YU156Hp", true);

            //run the report process
            myReport.ProcessSetup();
            //the second parameter is the name of the data source
            myReport.ProcessData(data, "sfdemo");
            myReport.ProcessComplete();

            //close out of our template file and output
            output.Close();
            template.Close();

            // Open the finished report
            string fullPath = Path.GetFullPath("../../../Samples/Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string basePath = Request.PhysicalApplicationPath + "\\";

            // Initialize the engine. License and configuration settings in web.config.
            Report.Init();

            // Open template file
            FileStream template = File.OpenRead(basePath + "DB2 - Templates.xlsx");

            // Create report process
            Report myReport = new ReportPdf(template);

            // SQL data source
            string            strConn = "server=db2.windward.net;database=Sample;User ID=demo;Password=demo;";
            IReportDataSource data    = new AdoDataSourceImpl("IBM.Data.DB2", strConn);

            // Run the report process
            myReport.ProcessSetup();
            //the second parameter is the name of the data source
            myReport.ProcessData(data, "DB2");
            myReport.ProcessComplete();

            // Close out of our template file
            template.Close();

            // Opens the finished report
            //Response.ContentType = "application/pdf"; // this would have the pdf open in the browser (disable content-disposition:attachment if you want this)
            Response.ContentType = "application/save"; // this is used with content-disposition to give the proper name of the file
            Response.AppendHeader("content-disposition", "attachment; filename=\"Report.pdf\"");
            Response.BinaryWrite(((MemoryStream)myReport.GetReport()).ToArray());
            Response.End();   // Must be called for MS Office documents
        }
        public void MySQLReport()
        {
            // Initialize the engine
            Report.Init();

            // Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/MySQL - Template.docx");
            FileStream output   = File.Create("../../../Samples/MySQL Report.pdf");

            // Create report process
            Report myReport = new ReportPdf(template, output);


            // MySQL data source
            string            strConn = "server=mysql.windward.net;database=sakila;user id=test;password=test;";
            IReportDataSource data    = new AdoDataSourceImpl("MySql.Data.MySqlClient", strConn);

            //run the report process
            myReport.ProcessSetup();
            //the second parameter is the name of the data source
            myReport.ProcessData(data, "MYSQL");
            myReport.ProcessComplete();

            //close out of our template file and output
            output.Close();
            template.Close();

            string fullPath = Path.GetFullPath("../../../Samples/MySQL Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }
Exemplo n.º 16
0
        public void Client_TestDatasets()
        {
            var dataSources = new Dictionary <string, DataSource>()
            {
                { "", new AdoDataSource("System.Data.SqlClient", "Data Source=mssql.windward.net;Initial Catalog=AdventureWorks;User=demo;Password=demo") }
            };

            var templateFilePath = SampleTemplatesFolder + @"\DataSet.docx";
            var outputFilePath   = SampleTemplatesFolder + @"\DataSetOutput.pdf";
            var datasetFilePath  = SampleTemplatesFolder + @"\DataSet.rdlx";

            using (var templateFile = File.OpenRead(templateFilePath))
            {
                using (var outputFile = File.Create(outputFilePath))
                {
                    using (var datasetFile = File.OpenRead(datasetFilePath))
                    {
                        var report = new ReportPdf(uri, templateFile, outputFile);

                        report.Datasets = new Dataset[] { new Dataset(datasetFile) };

                        report.Process(dataSources);
                    }
                }
            }
        }
Exemplo n.º 17
0
        private static void Main()
        {
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
            Stopwatch sw             = new Stopwatch();
            var       noOfIterations = TotalRecords / noOfRecordsPerFile;

            for (var i = 0; i < noOfIterations; i++)
            {
                var reportService = new ReportPdf();

                sw.Restart();
                var reportData = CreateReportData();
                var path       = GetTempPdfPath();
                reportService.Export(path, reportData);
                sw.Stop();
                Console.WriteLine("Time taken" + sw.Elapsed.TotalSeconds);
                //Process.Start(path);
            }
            sw.Reset();
            sw.Start();
            Console.WriteLine();
            ReportPdf.CombinePDFs(@"D:\APDFData", "ConcatenatedDocument1_tempfile.pdf");
            sw.Stop();
            Console.WriteLine("Time taken to combine the pdf" + sw.Elapsed.TotalSeconds);
            Console.ReadLine();
        }
        public static void Request1()
        {
            var dataSources = new Dictionary<string, DataSource>()
            {
                {"", new AdoDataSource("System.Data.SqlClient", "Data Source=mssql.windward.net;Initial Catalog=AdventureWorks;User=demo;Password=demo")}
            };

            var templateFilePath = SampleTemplatesFolder + @"\DataSet.docx";
            var outputFilePath = string.Format(@"{0}\DataSetOutput{1}.pdf", SampleTemplatesFolder, rnd.Next());
            var datasetFilePath = SampleTemplatesFolder + @"\DataSet.rdlx";
            using (var templateFile = File.OpenRead(templateFilePath))
            {
                using (var outputFile = File.Create(outputFilePath))
                {
                    using (var datasetFile = File.OpenRead(datasetFilePath))
                    {
                        var report = new ReportPdf(uri, templateFile, outputFile);

                        report.Datasets = new Dataset[] { new Dataset(datasetFile) };

                        report.Process(dataSources);
                    }
                }
            }
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            // Initialize the engine
            Report.Init();

            // Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/Microsoft SQL Server - Template.docx");
            FileStream output   = File.Create("../../../Samples/SQL Report.pdf");

            // Create report process
            Report myReport = new ReportPdf(template, output);

            string strConn = "Data Source=mssql.windward.net;Initial Catalog=Northwind;User ID=demo;Password=demo";

            // SQL data source
            using (AdoDataSourceImpl adoDatasource = new AdoDataSourceImpl("System.Data.SqlClient", strConn)) {
                //run the report process
                myReport.ProcessSetup();
                //the second parameter is the name of the data source
                myReport.ProcessData(adoDatasource, "MSSQL");
                myReport.ProcessComplete();
            }

            //close out of our template file and output
            output.Close();
            template.Close();

            // Open the finished report
            string fullPath = Path.GetFullPath("../../../Samples/SQL Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }
Exemplo n.º 20
0
        public void Client_PostTemplateAsync()
        {
            var dataSources = new Dictionary <string, DataSource>()
            {
                { "MANF_DATA_2009", new XmlDataSource(File.OpenRead(SampleTemplatesFolder + @"\Manufacturing.xml")) }
            };

            var templateFilePath = SampleTemplatesFolder + @"\Manufacturing.docx";
            var outputFilePath   = SampleTemplatesFolder + @"\AsyncOutput.pdf";

            using (var templateFile = File.OpenRead(templateFilePath))
            {
                var report = new ReportPdf(uri, templateFile);
                report.Process(dataSources);

                while (report.GetStatus() == Report.Status.Working)
                {
                    Thread.Sleep(100);
                }

                if (report.GetStatus() == Report.Status.Ready)
                {
                    File.WriteAllBytes(outputFilePath, report.GetReport());

                    report.Delete();
                }
            }
        }
        static void Main(string[] args)
        {
            // Initialize the engine
            Report.Init();

            // Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/JSON - Template.docx");
            FileStream output   = File.Create("../../../Samples/Report.pdf");

            // Create report process
            Report myReport = new ReportPdf(template, output);

            // Connect to our JSON database
            IReportDataSource data = new JsonDataSourceImpl("http://json.windward.net/Northwind.json", JsonDataSourceImpl.MODE.CONNECTION_STRING);

            // Run the report process
            myReport.ProcessSetup();
            // The second parameter is "" to tell the process that our data is the default data source
            myReport.ProcessData(data, "");
            myReport.ProcessComplete();

            // Close out of our template file and output
            output.Close();
            template.Close();

            // Opens the finished report
            string fullPath = Path.GetFullPath("../../../Samples/Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }
        /// <summary>
        /// Sample code to set datasets (SQL & XML) using a .rdlx file.
        /// </summary>
        /// <param name="args">nothing</param>
        static void Main(string[] args)
        {
            // Initialize the engine
            Report.Init();

            // Open template file and create output file
            using (FileStream template = new FileStream("../../files/Sample Dataset Template.docx",
                                                        FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using (FileStream output = new FileStream("../../files/Sample Dataset Report.pdf",
                                                          FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    // Create report process
                    using (Report myReport = new ReportPdf(template, output))
                    {
                        // read in the template
                        myReport.ProcessSetup();

                        // XML datasource
                        using (FileStream xmlFile = new FileStream("../../files/SouthWind.xml", FileMode.Open, FileAccess.Read, FileShare.Read))
                            using (FileStream xmlSchema = new FileStream("../../files/SouthWind.xsd", FileMode.Open, FileAccess.Read, FileShare.Read))
                                using (SaxonDataSourceImpl dsSaxon = new SaxonDataSourceImpl(xmlFile, xmlSchema))
                                    using (DataSetImpl dsEmployeesUnder5 = new DataSetImpl("employeesUnder5", "/windward-studios/Employees/Employee[@EmployeeID < 5]", dsSaxon))
                                        using (DataSetImpl dsCustStartA = new DataSetImpl("CustStartA", "/windward-studios/Customers/Customer[starts-with(CompanyName, 'A')]", dsSaxon))
                                            // SQL datasource
                                            using (AdoDataSourceImpl dsAdo = new AdoDataSourceImpl("System.Data.SqlClient", "Data Source=mssql.windward.net;Initial Catalog=Northwind;User ID=demo;Password=demo"))
                                                using (DataSetImpl dsEmployeesMoreThan5 = new DataSetImpl("EmpMoreThan5", "SELECT * FROM dbo.Employees WHERE(dbo.Employees.EmployeeID > 5)", dsAdo))
                                                    using (DataSetImpl dsCustStartWithB = new DataSetImpl("CustStartWithB", "SELECT * FROM dbo.Customers WHERE(dbo.Customers.CompanyName like 'B%')", dsAdo))
                                                    {
                                                        IDictionary <string, IReportDataSource> datasources = new Dictionary <string, IReportDataSource>();
                                                        datasources.Add("SW", dsSaxon);
                                                        datasources.Add("employeesUnder5", dsEmployeesUnder5);
                                                        datasources.Add("CustStartA", dsCustStartA);
                                                        datasources.Add("MSSQL", dsAdo);
                                                        datasources.Add("EmpMoreThan5", dsEmployeesMoreThan5);
                                                        datasources.Add("CustStartWithB", dsCustStartWithB);

                                                        myReport.ProcessData(datasources);
                                                    }

                        // all data applied, finish up the report.
                        myReport.ProcessComplete();

                        // no need to call close because of the using constructs
                    }
                }
            }

            // Opens the finished report
            string fullPath = Path.GetFullPath("../../files/Sample Dataset Report.pdf");

            Console.Out.WriteLine(string.Format("launching {0}", fullPath));
            System.Diagnostics.Process.Start(fullPath);
        }
Exemplo n.º 23
0
        private static void Main()
        {
            var reportService = new ReportPdf();
            var reportData    = CreateReportData();

            var path = GetTempPdfPath();

            reportService.Export(path, reportData);

            Process.Start(path);
        }
Exemplo n.º 24
0
        private void PrintButtonClicked(object sender, RoutedEventArgs e)
        {
            var reportService = new ReportPdf();
            var reportData    = CreateReportData();

            var path = GetTempPdfPath();

            reportService.Export(path, reportData);

            Process.Start(path);
        }
Exemplo n.º 25
0
 public void Client_PostTemplateReturnsReportPdf()
 {
     using (var templateFile = File.OpenRead(SampleTemplatesFolder + @"\Sample1.docx"))
     {
         using (var output = new MemoryStream())
         {
             var report = new ReportPdf(uri, templateFile, output);
             report.Process();
             Assert.IsTrue(IsPdf(output));
         }
     }
 }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            Report.Report  report;
            ReportDirector director = new ReportDirector();

            ReportPdf pdf = new ReportPdf();

            report = director.MakeReport(pdf);
            report.DisplayReport();

            ReportExcel excel = new ReportExcel();

            report = director.MakeReport(excel);
            report.DisplayReport();
        }
Exemplo n.º 27
0
        public void Client_XmlDataSourceCanUseConnectionString()
        {
            var dataSources = new Dictionary <string, DataSource>()
            {
                { "XPATH2", new XmlDataSource("Url=http://windwardwebsitestorage.blob.core.windows.net/devtestfiles/web-based-templates/XML/SouthWind.xml;") }
            };
            WebClient web = new WebClient();

            using (var template = web.OpenRead("http://windwardwebsitestorage.blob.core.windows.net/devtestfiles/web-based-templates/XML/XML.docx"))
            {
                using (var output = new MemoryStream())
                {
                    var report = new ReportPdf(uri, template, output);
                    report.Process(dataSources);
                    Assert.IsTrue(IsPdf(output));
                }
            }
        }
Exemplo n.º 28
0
        public void Client_PostTemplateWithAdoData()
        {
            var dataSources = new Dictionary <string, DataSource>()
            {
                { "MSSQL", new AdoDataSource("System.Data.SqlClient", "Data Source=mssql.windward.net;Initial Catalog=Northwind;User=demo;Password=demo") }
            };

            var templateFilePath = SampleTemplatesFolder + @"\MsSqlTemplate.docx";
            var outputFilePath   = SampleTemplatesFolder + @"\AdoDataOutput.pdf";

            using (var templateFile = File.OpenRead(templateFilePath))
            {
                using (var outputFile = File.Create(outputFilePath))
                {
                    var report = new ReportPdf(uri, templateFile, outputFile);
                    report.Process(dataSources);
                }
            }
        }
Exemplo n.º 29
0
        public void Client_ODataDataSourceCanUseConnectionString()
        {
            var dataSources = new Dictionary <string, DataSource>()
            {
                { "", new ODataDataSource("Url=http://odata.windward.net/Northwind/Northwind.svc;Version=2") }
            };

            var templatePath = SampleTemplatesFolder + @"\ODataSample.docx";

            using (var template = File.OpenRead(templatePath))
            {
                using (var output = new MemoryStream())
                {
                    var report = new ReportPdf(uri, template, output);
                    report.Process(dataSources);
                    Assert.IsTrue(IsPdf(output));
                }
            }
        }
Exemplo n.º 30
0
        public void Client_PostTemplateWithXmlData()
        {
            var dataSources = new Dictionary <string, DataSource>()
            {
                { "MANF_DATA_2009", new XmlDataSource(File.OpenRead(SampleTemplatesFolder + @"\Manufacturing.xml")) }
            };

            var templateFilePath = SampleTemplatesFolder + @"\Manufacturing.docx";
            var outputFilePath   = SampleTemplatesFolder + @"\XmlDataOutput.pdf";

            using (var templateFile = File.OpenRead(templateFilePath))
            {
                using (var outputFile = File.Create(outputFilePath))
                {
                    var report = new ReportPdf(uri, templateFile, outputFile);
                    report.Process(dataSources);
                }
            }
        }
Exemplo n.º 31
0
        public static void Request4()
        {
            var dataSources = new Dictionary <string, DataSource>()
            {
                { "MANF_DATA_2009", new XmlDataSource(File.OpenRead(SampleTemplatesFolder + @"\Manufacturing.xml")) }
            };

            var templateFilePath = SampleTemplatesFolder + @"\Manufacturing.docx";
            var outputFilePath   = string.Format(@"{0}\XmlDataOutput{1}.pdf", SampleTemplatesFolder, rnd.Next());

            using (var templateFile = File.OpenRead(templateFilePath))
            {
                using (var outputFile = File.Create(outputFilePath))
                {
                    var report = new ReportPdf(uri, templateFile, outputFile);
                    report.Process(dataSources);
                }
            }
        }
Exemplo n.º 32
0
        public static void Request3()
        {
            using (var template = File.OpenRead(SampleTemplatesFolder + @"\Sample1.docx"))
            {
                using (var output = new MemoryStream())
                {
                    var report = new ReportPdf(uri, template, output);
                    report.Process();

                    Assert.IsTrue(output.Length > 8);

                    // Compare the first 7 bytes to the '%PDF-1.' literal.
                    byte[] buffer = new byte[7];
                    Array.Copy(output.GetBuffer(), buffer, 7);
                    string hdr = System.Text.Encoding.UTF8.GetString(buffer);
                    Assert.AreEqual("%PDF-1.", hdr);
                }
            }
        }
Exemplo n.º 33
0
        public static void Request5()
        {
            var dataSources = new Dictionary <string, DataSource>()
            {
                { "MSSQL", new AdoDataSource("System.Data.SqlClient", "Data Source=mssql.windward.net;Initial Catalog=Northwind;User=demo;Password=demo") }
            };

            var templateFilePath = SampleTemplatesFolder + @"\MsSqlTemplate.docx";
            var outputFilePath   = string.Format(@"{0}\AdoDataOutput{1}.pdf", SampleTemplatesFolder, rnd.Next());

            using (var templateFile = File.OpenRead(templateFilePath))
            {
                using (var outputFile = File.Create(outputFilePath))
                {
                    var report = new ReportPdf(uri, templateFile, outputFile);
                    report.Process(dataSources);
                }
            }
        }
        public static void Request3()
        {
            using (var template = File.OpenRead(SampleTemplatesFolder + @"\Sample1.docx"))
            {
                using (var output = new MemoryStream())
                {
                    var report = new ReportPdf(uri, template, output);
                    report.Process();

                    Assert.IsTrue(output.Length > 8);

                    // Compare the first 8 bytes to the '%PDF-1.5' literal.

                    byte[] buffer = new byte[8];
                    Array.Copy(output.GetBuffer(), buffer, 8);

                    Assert.IsTrue(Enumerable.SequenceEqual(buffer, new byte[] { 0x25, 0x50, 0x44, 0x46, 0x2d, 0x31, 0x2e, 0x35 }));
                }
            }
        }
        public void Client_PostTemplateWithAdoData()
        {
            var dataSources = new Dictionary<string, DataSource>()
            {
                {"MSSQL", new AdoDataSource("System.Data.SqlClient", "Data Source=mssql.windward.net;Initial Catalog=Northwind;User=demo;Password=demo")}
            };

            var templateFilePath = SampleTemplatesFolder + @"\MsSqlTemplate.docx";
            var outputFilePath = SampleTemplatesFolder + @"\AdoDataOutput.pdf";
            using (var templateFile = File.OpenRead(templateFilePath))
            {
                using (var outputFile = File.Create(outputFilePath))
                {
                    var report = new ReportPdf(uri, templateFile, outputFile);
                    report.Process(dataSources);
                }
            }
        }
        public void Client_PostTemplateWithXmlData()
        {
            var dataSources = new Dictionary<string, DataSource>()
            {
                {"MANF_DATA_2009", new XmlDataSource(File.OpenRead(SampleTemplatesFolder + @"\Manufacturing.xml"))}
            };

            var templateFilePath = SampleTemplatesFolder + @"\Manufacturing.docx";
            var outputFilePath = SampleTemplatesFolder + @"\XmlDataOutput.pdf";
            using (var templateFile = File.OpenRead(templateFilePath))
            {
                using (var outputFile = File.Create(outputFilePath))
                {
                    var report = new ReportPdf(uri, templateFile, outputFile);
                    report.Process(dataSources);
                }
            }
        }
        public static void Request6()
        {
            var ds = new XmlDataSource(File.OpenRead(SampleTemplatesFolder + @"\Manufacturing.xml"));
            ds.Variables = new List<TemplateVariable>()
            {
                new TemplateVariable() { Name = "Var1", Value = "hi there" }
            };

            var dataSources = new Dictionary<string, DataSource>()
            {
                {"", ds}
            };

            var templateFilePath = SampleTemplatesFolder + @"\Variables.docx";
            var outputFilePath = string.Format(@"{0}\VariablesOutput{1}.pdf", SampleTemplatesFolder, rnd.Next());
            using (var templateFile = File.OpenRead(templateFilePath))
            {
                using (var outputFile = File.Create(outputFilePath))
                {
                    var report = new ReportPdf(uri, templateFile, outputFile);
                    report.Process(dataSources);
                }
            }
        }
        public static void Request4()
        {
            var dataSources = new Dictionary<string, DataSource>()
            {
                {"MANF_DATA_2009", new XmlDataSource(File.OpenRead(SampleTemplatesFolder + @"\Manufacturing.xml"))}
            };

            var templateFilePath = SampleTemplatesFolder + @"\Manufacturing.docx";
            var outputFilePath = string.Format(@"{0}\XmlDataOutput{1}.pdf", SampleTemplatesFolder, rnd.Next());
            using (var templateFile = File.OpenRead(templateFilePath))
            {
                using (var outputFile = File.Create(outputFilePath))
                {
                    var report = new ReportPdf(uri, templateFile, outputFile);
                    report.Process(dataSources);
                }
            }
        }
        public static void Request5()
        {
            var dataSources = new Dictionary<string, DataSource>()
            {
                {"MSSQL", new AdoDataSource("System.Data.SqlClient", "Data Source=mssql.windward.net;Initial Catalog=Northwind;User=demo;Password=demo")}
            };

            var templateFilePath = SampleTemplatesFolder + @"\MsSqlTemplate.docx";
            var outputFilePath = string.Format(@"{0}\AdoDataOutput{1}.pdf", SampleTemplatesFolder, rnd.Next());
            using (var templateFile = File.OpenRead(templateFilePath))
            {
                using (var outputFile = File.Create(outputFilePath))
                {
                    var report = new ReportPdf(uri, templateFile, outputFile);
                    report.Process(dataSources);
                }
            }
        }
Exemplo n.º 40
0
        private async void HandleGeneratePdfReportCommand(object parameter)
        {
            try
            {
                var reporter = new ReportPdf();
                var msg = await reporter.GeneratePdfReport();

                MessageBox.Show(msg);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Json report");
            }

        }