This commit is contained in:
2020-07-22 15:30:56 +00:00
parent f9f55c95d7
commit edd58cb380
4 changed files with 34 additions and 6 deletions

View File

@@ -3,6 +3,7 @@ using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using AyaNova.Models;
using AyaNova.Util;
namespace AyaNova.Biz
{
@@ -16,6 +17,9 @@ namespace AyaNova.Biz
{
private static bool NotifyIsRunning = false;
private static ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("CoreJobNotify");
private static DateTime lastRun = DateTime.MinValue;
// private static TimeSpan DELETE_AFTER_AGE = new TimeSpan(90, 0, 0, 0);
// private static TimeSpan RUN_EVERY_INTERVAL = new TimeSpan(0, 2, 0);//once every 2 minutes minimum
@@ -157,7 +161,7 @@ namespace AyaNova.Biz
private static async Task DeliverSMTP(NotifyEvent ne, AyContext ct)
{
log.LogTrace($"DeliverSMTP deliving notify event: {ne}");
throw new System.NotImplementedException("DeliverSMTP: NOT IMPLEMENTED YET");
//todo: //Open question: what to do with failed deliveries?
//we dont' want them piling up but we don't want to just dump them do we?
//it should be only mail ones that fail, not app ones, there's no way for an app delivery to fail as it's just put in a table
@@ -173,7 +177,17 @@ namespace AyaNova.Biz
//todo: abstract out email sending to it's own class maybe or whatever method I choose supports the best
//https://jasonwatmore.com/post/2020/07/15/aspnet-core-3-send-emails-via-smtp-with-mailkit
//https://medium.com/@ffimnsr/sending-email-using-mailkit-in-asp-net-core-web-api-71b946380442
return "ok";
IMailer m = AyaNova.Util.ServiceProviderProvider.Mailer;
try
{
await m.SendEmailAsync(toAddress, "Test from Notification system", "This is a test to confirm notification system is working", ServerGlobalOpsSettingsCache.Notify);
return "ok";
}
catch (Exception ex)
{
return ExceptionUtil.ExtractAllExceptionMessages(ex);
}
}