Ejemplo n.º 1
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();
                }
            }
        }
Ejemplo n.º 2
0
        public void AsynchronousRun()
        {
            var dataSources = new Dictionary <string, DataSource>()
            {
                { "MANF_DATA_2009", new XmlDataSource(File.OpenRead(string.Format(@"{0}\Manufacturing.xml", samplesFolder))) }
            };

            var templatePath = string.Format(@"{0}\Manufacturing.docx", samplesFolder);

            using (var templateStream = File.OpenRead(templatePath))
            {
                var report = new ReportPdf(serviceUri, templateStream);
                report.Process(dataSources);

                while (report.GetStatus() != Report.Status.Ready)
                {
                    Thread.Sleep(1);
                }
            }
        }
        public static void Request7()
        {
            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}\AsyncOutput{1}.pdf", SampleTemplatesFolder, rnd.Next());
            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();
                }
            }
        }