This commit is contained in:
2020-07-23 21:57:31 +00:00
parent 9b703dbd60
commit e6545c4d35
4 changed files with 41 additions and 18 deletions

View File

@@ -39,7 +39,7 @@ namespace AyaNova.Biz
//This handles general notification events not requiring a decision or tied to an object that are basically just a immediate message to the user
//e.g. ops problems, DefaultNotification, NotifyHealthCheck etc
//e.g. ops problems, GeneralNotification, NotifyHealthCheck etc
//optional user id to send directly to them
internal static async Task AddGeneralNotifyEvent(NotifyEventType eventType, string message, Exception except = null, long userId = 0)
{
@@ -48,7 +48,7 @@ namespace AyaNova.Biz
switch (eventType)
{
case NotifyEventType.BackupStatus:
case NotifyEventType.DefaultNotification:
case NotifyEventType.GeneralNotification:
case NotifyEventType.NotifyHealthCheck://created by job processor itself
case NotifyEventType.ServerOperationsProblem:
break;
@@ -56,7 +56,7 @@ namespace AyaNova.Biz
throw (new System.NotSupportedException($"NotifyEventProcessor:AddGeneralNotifyEvent - Type of event {eventType} is unexpected and not supported"));
}
if (eventType != NotifyEventType.DefaultNotification && userId != 0)
if (eventType != NotifyEventType.GeneralNotification && userId != 0)
{
throw (new System.NotSupportedException($"NotifyEventProcessor:AddGeneralNotifyEvent - event {eventType} was specified with user id {userId} which is unexpected and not supported"));
}
@@ -67,14 +67,14 @@ namespace AyaNova.Biz
using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext)
{
//Default notification goes to a specific user only
//General notification goes to a specific user only
//no need to consult subscriptions
if (eventType == NotifyEventType.DefaultNotification)
if (eventType == NotifyEventType.GeneralNotification)
{
if (userId == 0)
{
//this will likely be a development error, not a production error so no need to log etc
throw new System.ArgumentException("NotifyEventProcessor:AddGeneralNotifyEvent: DefaultNotification requires a user id but none was specified");
throw new System.ArgumentException("NotifyEventProcessor:AddGeneralNotifyEvent: GeneralNotification requires a user id but none was specified");
}
var UserName = await ct.User.Where(z => z.Id == userId).Select(z => z.Name).FirstOrDefaultAsync();
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = userId, Message = message, NotifySubscriptionId = 0, Name = UserName };