This commit is contained in:
@@ -107,7 +107,9 @@ namespace AyaNova.Biz
|
|||||||
BizMetrics=48,
|
BizMetrics=48,
|
||||||
Backup=49,
|
Backup=49,
|
||||||
Notification=50,
|
Notification=50,
|
||||||
NotifySubscription=51
|
NotifySubscription=51,
|
||||||
|
Reminder = 52,
|
||||||
|
UnitMeterReading = 53
|
||||||
|
|
||||||
|
|
||||||
//NOTE: New objects added here need to also be added to the following classes:
|
//NOTE: New objects added here need to also be added to the following classes:
|
||||||
|
|||||||
@@ -128,13 +128,45 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
case AyaEvent.Created:
|
case AyaEvent.Created:
|
||||||
//------------------------------
|
//------------------------------
|
||||||
//Specific created related subscriptions for AyaType
|
// AyaType Specific created related subscriptions
|
||||||
|
//
|
||||||
switch (newObject.AyaType)
|
switch (newObject.AyaType)
|
||||||
{
|
{
|
||||||
//AyaTypes with their own special notification related events
|
//AyaTypes with their own special notification related events
|
||||||
case AyaType.WorkOrder:
|
case AyaType.WorkOrder:
|
||||||
{
|
{
|
||||||
//WorkorderStatusChange
|
//WorkorderStatusChange
|
||||||
|
{
|
||||||
|
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.WorkorderStatusChange).ToListAsync();
|
||||||
|
foreach (var sub in subs)
|
||||||
|
{
|
||||||
|
if (TagsMatch(newObject.Tags, sub.Tags))
|
||||||
|
{
|
||||||
|
//Note: this is a "deadman switch" event
|
||||||
|
//it will deliver if it's not removed before the age selected
|
||||||
|
// 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
|
||||||
|
throw new System.NotImplementedException("Awaiting workorder object completion");
|
||||||
|
NotifyEvent n = new NotifyEvent()
|
||||||
|
{
|
||||||
|
EventType = NotifyEventType.ObjectAge,
|
||||||
|
UserId = sub.UserId,
|
||||||
|
ObjectId = newObject.Id,
|
||||||
|
SubscriptionId = sub.Id,
|
||||||
|
//TODO: IdValue=((WorkOrder)newObject).WorkorderStatusId
|
||||||
|
EventDate = DateTime.UtcNow
|
||||||
|
};
|
||||||
|
await ct.NotifyEvent.AddAsync(n);
|
||||||
|
log.LogTrace($"Adding NotifyEvent: [{n.ToString()}]");
|
||||||
|
|
||||||
|
//Note: in same event but for MODIFY below if need to delete old notifyevent here
|
||||||
|
// var deleteEventList = await ct.NotifyEvent.Where(z => z.ObjectId == ev.ObjectId && z.AyaType == ev.AyaType).ToListAsync();
|
||||||
|
// ct.NotifyEvent.RemoveRange(deleteEventList);
|
||||||
|
|
||||||
|
|
||||||
|
SaveContext = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//ScheduledOnWorkorder
|
//ScheduledOnWorkorder
|
||||||
//ScheduledOnWorkorderImminent
|
//ScheduledOnWorkorderImminent
|
||||||
//tentative WorkorderCloseByPassed
|
//tentative WorkorderCloseByPassed
|
||||||
@@ -151,21 +183,41 @@ namespace AyaNova.Biz
|
|||||||
//QuoteStatusChange
|
//QuoteStatusChange
|
||||||
//QuoteStatusAge
|
//QuoteStatusAge
|
||||||
break;
|
break;
|
||||||
|
case AyaType.Contract:
|
||||||
|
//ContractExpiring
|
||||||
|
break;
|
||||||
|
case AyaType.Reminder:
|
||||||
|
//ReminderImminent
|
||||||
|
break;
|
||||||
|
case AyaType.Unit:
|
||||||
|
//UnitWarrantyExpiry
|
||||||
|
break;
|
||||||
|
case AyaType.UnitMeterReading:
|
||||||
|
//UnitMeterReadingMultipleExceeded
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
//ObjectAge
|
//ObjectAge
|
||||||
|
//
|
||||||
{
|
{
|
||||||
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ObjectAge && z.AyaType == newObject.AyaType).ToListAsync();
|
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ObjectAge && z.AyaType == newObject.AyaType).ToListAsync();
|
||||||
foreach (var sub in subs)
|
foreach (var sub in subs)
|
||||||
{
|
{
|
||||||
if (TagsMatch(newObject.Tags, sub.Tags))
|
if (TagsMatch(newObject.Tags, sub.Tags))
|
||||||
{
|
{
|
||||||
NotifyEvent n = new NotifyEvent() {
|
//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
|
||||||
EventType = NotifyEventType.ObjectAge, UserId = sub.UserId, AyaType = newObject.AyaType, ObjectId = newObject.Id,
|
NotifyEvent n = new NotifyEvent()
|
||||||
SubscriptionId = sub.Id, EventDate=DateTime.UtcNow
|
{
|
||||||
};
|
EventType = NotifyEventType.ObjectAge,
|
||||||
|
UserId = sub.UserId,
|
||||||
|
AyaType = newObject.AyaType,
|
||||||
|
ObjectId = newObject.Id,
|
||||||
|
SubscriptionId = sub.Id,
|
||||||
|
EventDate = DateTime.UtcNow
|
||||||
|
};
|
||||||
await ct.NotifyEvent.AddAsync(n);
|
await ct.NotifyEvent.AddAsync(n);
|
||||||
log.LogTrace($"Adding NotifyEvent: [{n.ToString()}]");
|
log.LogTrace($"Adding NotifyEvent: [{n.ToString()}]");
|
||||||
SaveContext = true;
|
SaveContext = true;
|
||||||
@@ -173,7 +225,8 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
//General ObjectCreated subscriptions
|
//ObjectCreated
|
||||||
|
//
|
||||||
{
|
{
|
||||||
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ObjectCreated && z.AyaType == newObject.AyaType).ToListAsync();
|
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ObjectCreated && z.AyaType == newObject.AyaType).ToListAsync();
|
||||||
foreach (var sub in subs)
|
foreach (var sub in subs)
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ namespace AyaNova.Biz
|
|||||||
public enum NotifyEventType : int
|
public enum NotifyEventType : int
|
||||||
{
|
{
|
||||||
//see core-notifications.txt spec doc for a bit more info on each type (they are named a little bit differently)
|
//see core-notifications.txt spec doc for a bit more info on each type (they are named a little bit differently)
|
||||||
|
//#### NOTE: once event is coded in NotifyEventProcessor I'll mark it with a * in the comment so I know if I miss any
|
||||||
ObjectDeleted = 1,//Deletion of any object of conditional specific AyaType and optionally conditional tags
|
ObjectDeleted = 1,//Deletion of any object of conditional specific AyaType and optionally conditional tags
|
||||||
ObjectCreated = 2,//creation of any object of conditional specific AyaType and optionally conditional tags
|
ObjectCreated = 2,//* creation of any object of conditional specific AyaType and optionally conditional tags
|
||||||
ObjectModified = 3,//Modification / update of any kind of any object of conditional specific AyaType and optionally conditional tags
|
ObjectModified = 3,//Modification / update of any kind of any object of conditional specific AyaType and optionally conditional tags
|
||||||
WorkorderStatusChange = 4,//Workorder object, any *change* of status including from no status (new) to a specific conditional status ID value
|
WorkorderStatusChange = 4,//Workorder object, any *change* of status including from no status (new) to a specific conditional status ID value
|
||||||
ContractExpiring = 5,//Contract object, aged notification with optional advance notice for expiration date of contract. Customer version and User version deliveries possible.
|
ContractExpiring = 5,//Contract object, aged notification with optional advance notice for expiration date of contract. Customer version and User version deliveries possible.
|
||||||
@@ -19,7 +19,7 @@ namespace AyaNova.Biz
|
|||||||
CSRRejected = 7,//CustomerServiceRequest object, saved with REJECTED status, delivered to Customer only
|
CSRRejected = 7,//CustomerServiceRequest object, saved with REJECTED status, delivered to Customer only
|
||||||
DEPRECATED_8 = 8,//UNUSED, FILL IN LATER WITH NEXT NEW NOTIFICATION EVENT
|
DEPRECATED_8 = 8,//UNUSED, FILL IN LATER WITH NEXT NEW NOTIFICATION EVENT
|
||||||
QuoteStatusChange = 9,//Quote object, any *change* of status including from no status (new) to a specific conditional status ID value
|
QuoteStatusChange = 9,//Quote object, any *change* of status including from no status (new) to a specific conditional status ID value
|
||||||
ObjectAge = 10,//Any object, Age (conditional on AgeValue) after creation event of any object of conditional specific AyaType and optionally conditional tags
|
ObjectAge = 10,//* Any object, Age (conditional on AgeValue) after creation event of any object of conditional specific AyaType and optionally conditional tags
|
||||||
ServiceBankDepleted = 11,//ServiceBank object, any change to balance triggers this check, conditional on decvalue as remaining balance left to trigger this notification
|
ServiceBankDepleted = 11,//ServiceBank object, any change to balance triggers this check, conditional on decvalue as remaining balance left to trigger this notification
|
||||||
ReminderImminent = 12,//Reminder object, Advance notice setting tag conditional
|
ReminderImminent = 12,//Reminder object, Advance notice setting tag conditional
|
||||||
ScheduledOnWorkorder = 13,//Workorder / WorkorderItemScheduledUser object, instant notification when current user is scheduled on a service workorder
|
ScheduledOnWorkorder = 13,//Workorder / WorkorderItemScheduledUser object, instant notification when current user is scheduled on a service workorder
|
||||||
|
|||||||
Reference in New Issue
Block a user