Skip to content

Commit

Permalink
Fixed temp storage
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohansson committed Aug 15, 2024
1 parent 6fd0d96 commit e84c64e
Showing 1 changed file with 50 additions and 16 deletions.
66 changes: 50 additions & 16 deletions func-nyforvarvslistan/NyforvarvslistanFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,31 +206,65 @@ public static void CreateLists(ILogger log)
// docxGenerator.GenerateDocx("brailleBook-" + Dates.GetCurrentYear(Dates.StartOfPreviousMonth) + "-" + Dates.GetMonthNameInSwedish(Dates.StartOfPreviousMonth) + ".docx", books);
}
List<string> generatedFiles = new List<string>();

if (talkingBooks.Any())
if (Environment.GetEnvironmentVariable("WEBSITE_CONTENTSHARE") != null)
{
string talkingBooksFile = "nyf-tb-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml";
generatedFiles.Add(talkingBooksFile);
if (talkingBooks.Any())
{
string tempPath = Path.GetTempPath();

string talkingBooksNoLinksFile = "nyf-tb-no-links-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml";
generatedFiles.Add(talkingBooksNoLinksFile);
string talkingBooksFile = Path.Combine(tempPath, $"nyf-tb-{DateTime.Now:yyyy-MM}.xml");
generatedFiles.Add(talkingBooksFile);

string talkingBooksSwedishOnlyFile = "nyf-tb-no-links-swedishonly-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml";
generatedFiles.Add(talkingBooksSwedishOnlyFile);
}
string talkingBooksNoLinksFile = Path.Combine(tempPath, $"nyf-tb-no-links-{DateTime.Now:yyyy-MM}.xml");
generatedFiles.Add(talkingBooksNoLinksFile);

if (brailleBooks.Any())
string talkingBooksSwedishOnlyFile = Path.Combine(tempPath, $"nyf-tb-no-links-swedishonly-{DateTime.Now:yyyy-MM}.xml");
generatedFiles.Add(talkingBooksSwedishOnlyFile);
}

if (brailleBooks.Any())
{
string tempPath = Path.GetTempPath();

string brailleBooksFile = Path.Combine(tempPath, $"nyf-punkt-{DateTime.Now:yyyy-MM}.xml");
generatedFiles.Add(brailleBooksFile);

string brailleBooksNoLinksFile = Path.Combine(tempPath, $"nyf-punkt-no-links-{DateTime.Now:yyyy-MM}.xml");
generatedFiles.Add(brailleBooksNoLinksFile);

string brailleBooksSwedishOnlyFile = Path.Combine(tempPath, $"nyf-punkt-no-links-swedishonly-{DateTime.Now:yyyy-MM}.xml");
generatedFiles.Add(brailleBooksSwedishOnlyFile);
}
}
else
{
string brailleBooksFile = "nyf-punkt-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml";
generatedFiles.Add(brailleBooksFile);
if (talkingBooks.Any())
{
string talkingBooksFile = "nyf-tb-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml";
generatedFiles.Add(talkingBooksFile);

string brailleBooksNoLinksFile = "nyf-punkt-no-links-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml";
generatedFiles.Add(brailleBooksNoLinksFile);
string talkingBooksNoLinksFile = "nyf-tb-no-links-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml";
generatedFiles.Add(talkingBooksNoLinksFile);

string brailleBooksSwedishOnlyFile = "nyf-punkt-no-links-swedishonly-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml";
generatedFiles.Add(brailleBooksSwedishOnlyFile);
string talkingBooksSwedishOnlyFile = "nyf-tb-no-links-swedishonly-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml";
generatedFiles.Add(talkingBooksSwedishOnlyFile);
}

if (brailleBooks.Any())
{
string brailleBooksFile = "nyf-punkt-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml";
generatedFiles.Add(brailleBooksFile);

string brailleBooksNoLinksFile = "nyf-punkt-no-links-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml";
generatedFiles.Add(brailleBooksNoLinksFile);

string brailleBooksSwedishOnlyFile = "nyf-punkt-no-links-swedishonly-" + DateTime.Now.Year + "-" + DateTime.Now.Month.ToString("00") + ".xml";
generatedFiles.Add(brailleBooksSwedishOnlyFile);
}
}



if (generatedFiles.Any())
{
SendEmailWithAttachments(generatedFiles.ToArray(), "[email protected]");
Expand Down

0 comments on commit e84c64e

Please sign in to comment.