This commit is contained in:
@@ -34,7 +34,7 @@ namespace AyaNova.Biz
|
||||
CustomerServiceImminent = 21,//* Workorder / WorkorderItemScheduledUser object, notice that scheduled service is due, can set advance notice, CUSTOMER gets delivery
|
||||
PartRequested = 22,//?? HOL UP, isn't this covered by objectCreated?* Workorder object / workorderitempartrequest created tag filterable
|
||||
WorkorderTotalExceedsThreshold = 23,//* "the Andy" Workorder updated / created, based on balance total so conditional on DecValue
|
||||
WorkorderStatusAge = 24,//* Workorder object Created / Updated, conditional on exact status selected IdValue, Tags conditional, advance notice can be set
|
||||
WorkorderStatusAge = 24,//* Workorder STATUS unchanged for set time (stuck in state), conditional on: Duration (how long stuck), exact status selected IdValue, Tags. Advance notice can NOT be set
|
||||
UnitWarrantyExpiry = 25,//* Unit object created, advance notice can be used, tag conditional
|
||||
UnitMeterReadingMultipleExceeded = 26,//* UnitMeterReading object, Created, conditional on DecValue as the Multiple threshold, if passed then notifies
|
||||
GeneralNotification = 27,//* NO OBJECT old quick notification, refers now to any direct text notification internal or user to user used for system notifications (default delivers in app but user can opt to also get email)
|
||||
|
||||
@@ -983,7 +983,7 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
//STANDARD EVENTS FOR ALL OBJECTS
|
||||
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
|
||||
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);//Note: will properly handle all delete events and event removal if deleted
|
||||
|
||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||
WorkOrder oProposed = (WorkOrder)proposedObj;
|
||||
@@ -998,24 +998,19 @@ namespace AyaNova.Biz
|
||||
|
||||
#region COMPLETE BY OVERDUE
|
||||
|
||||
//COMPLETE BY OVERDUE
|
||||
if (ayaEvent == AyaEvent.Created && oProposed.CompleteByDate != null)
|
||||
{// WorkorderCompletedStatusOverdue Created here on workorder creation for any subscribers
|
||||
// State notify event processor below has more notes and details and will remove this event if set to a completed state
|
||||
|
||||
|
||||
{
|
||||
//WorkorderCompletedStatusOverdue Created here on workorder creation for any subscribers
|
||||
//State notify event processor below has more notes and details and will remove this event if set to a completed state
|
||||
//If new and has completeby then can do notification
|
||||
|
||||
|
||||
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.WorkorderCompletedStatusOverdue).ToListAsync();
|
||||
|
||||
foreach (var sub in subs)
|
||||
{
|
||||
//not for inactive users
|
||||
if (!await UserBiz.UserIsActive(sub.UserId)) continue;
|
||||
|
||||
//Tag match? (will be true if no sub tags so always safe to call this)
|
||||
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(o.Tags, sub.Tags))
|
||||
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(proposedObj.Tags, sub.Tags))
|
||||
{
|
||||
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
@@ -1240,15 +1235,15 @@ namespace AyaNova.Biz
|
||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||
//WorkorderStatusChange = 4,//*Workorder object, any NEW status set. Conditions: specific status ID value only (no generic any status allowed), Workorder TAGS
|
||||
//WorkorderCompletedStatusOverdue = 15,//* Workorder object not set to a "Completed" flagged workorder status type in selected time span from creation of workorderWorkorderSetToCompletedStatus
|
||||
//WorkorderStatusAge = 24,//* Workorder object Created / Updated, conditional on exact status selected IdValue, Tags conditional, advance notice can be set
|
||||
//WorkorderStatusAge = 24,//* Workorder STATUS unchanged for set time (stuck in state), conditional on: Duration (how long stuck), exact status selected IdValue, Tags. Advance notice can NOT be set
|
||||
|
||||
//NOTE: ID, state notifications are for the Workorder, not the state itself unlike other objects, so use the WO type and ID here for all notifications
|
||||
|
||||
WorkOrderState o = (WorkOrderState)proposedObj;
|
||||
WorkOrderStatus wos = await ct.WorkOrderStatus.AsNoTracking().FirstOrDefaultAsync(x => x.Id == o.WorkOrderStatusId);
|
||||
|
||||
WorkOrder wo = await ct.WorkOrder.AsNoTracking().FirstOrDefaultAsync(x => x.Id == o.WorkOrderId);
|
||||
var WorkorderName = wo.Serial.ToString();
|
||||
// WorkOrder wo = await ct.WorkOrder.AsNoTracking().FirstOrDefaultAsync(x => x.Id == o.WorkOrderId);
|
||||
string WorkorderName = (await ct.WorkOrder.AsNoTracking().Where(x => x.Id == o.WorkOrderId).Select(x => x.Serial).FirstOrDefaultAsync()).ToString();
|
||||
|
||||
//## DELETED EVENTS
|
||||
//A state cannot be deleted so nothing to handle that is required
|
||||
@@ -1275,7 +1270,37 @@ namespace AyaNova.Biz
|
||||
if (!await UserBiz.UserIsActive(sub.UserId)) continue;
|
||||
|
||||
//Tag match? (will be true if no sub tags so always safe to call this)
|
||||
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(wo.Tags, sub.Tags))
|
||||
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(proposedObj.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.WorkorderStatusChange,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.WorkOrder,
|
||||
ObjectId = o.WorkOrderId,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = WorkorderName
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//workorder status change event
|
||||
|
||||
//# STATUS AGE
|
||||
{
|
||||
//WorkorderStatusAge = 24,//* Workorder STATUS unchanged for set time (stuck in state), conditional on: Duration (how long stuck), exact status selected IdValue, Tags. Advance notice can NOT be set
|
||||
//Always clear any old ones for this object as they are all irrelevant the moment the state has changed:
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, proposedObj.Id, NotifyEventType.WorkorderStatusAge);
|
||||
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.WorkorderStatusAge && z.IdValue == o.WorkOrderStatusId).ToListAsync();
|
||||
foreach (var sub in subs)
|
||||
{
|
||||
//not for inactive users
|
||||
if (!await UserBiz.UserIsActive(sub.UserId)) continue;
|
||||
|
||||
//Tag match? (will be true if no sub tags so always safe to call this)
|
||||
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(proposedObj.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user