コード例 #1
0
        public async Task <string> CreateBloodChemistryRequisitionReport([FromBody] ToxLabOrderReportData reportInfo)
        {
            string templateName = "BloodChemistryRequisitionReport.trdx";

            if (reportInfo != null && !string.IsNullOrEmpty(reportInfo.LabAbbreviation))
            {
                templateName = "BloodChemistryRequisitionReport" + reportInfo.LabAbbreviation + ".trdx";
            }
            ReportCreator report = new ReportCreator();

            return(await report.CreateToxLabOrderRequisitionReport(reportInfo, templateName));
        }
コード例 #2
0
        public async Task <string> CreateToxLabOrderRequisitionReport(ToxLabOrderReportData dataSource, string templateName = "ToxLabOrderRequisitionReport.trdx")
        {
            string filePath = System.Configuration.ConfigurationManager.AppSettings["ReportTemplateLocation"].ToString() + "\\" + templateName;

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreWhitespace = true;

            Telerik.Reporting.Report report = null;

            using (XmlReader xmlReader = XmlReader.Create(filePath, settings))
            {
                ReportXmlSerializer xmlSerializer = new ReportXmlSerializer();
                report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
            }

            report.DataSource = dataSource;


            ReportProcessor      reportProcessor      = new ReportProcessor();
            InstanceReportSource instanceReportSource = new InstanceReportSource();

            instanceReportSource.ReportDocument = report;
            RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);

            //var reportLocation = ConfigurationManager.AppSettings["ReportTempLocation"];
            //string reportName = dataSource.Id + "_ToxLabOrderRequisition_" + Guid.NewGuid().ToString() + "_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + ".pdf";
            //string reportDestination = Path.Combine(dataSource.FolderPath, reportName);

            //using (FileStream fs = new FileStream(reportDestination, FileMode.Create))
            //{
            //    fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            //}
            //string reportUrl = dataSource.ServerUrl + "/" + reportName;
            //byte[] bytes = result.DocumentBytes;
            //string response = Convert.ToBase64String(bytes);

            return(Convert.ToBase64String(result.DocumentBytes));
        }