This commit is contained in:
@@ -531,6 +531,54 @@ namespace AyaNova.Biz
|
|||||||
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
|
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
|
||||||
|
|
||||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||||
|
Customer o = (Customer)proposedObj;
|
||||||
|
|
||||||
|
//## 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, AyaType.Customer, o.Id, NotifyEventType.ContractExpiring);
|
||||||
|
|
||||||
|
|
||||||
|
//## CREATED / MODIFIED EVENTS
|
||||||
|
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
||||||
|
{
|
||||||
|
|
||||||
|
//# CONTRACT EXPIRY
|
||||||
|
{
|
||||||
|
if (o.ContractId != null && o.ContractExpires != null)
|
||||||
|
{
|
||||||
|
var ContractExpirydate = (DateTime)o.ContractExpires;
|
||||||
|
//notify users about contract expiry (time delayed)
|
||||||
|
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ContractExpiring).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.TagsMatch(o.Tags, sub.Tags))
|
||||||
|
{
|
||||||
|
NotifyEvent n = new NotifyEvent()
|
||||||
|
{
|
||||||
|
EventType = NotifyEventType.ContractExpiring,
|
||||||
|
UserId = sub.UserId,
|
||||||
|
AyaType = o.AyaType,
|
||||||
|
ObjectId = o.Id,
|
||||||
|
NotifySubscriptionId = sub.Id,
|
||||||
|
Name = o.Name,
|
||||||
|
EventDate = ContractExpirydate
|
||||||
|
};
|
||||||
|
await ct.NotifyEvent.AddAsync(n);
|
||||||
|
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||||
|
await ct.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//Contract expiry event
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}//end of process notifications
|
}//end of process notifications
|
||||||
|
|
||||||
|
|||||||
@@ -489,7 +489,55 @@ namespace AyaNova.Biz
|
|||||||
//STANDARD EVENTS FOR ALL OBJECTS
|
//STANDARD EVENTS FOR ALL OBJECTS
|
||||||
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
|
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
|
||||||
|
|
||||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||||
|
HeadOffice o = (HeadOffice)proposedObj;
|
||||||
|
|
||||||
|
//## 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, AyaType.HeadOffice, o.Id, NotifyEventType.ContractExpiring);
|
||||||
|
|
||||||
|
|
||||||
|
//## CREATED / MODIFIED EVENTS
|
||||||
|
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
||||||
|
{
|
||||||
|
|
||||||
|
//# CONTRACT EXPIRY
|
||||||
|
{
|
||||||
|
if (o.ContractId != null && o.ContractExpires != null)
|
||||||
|
{
|
||||||
|
var ContractExpirydate = (DateTime)o.ContractExpires;
|
||||||
|
//notify users about contract expiry (time delayed)
|
||||||
|
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ContractExpiring).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.TagsMatch(o.Tags, sub.Tags))
|
||||||
|
{
|
||||||
|
NotifyEvent n = new NotifyEvent()
|
||||||
|
{
|
||||||
|
EventType = NotifyEventType.ContractExpiring,
|
||||||
|
UserId = sub.UserId,
|
||||||
|
AyaType = o.AyaType,
|
||||||
|
ObjectId = o.Id,
|
||||||
|
NotifySubscriptionId = sub.Id,
|
||||||
|
Name = o.Name,
|
||||||
|
EventDate = ContractExpirydate
|
||||||
|
};
|
||||||
|
await ct.NotifyEvent.AddAsync(n);
|
||||||
|
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||||
|
await ct.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//Contract expiry event
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}//end of process notifications
|
}//end of process notifications
|
||||||
|
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ namespace AyaNova.Biz
|
|||||||
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Serial", "no two units can have the same serial and same unitmodel");
|
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Serial", "no two units can have the same serial and same unitmodel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proposedObj.ContractId != null)
|
if (proposedObj.ContractId != null)
|
||||||
if (proposedObj.ContractExpires == null)
|
if (proposedObj.ContractExpires == null)
|
||||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "ContractExpires");
|
AddError(ApiErrorCode.VALIDATION_REQUIRED, "ContractExpires");
|
||||||
@@ -484,30 +484,22 @@ namespace AyaNova.Biz
|
|||||||
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
|
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
|
||||||
|
|
||||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||||
/*
|
Unit o = (Unit)proposedObj;
|
||||||
UnitWarrantyExpiry = 25,//* Unit object created, advance notice can be used, tag conditional
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
//## DELETED EVENTS
|
//## DELETED EVENTS
|
||||||
//TODO: there are no specific deleted events
|
//any event added below needs to be removed, so
|
||||||
//but 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
|
//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
|
//do it regardless any time there's an update and then
|
||||||
//let this code below handle the refreshing addition that could have changes
|
//let this code below handle the refreshing addition that could have changes
|
||||||
|
await NotifyEventHelper.ClearPriorEventsForObject(ct, AyaType.Unit, o.Id, NotifyEventType.UnitWarrantyExpiry);
|
||||||
|
await NotifyEventHelper.ClearPriorEventsForObject(ct, AyaType.Unit, o.Id, NotifyEventType.ContractExpiring);
|
||||||
|
|
||||||
|
|
||||||
//## CREATED / MODIFIED EVENTS
|
//## CREATED / MODIFIED EVENTS
|
||||||
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
||||||
{
|
{
|
||||||
Unit o = (Unit)proposedObj;
|
|
||||||
|
|
||||||
//# UNIT WARRANTY EXPIRY
|
//# UNIT WARRANTY EXPIRY
|
||||||
{
|
{
|
||||||
//first remove any existing, potentially stale notifyevents for this exact object and notifyeventtype
|
|
||||||
//NOTE: this is only required for notify events that have an AgeValue where the eventdate is relevant
|
|
||||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, AyaType.Unit, o.Id, NotifyEventType.UnitWarrantyExpiry);
|
|
||||||
|
|
||||||
//does the unit even have a model or warranty?
|
//does the unit even have a model or warranty?
|
||||||
int effectiveWarrantyMonths = 0;
|
int effectiveWarrantyMonths = 0;
|
||||||
//unit has own warranty terms
|
//unit has own warranty terms
|
||||||
@@ -560,6 +552,39 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
}//warranty expiry event
|
}//warranty expiry event
|
||||||
|
|
||||||
|
//# CONTRACT EXPIRY
|
||||||
|
{
|
||||||
|
if (o.ContractId != null && o.ContractExpires != null)
|
||||||
|
{
|
||||||
|
var ContractExpirydate = (DateTime)o.ContractExpires;
|
||||||
|
//notify users about contract expiry (time delayed)
|
||||||
|
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ContractExpiring).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.TagsMatch(o.Tags, sub.Tags))
|
||||||
|
{
|
||||||
|
NotifyEvent n = new NotifyEvent()
|
||||||
|
{
|
||||||
|
EventType = NotifyEventType.ContractExpiring,
|
||||||
|
UserId = sub.UserId,
|
||||||
|
AyaType = o.AyaType,
|
||||||
|
ObjectId = o.Id,
|
||||||
|
NotifySubscriptionId = sub.Id,
|
||||||
|
Name = o.Serial,
|
||||||
|
EventDate = ContractExpirydate
|
||||||
|
};
|
||||||
|
await ct.NotifyEvent.AddAsync(n);
|
||||||
|
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||||
|
await ct.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//Contract expiry event
|
||||||
|
|
||||||
|
|
||||||
//#todo: METER READING EVENT
|
//#todo: METER READING EVENT
|
||||||
//MIGRATE_OUTSTANDING need meter reading object to complete unit notification for UnitMeterReadingMultipleExceeded
|
//MIGRATE_OUTSTANDING need meter reading object to complete unit notification for UnitMeterReadingMultipleExceeded
|
||||||
@@ -570,11 +595,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
//then check if unit is still metered etc etc and do the rest once the unit meter reading is coded
|
//then check if unit is still metered etc etc and do the rest once the unit meter reading is coded
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2638,6 +2638,8 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||||
|
|
||||||
|
//todo: contract response time notification
|
||||||
|
|
||||||
}//end of process notifications
|
}//end of process notifications
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user