This commit is contained in:
2020-07-20 23:17:07 +00:00
parent 5bfdaad629
commit 243d71612d
3 changed files with 11 additions and 6 deletions

View File

@@ -76,7 +76,8 @@ namespace AyaNova.Biz
//this will likely be a development error, not a production error so no need to log etc
throw new System.ArgumentException("NotifyEventProcessor:AddGeneralNotifyEvent: DefaultNotification requires a user id but none was specified");
}
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = userId, Message = message, NotifySubscriptionId = 0 };
var UserName = await ct.User.Where(z => z.Id == userId).Select(z => z.Name).FirstOrDefaultAsync();
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = userId, Message = message, NotifySubscriptionId = 0, Name = UserName };
await ct.NotifyEvent.AddAsync(n);
await ct.SaveChangesAsync();
return;
@@ -87,7 +88,8 @@ namespace AyaNova.Biz
var subs = await ct.NotifySubscription.Where(z => z.EventType == eventType).ToListAsync();
foreach (var sub in subs)
{
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = sub.UserId, Message = message, NotifySubscriptionId = sub.Id };
//note flag ~SERVER~ means to client to substitute "Server" translation key text instead
NotifyEvent n = new NotifyEvent() { EventType = eventType, UserId = sub.UserId, Message = message, NotifySubscriptionId = sub.Id, Name = "~SERVER~" };
await ct.NotifyEvent.AddAsync(n);
}
if (subs.Count > 0)
@@ -206,9 +208,9 @@ namespace AyaNova.Biz
if (TagsMatch(newObject.Tags, sub.Tags))
{
//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
//ObjectAge is determined by subscription AgeValue in combo with the EventDate NotifyEvent parameter which together determines at what age from notifyevent.EventDate it's considered for the event to have officially occured
//However delivery is determined by sub.advancenotice so all three values play a part
//
//ObjectAge is determined by subscription AgeValue in combo with the EventDate NotifyEvent parameter which together determines at what age from notifyevent.EventDate it's considered for the event to have officially occured
//However delivery is determined by sub.advancenotice so all three values play a part
//
NotifyEvent n = new NotifyEvent()
{
EventType = NotifyEventType.ObjectAge,

View File

@@ -19,6 +19,8 @@ namespace AyaNova.Models
public AyaType AyaType { get; set; }
public long ObjectId { get; set; }
[Required]
public string Name {get;set;}//object name or closest equivalent for display
[Required]
public NotifyEventType EventType { get; set; }
[Required]
public long UserId { get; set; }
@@ -46,6 +48,7 @@ namespace AyaNova.Models
// AgeValue = TimeSpan.Zero;
AyaType = AyaType.NoType;
ObjectId = 0;
Name=string.Empty;
}
public override string ToString()

View File

@@ -689,7 +689,7 @@ $BODY$;
"deliveryaddress text, attachreportid bigint not null, tags varchar(255) ARRAY)");
await ExecQueryAsync("CREATE TABLE anotifyevent (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created timestamp not null, " +
"ayatype integer not null, objectid bigint not null, eventtype integer not null, notifysubscriptionid bigint not null references anotifysubscription(id) on delete cascade, " +
"ayatype integer not null, objectid bigint not null, name varchar(255) not null, eventtype integer not null, notifysubscriptionid bigint not null references anotifysubscription(id) on delete cascade, " +
"userid bigint not null, idvalue bigint not null, decvalue decimal(19,4) not null, eventdate timestamp, message text)");