Ejemplo n.º 1
0
        private async Task <Depencency> Html2PdfHealthcheck()
        {
            Depencency depencency = new Depencency("Html2Pdf", "Detect if pdf is generated");

            try
            {
                var html     = "<p>test/<p>";
                var response = await _nodeServices.InvokeAsync <string>("./Node/htmlToPdf.js", html);

                if (response == null)
                {
                    depencency.SetError("No response from Node");
                }
                else if (response.Length == 0)
                {
                    depencency.SetError("PDF stream is zero length");
                }
                else
                {
                    System.IO.File.Delete(response);
                }
            }
            catch (Exception e)
            {
                depencency.SetError(e);
            }

            return(depencency);
        }
Ejemplo n.º 2
0
        private Depencency AzureAuthenticationHealthCheck()
        {
            Depencency depencency    = new Depencency("Azure authentication", "Get username from User.identity.Name");
            bool       authenticated = User.Identity.IsAuthenticated;

            if (!authenticated)
            {
                depencency.SetError("No user");
            }

            return(depencency);
        }
Ejemplo n.º 3
0
        private async Task <Depencency> Html2PdfHealthcheck()
        {
            var depencency = new Depencency("Html2Pdf", "Detect if pdf is generated");

            try
            {
                var options = new LaunchOptions {
                    Headless = true, Args = new[] { "--no-sandbox" }
                };
                using (var browser = await Puppeteer.LaunchAsync(options))
                {
                    var html = "<p>test/<p>";
                    var page = await browser.NewPageAsync();

                    await page.SetContentAsync(html);

                    var response = await page.PdfStreamAsync();

                    //var response = await _nodeServices.InvokeFromFileAsync<string>("./Node/htmlToPdf.cjs", html);

                    if (response == null)
                    {
                        depencency.SetError("No response from Node");
                    }
                    else if (response.Length == 0)
                    {
                        depencency.SetError("PDF stream is zero length");
                    }
                }
            }
            catch (Exception e)
            {
                depencency.SetError(e);
            }

            return(depencency);
        }