From 0ac2b2c3113267b699d9b2e00925306f702bbb31 Mon Sep 17 00:00:00 2001 From: erikmtm <116561386+erikmtm@users.noreply.github.com> Date: Thu, 15 Aug 2024 12:39:37 +0200 Subject: [PATCH] Mer temppath. --- .../NyforvarvslistanFunction.cs | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/func-nyforvarvslistan/NyforvarvslistanFunction.cs b/func-nyforvarvslistan/NyforvarvslistanFunction.cs index c8ceae3..478b65f 100644 --- a/func-nyforvarvslistan/NyforvarvslistanFunction.cs +++ b/func-nyforvarvslistan/NyforvarvslistanFunction.cs @@ -107,7 +107,7 @@ private static async Task SetBackMinervaLastRun(ILogger log) throw; // Rethrow the exception to be caught by the outer catch block if needed } } - public static void CreateLists(ILogger log) + public static void CreateLists(ILogger log) { log.LogInformation($"Function triggered at: {DateTime.Now}"); // var startDate = Dates.StartOfPreviousMonth.ToElasticsearchFormat(); @@ -181,6 +181,30 @@ public static void CreateLists(ILogger log) //var pdfGenerator = new PdfGenerator(); //var docxGenerator = new DocxGenerator(); var xmlGenerator = new XmlGenerator(); + if (Environment.GetEnvironmentVariable("WEBSITE_CONTENTSHARE") != null) + { + if (talkingBooks.Any()) + { + string tempPath = Path.GetTempPath(); + + xmlGenerator.SaveToFile(talkingBooks, Path.Combine(tempPath, "nyf-tb-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml")); + xmlGenerator.SaveToFile(talkingBooks, Path.Combine(tempPath, "nyf-tb-no-links-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml")); + xmlGenerator.SaveToFile(talkingBooks, Path.Combine(tempPath, "nyf-tb-no-links-swedishonly-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml")); + + // Additional processing, such as uploading to Blob Storage, goes here + } + + if (brailleBooks.Any()) + { + string tempPath = Path.GetTempPath(); + + xmlGenerator.SaveToFile(brailleBooks, Path.Combine(tempPath, "nyf-punkt-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml")); + xmlGenerator.SaveToFile(brailleBooks, Path.Combine(tempPath, "nyf-punkt-no-links-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml")); + xmlGenerator.SaveToFile(brailleBooks, Path.Combine(tempPath, "nyf-punkt-no-links-swedishonly-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml")); + + // Additional processing, such as uploading to Blob Storage, goes here + } + } else { if (talkingBooks.Any()) { @@ -205,6 +229,7 @@ public static void CreateLists(ILogger log) // pdfGenerator.GeneratePdf(brailleBookHtml, "brailleBook-" + Dates.GetCurrentYear(Dates.StartOfPreviousMonth) + "-" + Dates.GetMonthNameInSwedish(Dates.StartOfPreviousMonth) + ".pdf"); // docxGenerator.GenerateDocx("brailleBook-" + Dates.GetCurrentYear(Dates.StartOfPreviousMonth) + "-" + Dates.GetMonthNameInSwedish(Dates.StartOfPreviousMonth) + ".docx", books); } + } List generatedFiles = new List(); if (Environment.GetEnvironmentVariable("WEBSITE_CONTENTSHARE") != null) {