Esempio n. 1
0
        public async Task <IActionResult> GetPDF([FromServices] INodeServices nodeServices, [FromBody]  Object rawdata)
        {
            JSONResponse result  = null;
            var          options = new { format = "letter", orientation = "landscape" };

            for (var i = 0; i <= 2; i++)
            {
                try
                {
                    // execute the Node.js component
                    result = await nodeServices.InvokeAsync <JSONResponse>("./pdf", "schoolbus_permit", rawdata, options);

                    break;
                }
                catch (Exception Ex)
                {
                    if (i < 2)
                    {
                        _logger.LogInformation("exception: retry " + i);
                        await Task.Delay(100 + 100 *i);
                    }
                    else
                    {
                        _logger.LogError("Exception in call of PDF node services. ", Ex);
                    }
                }
            }
            return(new FileContentResult(result.data, "application/pdf"));
        }
Esempio n. 2
0
        public async Task <IActionResult> GetTestPDF([FromServices] INodeServices nodeServices)
        {
            if (_env.IsProduction())
            {
                return(BadRequest("This API is not available outside a development environment."));
            }

            JSONResponse result  = null;
            var          options = new { };

            var testObject = new Dictionary <string, string>();

            testObject.Add("title", "test title");
            testObject.Add("licenceNumber", "123456");
            testObject.Add("businessName", "test biz name");
            testObject.Add("addressLine1", "address 1");
            testObject.Add("addressLine2", "address 2");
            testObject.Add("companyName", "Test Inc.");
            // testObject.Add("permitIssueDate", "date 123");
            // testObject.Add("restrictionsText", "restrictions");

            // execute the Node.js component
            result = await nodeServices.InvokeAsync <JSONResponse>("./pdf", "cannabis_licence", testObject, options);

            return(new FileContentResult(result.data, "application/pdf"));
        }
Esempio n. 3
0
        public async Task <IActionResult> GetPDF([FromServices] INodeServices nodeServices, [FromBody]  Object rawdata)
        {
            JSONResponse result  = null;
            var          options = new { format = "letter", orientation = "landscape" };

            // execute the Node.js component
            result = await nodeServices.InvokeAsync <JSONResponse>("./pdf", "schoolbus_permit", rawdata, options);

            return(new FileContentResult(result.data, "application/pdf"));
        }
Esempio n. 4
0
        public async Task <IActionResult> GetPDF([FromServices] INodeServices nodeServices, [FromBody]  object rawdata, string template)
        {
            JSONResponse result  = null;
            var          options = new { format = "Letter", orientation = "portrait" };

            // execute the Node.js component
            result = await nodeServices.InvokeAsync <JSONResponse>("./pdf", template, rawdata, options);

            return(new FileContentResult(result.data, "application/pdf"));
        }
Esempio n. 5
0
        public async Task <IActionResult> BuildPDF([FromServices] INodeServices nodeServices, [FromBody]  PDFRequest rawdata)
        {
            //JObject options = JObject.Parse(rawdata.options);

            // execute the Node.js component to generate a PDF
            JSONResponse result = await nodeServices.InvokeAsync <JSONResponse>("./pdf", rawdata.html, JObject.Parse(rawdata.options));

            //options = null;

            return(new FileContentResult(result.data, "application/pdf"));
        }
Esempio n. 6
0
        public async Task <IActionResult> BuildPDF([FromServices] INodeServices nodeServices, [FromBody]  PDFRequest rawdata)
        {
            JObject      options = JObject.Parse(rawdata.options);
            JSONResponse result  = null;

            //var options = new { format="letter", orientation= "portrait" };

            // execute the Node.js component to generate a PDF
            result = await nodeServices.InvokeAsync <JSONResponse>("./pdf.js", rawdata.html, options);

            return(new FileContentResult(result.data, "application/pdf"));
        }