This commit is contained in:
@@ -993,15 +993,7 @@ namespace AyaNova.Biz
|
||||
|
||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||
|
||||
// PM oCurrent = null;
|
||||
// bool SameTags = true;
|
||||
// if (currentObj != null)
|
||||
// {
|
||||
// oCurrent = (PM)currentObj;
|
||||
// SameTags = NotifyEventHelper.TwoObjectsHaveSameTags(proposedObj.Tags, currentObj.Tags);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
}//end of process notifications
|
||||
|
||||
@@ -1382,13 +1374,13 @@ namespace AyaNova.Biz
|
||||
// await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.ContractExpiring);
|
||||
|
||||
|
||||
//## CREATED / MODIFIED EVENTS
|
||||
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
// //## CREATED / MODIFIED EVENTS
|
||||
// if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
||||
// {
|
||||
|
||||
//todo: fix etc, tons of shit here incoming
|
||||
// //todo: fix etc, tons of shit here incoming
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}//end of process notifications
|
||||
|
||||
@@ -2862,147 +2854,6 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
//## CREATED
|
||||
if (ayaEvent == AyaEvent.Created)
|
||||
{
|
||||
//OutsideServiceOverdue
|
||||
if (oProposed.ETADate != null)
|
||||
{
|
||||
//Conditions: tags + time delayed eta value
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.OutsideServiceOverdue).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.OutsideServiceOverdue,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.PMItemOutsideService,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
EventDate = (DateTime)oProposed.ETADate,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//OutsideServiceOverdue
|
||||
|
||||
//OutsideServiceReceived (here because it's possible a outside service is entered new with both an eta and received date if entered after the fact)
|
||||
if (oProposed.ReturnDate != null)
|
||||
{
|
||||
//Clear overdue ones as it's now received
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, proposedObj.Id, NotifyEventType.OutsideServiceOverdue);
|
||||
|
||||
//Conditions: tags
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.OutsideServiceReceived).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.OutsideServiceReceived,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.PMItemOutsideService,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//OutsideServiceReceived
|
||||
}
|
||||
|
||||
//## MODIFIED
|
||||
if (ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
PMItemOutsideService oCurrent = (PMItemOutsideService)currentObj;
|
||||
|
||||
//OutsideServiceOverdue
|
||||
//if modified then remove any potential prior ones in case irrelevant
|
||||
if (oProposed.ETADate != oCurrent.ETADate)
|
||||
{
|
||||
//eta changed, so first of all remove any prior ones
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, proposedObj.Id, NotifyEventType.OutsideServiceOverdue);
|
||||
//now can go ahead and add back again as appropriate
|
||||
if (oProposed.ETADate != null)
|
||||
{
|
||||
//Conditions: tags + time delayed eta value
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.OutsideServiceOverdue).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.OutsideServiceOverdue,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.PMItemOutsideService,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
EventDate = (DateTime)oProposed.ETADate,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//OutsideServiceOverdue
|
||||
}
|
||||
|
||||
//OutsideServiceReceived
|
||||
if (oProposed.ReturnDate != oCurrent.ReturnDate && oProposed.ReturnDate != null)//note that this is an instant notification type so no need to clear older ones like above which is time delayed
|
||||
{
|
||||
//Clear overdue ones as it's now received
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, proposedObj.Id, NotifyEventType.OutsideServiceOverdue);
|
||||
|
||||
//Conditions: tags
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.OutsideServiceReceived).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.OutsideServiceReceived,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.PMItemOutsideService,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//OutsideServiceReceived
|
||||
}
|
||||
|
||||
}//end of process notifications
|
||||
|
||||
|
||||
@@ -3733,122 +3584,6 @@ namespace AyaNova.Biz
|
||||
|
||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||
|
||||
|
||||
//## CREATED / UPDATED - ScheduledOnWorkorder event
|
||||
//Note: scheduled on quote is immediate so same process regardless if modified or updated
|
||||
//because modified changes nearly all affect user so decision is just send it no matter what as any difference is enough to send
|
||||
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
//this block is entirely about //ScheduledOnWorkorder event
|
||||
|
||||
if (oProposed.UserId != null)
|
||||
{
|
||||
//Conditions: userid match and tags
|
||||
//delivery is immediate so no need to remove old ones of this kind
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.ScheduledOnWorkorder && z.UserId == oProposed.UserId).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.ScheduledOnWorkorder,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.PMItemScheduledUser,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//ScheduledOnWorkorder
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//## CREATED
|
||||
if (ayaEvent == AyaEvent.Created)
|
||||
{
|
||||
//ScheduledOnWorkorderImminent
|
||||
if (oProposed.UserId != null && oProposed.StartDate != null)
|
||||
{
|
||||
//Conditions: userid match and tags + time delayed age value
|
||||
//delivery is delayed so need to remove old ones of this kind on update
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.ScheduledOnWorkorderImminent && z.UserId == oProposed.UserId).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.ScheduledOnWorkorderImminent,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.PMItemScheduledUser,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
EventDate = (DateTime)oProposed.StartDate,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//ScheduledOnWorkorderImminent
|
||||
}
|
||||
|
||||
|
||||
|
||||
//## MODIFIED
|
||||
if (ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
|
||||
//ScheduledOnWorkorderImminent
|
||||
//Always clear any old ones for this object as they are all irrelevant the moment changed:
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, proposedObj.Id, NotifyEventType.ScheduledOnWorkorderImminent);
|
||||
|
||||
if (oProposed.UserId != null && oProposed.StartDate != null)
|
||||
{
|
||||
//Conditions: userid match and tags + time delayed age value
|
||||
//delivery is delayed so need to remove old ones of this kind on update
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.ScheduledOnWorkorderImminent && z.UserId == oProposed.UserId).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.ScheduledOnWorkorderImminent,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.PMItemScheduledUser,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
EventDate = (DateTime)oProposed.StartDate,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//ScheduledOnWorkorderImminent
|
||||
}
|
||||
|
||||
}//end of process notifications
|
||||
|
||||
|
||||
|
||||
@@ -1044,14 +1044,6 @@ namespace AyaNova.Biz
|
||||
|
||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||
|
||||
// Quote oCurrent = null;
|
||||
// bool SameTags = true;
|
||||
// if (currentObj != null)
|
||||
// {
|
||||
// oCurrent = (Quote)currentObj;
|
||||
// SameTags = NotifyEventHelper.TwoObjectsHaveSameTags(proposedObj.Tags, currentObj.Tags);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}//end of process notifications
|
||||
@@ -1767,21 +1759,6 @@ namespace AyaNova.Biz
|
||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||
|
||||
|
||||
//## DELETED EVENTS
|
||||
//any event added below needs to be removed, so
|
||||
//just blanket remove any event for this object of eventtype that would be added below here
|
||||
//do it regardless any time there's an update and then
|
||||
//let this code below handle the refreshing addition that could have changes
|
||||
// await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, o.Id, NotifyEventType.ContractExpiring);
|
||||
|
||||
|
||||
//## CREATED / MODIFIED EVENTS
|
||||
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
|
||||
//todo: fix etc, tons of shit here incoming
|
||||
|
||||
}
|
||||
|
||||
}//end of process notifications
|
||||
|
||||
@@ -3296,152 +3273,6 @@ namespace AyaNova.Biz
|
||||
|
||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||
|
||||
//## DELETED EVENTS
|
||||
//standard process above will remove any hanging around when deleted, nothing else specific here to deal with
|
||||
|
||||
|
||||
|
||||
//## CREATED
|
||||
if (ayaEvent == AyaEvent.Created)
|
||||
{
|
||||
//OutsideServiceOverdue
|
||||
if (oProposed.ETADate != null)
|
||||
{
|
||||
//Conditions: tags + time delayed eta value
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.OutsideServiceOverdue).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.OutsideServiceOverdue,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.QuoteItemOutsideService,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
EventDate = (DateTime)oProposed.ETADate,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//OutsideServiceOverdue
|
||||
|
||||
//OutsideServiceReceived (here because it's possible a outside service is entered new with both an eta and received date if entered after the fact)
|
||||
if (oProposed.ReturnDate != null)
|
||||
{
|
||||
//Clear overdue ones as it's now received
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, proposedObj.Id, NotifyEventType.OutsideServiceOverdue);
|
||||
|
||||
//Conditions: tags
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.OutsideServiceReceived).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.OutsideServiceReceived,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.QuoteItemOutsideService,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//OutsideServiceReceived
|
||||
}
|
||||
|
||||
//## MODIFIED
|
||||
if (ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
QuoteItemOutsideService oCurrent = (QuoteItemOutsideService)currentObj;
|
||||
|
||||
//OutsideServiceOverdue
|
||||
//if modified then remove any potential prior ones in case irrelevant
|
||||
if (oProposed.ETADate != oCurrent.ETADate)
|
||||
{
|
||||
//eta changed, so first of all remove any prior ones
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, proposedObj.Id, NotifyEventType.OutsideServiceOverdue);
|
||||
//now can go ahead and add back again as appropriate
|
||||
if (oProposed.ETADate != null)
|
||||
{
|
||||
//Conditions: tags + time delayed eta value
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.OutsideServiceOverdue).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.OutsideServiceOverdue,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.QuoteItemOutsideService,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
EventDate = (DateTime)oProposed.ETADate,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//OutsideServiceOverdue
|
||||
}
|
||||
|
||||
//OutsideServiceReceived
|
||||
if (oProposed.ReturnDate != oCurrent.ReturnDate && oProposed.ReturnDate != null)//note that this is an instant notification type so no need to clear older ones like above which is time delayed
|
||||
{
|
||||
//Clear overdue ones as it's now received
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, proposedObj.Id, NotifyEventType.OutsideServiceOverdue);
|
||||
|
||||
//Conditions: tags
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.OutsideServiceReceived).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.OutsideServiceReceived,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.QuoteItemOutsideService,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//OutsideServiceReceived
|
||||
}
|
||||
|
||||
}//end of process notifications
|
||||
|
||||
|
||||
@@ -4196,121 +4027,6 @@ namespace AyaNova.Biz
|
||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||
|
||||
|
||||
//## CREATED / UPDATED - ScheduledOnWorkorder event
|
||||
//Note: scheduled on quote is immediate so same process regardless if modified or updated
|
||||
//because modified changes nearly all affect user so decision is just send it no matter what as any difference is enough to send
|
||||
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
//this block is entirely about //ScheduledOnWorkorder event
|
||||
|
||||
if (oProposed.UserId != null)
|
||||
{
|
||||
//Conditions: userid match and tags
|
||||
//delivery is immediate so no need to remove old ones of this kind
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.ScheduledOnWorkorder && z.UserId == oProposed.UserId).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.ScheduledOnWorkorder,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.QuoteItemScheduledUser,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//ScheduledOnWorkorder
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//## CREATED
|
||||
if (ayaEvent == AyaEvent.Created)
|
||||
{
|
||||
//ScheduledOnWorkorderImminent
|
||||
if (oProposed.UserId != null && oProposed.StartDate != null)
|
||||
{
|
||||
//Conditions: userid match and tags + time delayed age value
|
||||
//delivery is delayed so need to remove old ones of this kind on update
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.ScheduledOnWorkorderImminent && z.UserId == oProposed.UserId).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.ScheduledOnWorkorderImminent,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.QuoteItemScheduledUser,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
EventDate = (DateTime)oProposed.StartDate,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//ScheduledOnWorkorderImminent
|
||||
}
|
||||
|
||||
|
||||
|
||||
//## MODIFIED
|
||||
if (ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
|
||||
//ScheduledOnWorkorderImminent
|
||||
//Always clear any old ones for this object as they are all irrelevant the moment changed:
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, proposedObj.AyaType, proposedObj.Id, NotifyEventType.ScheduledOnWorkorderImminent);
|
||||
|
||||
if (oProposed.UserId != null && oProposed.StartDate != null)
|
||||
{
|
||||
//Conditions: userid match and tags + time delayed age value
|
||||
//delivery is delayed so need to remove old ones of this kind on update
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.ScheduledOnWorkorderImminent && z.UserId == oProposed.UserId).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(WorkorderInfo.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.ScheduledOnWorkorderImminent,
|
||||
UserId = sub.UserId,
|
||||
AyaType = AyaType.QuoteItemScheduledUser,
|
||||
ObjectId = oProposed.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
EventDate = (DateTime)oProposed.StartDate,
|
||||
Name = $"{WorkorderInfo.Serial.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}//ScheduledOnWorkorderImminent
|
||||
}
|
||||
|
||||
}//end of process notifications
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user