示例#1
0
        private static void WriteInDocument(Document document, ReportResponseViewModel reportModel)
        {
            var sec = document.Sections.AddSection();

            sec.AddParagraph("My test complain report.");
            sec.AddParagraph($"Complain Id: {reportModel.ComplainId}");
            sec.AddParagraph($"User owner name: {reportModel.DealOwnerUsername}");
            sec.AddParagraph($"User creditor name: {reportModel.DealCreditorUsername}");
            sec.AddParagraph($"Date of creating: {reportModel.DateOfCreating.ToShortDateString()}");
            sec.AddParagraph($"Complain: {reportModel.ComplainText}");
        }
示例#2
0
        public async Task <IHttpActionResult> ComplainPdf(string complainId)
        {
            ReportResponseViewModel report = await _repo.GetReport(complainId);

            if (report == null)
            {
                return(BadRequest($"Complain {complainId} not found."));
            }

            return(Ok(report));
        }
示例#3
0
        public static string CreateHtml(ReportResponseViewModel report, string xsltTemplatePath)
        {
            string xmlPath  = HostingEnvironment.MapPath($"\\App_Data\\temp-{report.ComplainId}.xml");
            string htmlPath = HostingEnvironment.MapPath($"\\App_Data\\temp-{report.ComplainId}.html");

            var formatter = new XmlSerializer(typeof(ReportResponseViewModel));

            using (var fs = new FileStream(xmlPath, FileMode.Create))
            {
                formatter.Serialize(fs, report);
            }

            var xmlDoc       = new XPathDocument(xmlPath);
            var xslTransform = new XslCompiledTransform();

            xslTransform.Load(xsltTemplatePath);
            xslTransform.Transform(xmlPath, htmlPath);

            return(File.ReadAllText(htmlPath));
        }