This commit is contained in:
2020-07-20 19:05:28 +00:00
parent 0842ce025e
commit ab65e15d99
7 changed files with 69 additions and 26 deletions

View File

@@ -76,7 +76,7 @@ namespace AyaNova.Biz
//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");
}
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = userId, Message = message, SubscriptionId = 0 };
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = userId, Message = message, NotifySubscriptionId = 0 };
await ct.NotifyEvent.AddAsync(n);
await ct.SaveChangesAsync();
return;
@@ -87,7 +87,7 @@ namespace AyaNova.Biz
var subs = await ct.NotifySubscription.Where(z => z.EventType == eventType).ToListAsync();
foreach (var sub in subs)
{
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = sub.UserId, Message = message, SubscriptionId = sub.Id };
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = sub.UserId, Message = message, NotifySubscriptionId = sub.Id };
await ct.NotifyEvent.AddAsync(n);
}
if (subs.Count > 0)
@@ -148,7 +148,7 @@ namespace AyaNova.Biz
EventType = NotifyEventType.ObjectAge,
UserId = sub.UserId,
ObjectId = newObject.Id,
SubscriptionId = sub.Id,
NotifySubscriptionId = sub.Id,
//TODO: IdValue=((WorkOrder)newObject).WorkorderStatusId
EventDate = DateTime.UtcNow
};
@@ -206,13 +206,16 @@ namespace AyaNova.Biz
if (TagsMatch(newObject.Tags, sub.Tags))
{
//Note: age is set by advance notice which is consulted by CoreJobNotify in it's run so the deliver date is not required here only the reference EventDate to check for deliver
//ObjectAge is determined by subscription AgeValue in combo with the EventDate NotifyEvent parameter which together determines at what age from notifyevent.EventDate it's considered for the event to have officially occured
//However delivery is determined by sub.advancenotice so all three values play a part
//
NotifyEvent n = new NotifyEvent()
{
EventType = NotifyEventType.ObjectAge,
UserId = sub.UserId,
AyaType = newObject.AyaType,
ObjectId = newObject.Id,
SubscriptionId = sub.Id,
NotifySubscriptionId = sub.Id,
EventDate = DateTime.UtcNow
};
await ct.NotifyEvent.AddAsync(n);
@@ -230,7 +233,7 @@ namespace AyaNova.Biz
{
if (TagsMatch(newObject.Tags, sub.Tags))
{
NotifyEvent n = new NotifyEvent() { EventType = NotifyEventType.ObjectCreated, UserId = sub.UserId, AyaType = newObject.AyaType, ObjectId = newObject.Id, SubscriptionId = sub.Id };
NotifyEvent n = new NotifyEvent() { EventType = NotifyEventType.ObjectCreated, UserId = sub.UserId, AyaType = newObject.AyaType, ObjectId = newObject.Id, NotifySubscriptionId = sub.Id };
await ct.NotifyEvent.AddAsync(n);
log.LogTrace($"Adding NotifyEvent: [{n.ToString()}]");
SaveContext = true;
@@ -266,7 +269,7 @@ namespace AyaNova.Biz
// EventType = NotifyEventType.ObjectAge,
// UserId = sub.UserId,
// ObjectId = newObject.Id,
// SubscriptionId = sub.Id,
// NotifySubscriptionId = sub.Id,
// //TODO: IdValue=((WorkOrder)newObject).WorkorderStatusId
// EventDate = DateTime.UtcNow
// };
@@ -333,7 +336,7 @@ namespace AyaNova.Biz
{
if (TagsMatch(newObject.Tags, sub.Tags))
{
NotifyEvent n = new NotifyEvent() { EventType = NotifyEventType.ObjectModified, UserId = sub.UserId, AyaType = newObject.AyaType, ObjectId = newObject.Id, SubscriptionId = sub.Id };
NotifyEvent n = new NotifyEvent() { EventType = NotifyEventType.ObjectModified, UserId = sub.UserId, AyaType = newObject.AyaType, ObjectId = newObject.Id, NotifySubscriptionId = sub.Id };
await ct.NotifyEvent.AddAsync(n);
log.LogTrace($"Adding NotifyEvent: [{n.ToString()}]");
SaveContext = true;
@@ -368,7 +371,7 @@ namespace AyaNova.Biz
if (TagsMatch(newObject.Tags, sub.Tags))
{
//TODO: On deliver should point to history event log record or take from there and insert into delivery message?
NotifyEvent n = new NotifyEvent() { EventType = NotifyEventType.ObjectDeleted, UserId = sub.UserId, AyaType = newObject.AyaType, ObjectId = newObject.Id, SubscriptionId = sub.Id, Message = newObject.Name };
NotifyEvent n = new NotifyEvent() { EventType = NotifyEventType.ObjectDeleted, UserId = sub.UserId, AyaType = newObject.AyaType, ObjectId = newObject.Id, NotifySubscriptionId = sub.Id, Message = newObject.Name };
await ct.NotifyEvent.AddAsync(n);
log.LogTrace($"Adding NotifyEvent: [{n.ToString()}]");
SaveContext = true;