This commit is contained in:
@@ -75,6 +75,10 @@ namespace AyaNova
|
|||||||
_newLog.LogDebug("ServerState service");
|
_newLog.LogDebug("ServerState service");
|
||||||
services.AddSingleton(new AyaNova.Api.ControllerHelpers.ApiServerState());
|
services.AddSingleton(new AyaNova.Api.ControllerHelpers.ApiServerState());
|
||||||
|
|
||||||
|
|
||||||
|
_newLog.LogDebug("Mail service");
|
||||||
|
services.AddSingleton<IMailer,Mailer>();
|
||||||
|
|
||||||
//Init controllers
|
//Init controllers
|
||||||
_newLog.LogDebug("Controllers");
|
_newLog.LogDebug("Controllers");
|
||||||
var MvcBuilder = services.AddControllers(config =>
|
var MvcBuilder = services.AddControllers(config =>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using AyaNova.Models;
|
using AyaNova.Models;
|
||||||
|
using AyaNova.Util;
|
||||||
|
|
||||||
namespace AyaNova.Biz
|
namespace AyaNova.Biz
|
||||||
{
|
{
|
||||||
@@ -16,6 +17,9 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
private static bool NotifyIsRunning = false;
|
private static bool NotifyIsRunning = false;
|
||||||
private static ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("CoreJobNotify");
|
private static ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("CoreJobNotify");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static DateTime lastRun = DateTime.MinValue;
|
private static DateTime lastRun = DateTime.MinValue;
|
||||||
// private static TimeSpan DELETE_AFTER_AGE = new TimeSpan(90, 0, 0, 0);
|
// 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
|
// 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)
|
private static async Task DeliverSMTP(NotifyEvent ne, AyContext ct)
|
||||||
{
|
{
|
||||||
log.LogTrace($"DeliverSMTP deliving notify event: {ne}");
|
log.LogTrace($"DeliverSMTP deliving notify event: {ne}");
|
||||||
throw new System.NotImplementedException("DeliverSMTP: NOT IMPLEMENTED YET");
|
|
||||||
//todo: //Open question: what to do with failed deliveries?
|
//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?
|
//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
|
//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
|
//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://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
|
//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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace AyaNova.Util
|
|||||||
internal static bool BOOTING { get; set; }
|
internal static bool BOOTING { get; set; }
|
||||||
|
|
||||||
internal static GlobalOpsBackupSettings Backup { get; set; }
|
internal static GlobalOpsBackupSettings Backup { get; set; }
|
||||||
internal static GlobalOpsNotificationSettings Notify {get;set;}
|
internal static GlobalOpsNotificationSettings Notify { get; set; }
|
||||||
internal static DateTime NextBackup { get; set; }
|
internal static DateTime NextBackup { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Populate and / or create the settings
|
/// Populate and / or create the settings
|
||||||
@@ -35,10 +35,12 @@ namespace AyaNova.Util
|
|||||||
SetNextBackup();
|
SetNextBackup();
|
||||||
|
|
||||||
|
|
||||||
Notify=ct.GlobalOpsNotificationSettings.FirstOrDefault(z=>z.Id==1);
|
Notify = ct.GlobalOpsNotificationSettings.FirstOrDefault(z => z.Id == 1);
|
||||||
if(Notify==null)
|
if (Notify == null)
|
||||||
{
|
{
|
||||||
Notify=new GlobalOpsNotificationSettings();
|
Notify = new GlobalOpsNotificationSettings();
|
||||||
|
ct.GlobalOpsNotificationSettings.Add(Notify);
|
||||||
|
ct.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ namespace AyaNova.Util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static AyaNova.Util.IMailer Mailer
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Scope.ServiceProvider.GetRequiredService<AyaNova.Util.IMailer>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1
|
// https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1
|
||||||
internal static System.Net.Http.IHttpClientFactory HttpClientFactory
|
internal static System.Net.Http.IHttpClientFactory HttpClientFactory
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user