-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed so that it should be able to send emails when needed.
- Loading branch information
Showing
4 changed files
with
21 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,18 @@ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Mail; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using System.Xml.Linq; | ||
using Azure; | ||
using Azure.Data.Tables; | ||
using Azure.Storage.Blobs; | ||
using func_nyforvarvslistan; | ||
using Mailjet.Client; | ||
using Mailjet.Client.Resources; | ||
using Microsoft.Azure.WebJobs; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.WindowsAzure.Storage.Table; | ||
using Nest; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using PdfSharpCore.Pdf.Content.Objects; | ||
|
||
public static class NyforvarvslistanFunction | ||
{ | ||
|
@@ -47,11 +39,11 @@ public static class NyforvarvslistanFunction | |
private static readonly ElasticClient Client = new ElasticClient(ConnectionSettings); | ||
|
||
[FunctionName("NyforvarvslistanFunction")] | ||
public static void Run([TimerTrigger("0 0 0 * * *", RunOnStartup = true)] TimerInfo myTimer, ILogger log) | ||
public static void Run([TimerTrigger("0 0 7 * * *", RunOnStartup = true)] TimerInfo myTimer, ILogger log) | ||
{ | ||
try | ||
{ | ||
if (DateTime.UtcNow.Day == 1) | ||
if (DateTime.UtcNow.Day == 14) | ||
{ | ||
SetBackMinervaLastRun(log); | ||
Check warning on line 48 in func-nyforvarvslistan/NyforvarvslistanFunction.cs GitHub Actions / build-and-deploy
Check warning on line 48 in func-nyforvarvslistan/NyforvarvslistanFunction.cs GitHub Actions / build-and-deploy
|
||
Task.Delay(30000).Wait(); | ||
|
@@ -240,7 +232,7 @@ public static void CreateLists(ILogger log) | |
if (generatedFiles.Any()) | ||
{ | ||
SendEmailWithAttachments(generatedFiles.ToArray(), "[email protected]"); | ||
SendEmailWithAttachments(generatedFiles.ToArray(), "[email protected]"); | ||
// SendEmailWithAttachments(generatedFiles.ToArray(), "[email protected]"); | ||
} | ||
} | ||
|
||
|
@@ -350,9 +342,19 @@ private static string getCategoryBasedOnClassification(List<string> classificati | |
|
||
if (category == null) //Use Dewey, and match the Dewey classification to an SAB one, if no SAB classification was found | ||
{ | ||
string filePath; | ||
if (Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID") != null) | ||
{ | ||
// Running in Azure | ||
filePath = Path.Combine(AppContext.BaseDirectory, "Dewey_SAB.txt"); | ||
} | ||
else | ||
{ | ||
// Running locally | ||
filePath = Path.Combine(Environment.CurrentDirectory, "Dewey_SAB.txt"); | ||
} | ||
foreach (var classification in classifications) | ||
{ | ||
string filePath = Path.Combine(Environment.CurrentDirectory, "Dewey_SAB.txt"); | ||
SABDeweyMapper deweyMapper = new SABDeweyMapper(filePath); | ||
var convertedClassification = deweyMapper.getSabCode(classification); | ||
var key = convertedClassification[0].ToString().ToUpper(); | ||
|
@@ -368,6 +370,6 @@ private static string getCategoryBasedOnClassification(List<string> classificati | |
} | ||
} | ||
|
||
return category ?? "Allmänt och blandat"; | ||
return category ?? "Allmänt och blandat"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters