This commit is contained in:
@@ -34,7 +34,7 @@ Inspiring quotes used to help complete this huge project by myself
|
||||
ServerStateStatusChange = 36,
|
||||
ServerStateStatusAge=37,
|
||||
SubscriptionServerExpiring = 38,
|
||||
SubscriptionServerLastUpdateAge = 39,
|
||||
SubscriptionServerLastUpdateAge = 39,//here this means the operating system, not RAVEN which should always be updated on all servers when released
|
||||
SubscriptionServerRequestReceived = 40,
|
||||
LicenseTrialRequestReceived = 41,
|
||||
PurchaseNotificationReceived = 42
|
||||
|
||||
@@ -408,15 +408,15 @@ namespace Sockeye.Biz
|
||||
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
|
||||
|
||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||
SubscriptionServer o = (SubscriptionServer)proposedObj;
|
||||
|
||||
SubscriptionServer ProposedServer = (SubscriptionServer)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, BizType, o.Id, NotifyEventType.SubscriptionServerExpiring);
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, BizType, o.Id, NotifyEventType.SubscriptionServerLastUpdateAge);
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, BizType, ProposedServer.Id, NotifyEventType.SubscriptionServerExpiring);
|
||||
await NotifyEventHelper.ClearPriorEventsForObject(ct, BizType, ProposedServer.Id, NotifyEventType.SubscriptionServerLastUpdateAge);
|
||||
|
||||
|
||||
//## CREATED / MODIFIED EVENTS
|
||||
@@ -424,7 +424,7 @@ namespace Sockeye.Biz
|
||||
{
|
||||
|
||||
//# NEW TRIAL SERVER REQUEST
|
||||
if (ayaEvent == SockEvent.Created && o.Trial == true)
|
||||
if (ayaEvent == SockEvent.Created && ProposedServer.Trial == true)
|
||||
{
|
||||
{
|
||||
//Conditions: must match specific status id value and also tags below
|
||||
@@ -436,16 +436,16 @@ namespace Sockeye.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(o.Tags, sub.Tags))
|
||||
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(ProposedServer.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.SubscriptionServerRequestReceived,
|
||||
UserId = sub.UserId,
|
||||
SockType = BizType,
|
||||
ObjectId = o.Id,
|
||||
ObjectId = ProposedServer.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = $"{o.TrialCompany} - trial server requested"
|
||||
Name = $"{ProposedServer.TrialCompany} - trial server requested"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
@@ -466,7 +466,7 @@ namespace Sockeye.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(o.Tags, sub.Tags))
|
||||
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(ProposedServer.Tags, sub.Tags))
|
||||
{
|
||||
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
@@ -474,10 +474,10 @@ namespace Sockeye.Biz
|
||||
EventType = NotifyEventType.SubscriptionServerExpiring,
|
||||
UserId = sub.UserId,
|
||||
SockType = BizType,
|
||||
ObjectId = o.Id,
|
||||
ObjectId = ProposedServer.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = o.Name,
|
||||
EventDate = o.SubscriptionExpire
|
||||
Name = ProposedServer.Name,
|
||||
EventDate = ProposedServer.SubscriptionExpire
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
@@ -488,9 +488,9 @@ namespace Sockeye.Biz
|
||||
}//subscription server expiry event
|
||||
|
||||
|
||||
//# SUBSCRIPTION SERVER LAST UPDATE AGE
|
||||
//# SUBSCRIPTION SERVER LAST UPDATE (O.S.) AGE
|
||||
{
|
||||
if (o.LastUpdated != null)
|
||||
if (ProposedServer.LastUpdated != null)
|
||||
{
|
||||
//notify users about warranty expiry (time delayed)
|
||||
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.SubscriptionServerLastUpdateAge).ToListAsync();
|
||||
@@ -500,17 +500,17 @@ namespace Sockeye.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(o.Tags, sub.Tags))
|
||||
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(ProposedServer.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.SubscriptionServerLastUpdateAge,
|
||||
UserId = sub.UserId,
|
||||
SockType = BizType,
|
||||
ObjectId = o.Id,
|
||||
ObjectId = ProposedServer.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = o.Name,
|
||||
EventDate = (DateTime)o.LastUpdated
|
||||
Name = ProposedServer.Name,
|
||||
EventDate = (DateTime)ProposedServer.LastUpdated
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
@@ -522,66 +522,70 @@ namespace Sockeye.Biz
|
||||
}//subscription server last updated event
|
||||
|
||||
|
||||
|
||||
//# STATUS CHANGE (create new status)
|
||||
//##################################
|
||||
//ServerState changes events
|
||||
//##################################
|
||||
if (isNew || ((SubscriptionServer)currentObj).ServerState != ProposedServer.ServerState)//must have changed from a prior state
|
||||
{
|
||||
//Conditions: must match specific status id value and also tags below
|
||||
//delivery is immediate so no need to remove old ones of this kind
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.ServerStateStatusChange && z.IdValue == (long)o.ServerState).ToListAsync();
|
||||
foreach (var sub in subs)
|
||||
//# STATUS CHANGE (changed to this new status)
|
||||
{
|
||||
//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))
|
||||
//Conditions: must match specific status id value and also tags below
|
||||
//delivery is immediate so no need to remove old ones of this kind
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.ServerStateStatusChange && z.IdValue == (long)ProposedServer.ServerState).ToListAsync();
|
||||
foreach (var sub in subs)
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.ServerStateStatusChange,
|
||||
UserId = sub.UserId,
|
||||
SockType = BizType,
|
||||
ObjectId = o.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = $"{o.Name} - {o.ServerState.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}// status change event
|
||||
//not for inactive users
|
||||
if (!await UserBiz.UserIsActive(sub.UserId)) continue;
|
||||
|
||||
//# STATUS AGE
|
||||
{
|
||||
//ServerStateStatusAge 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, SockType.SubscriptionServer, proposedObj.Id, NotifyEventType.ServerStateStatusAge);
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.ServerStateStatusAge && z.IdValue == (long)o.ServerState).ToListAsync();
|
||||
foreach (var sub in subs)
|
||||
//Tag match? (will be true if no sub tags so always safe to call this)
|
||||
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(ProposedServer.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.ServerStateStatusChange,
|
||||
UserId = sub.UserId,
|
||||
SockType = BizType,
|
||||
ObjectId = ProposedServer.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = $"{ProposedServer.Name} - {ProposedServer.ServerState.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}// status change event
|
||||
|
||||
//# STATUS AGE
|
||||
{
|
||||
//not for inactive users
|
||||
if (!await UserBiz.UserIsActive(sub.UserId)) continue;
|
||||
|
||||
//WorkOrder Tag match? (Not State, state has no tags, will be true if no sub tags so always safe to call this)
|
||||
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(o.Tags, sub.Tags))
|
||||
//ServerStateStatusAge 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, SockType.SubscriptionServer, proposedObj.Id, NotifyEventType.ServerStateStatusAge);
|
||||
var subs = await ct.NotifySubscription.AsNoTracking().Where(z => z.EventType == NotifyEventType.ServerStateStatusAge && z.IdValue == (long)ProposedServer.ServerState).ToListAsync();
|
||||
foreach (var sub in subs)
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.ServerStateStatusAge,
|
||||
UserId = sub.UserId,
|
||||
SockType = SockType.SubscriptionServer,
|
||||
ObjectId = o.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = $"{o.Name} - {o.ServerState.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}// status age event
|
||||
//not for inactive users
|
||||
if (!await UserBiz.UserIsActive(sub.UserId)) continue;
|
||||
|
||||
//WorkOrder Tag match? (Not State, state has no tags, will be true if no sub tags so always safe to call this)
|
||||
if (NotifyEventHelper.ObjectHasAllSubscriptionTags(ProposedServer.Tags, sub.Tags))
|
||||
{
|
||||
NotifyEvent n = new NotifyEvent()
|
||||
{
|
||||
EventType = NotifyEventType.ServerStateStatusAge,
|
||||
UserId = sub.UserId,
|
||||
SockType = SockType.SubscriptionServer,
|
||||
ObjectId = ProposedServer.Id,
|
||||
NotifySubscriptionId = sub.Id,
|
||||
Name = $"{ProposedServer.Name} - {ProposedServer.ServerState.ToString()}"
|
||||
};
|
||||
await ct.NotifyEvent.AddAsync(n);
|
||||
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}// status age event
|
||||
}//is new or ServerState has changed
|
||||
|
||||
}//object created or modified
|
||||
|
||||
|
||||
Reference in New Issue
Block a user