diff --git a/server/AyaNova/biz/NotifyEventProcessor.cs b/server/AyaNova/biz/NotifyEventProcessor.cs index 2d80b26d..da81470c 100644 --- a/server/AyaNova/biz/NotifyEventProcessor.cs +++ b/server/AyaNova/biz/NotifyEventProcessor.cs @@ -127,18 +127,52 @@ namespace AyaNova.Biz switch (ayaEvent) { case AyaEvent.Created: + //------------------------------ //Specific created related subscriptions for AyaType switch (newObject.AyaType) { //AyaTypes with their own special notification related events - - case AyaType.WorkOrder: + { + //WorkorderStatusChange + //ScheduledOnWorkorder + //ScheduledOnWorkorderImminent + //tentative WorkorderCloseByPassed + //OutsideServiceOverdue + //OutsideServiceReceived + //PartRequestReceived + //CustomerServiceImminent + //PartRequested + //WorkorderTotalExceedsThreshold + //WorkorderStatusAge + } break; case AyaType.Quote: + //QuoteStatusChange + //QuoteStatusAge break; } + + //----------------------------------------------- + //ObjectAge + { + var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ObjectAge && z.AyaType == newObject.AyaType).ToListAsync(); + foreach (var sub in subs) + { + if (TagsMatch(newObject.Tags, sub.Tags)) + { + NotifyEvent n = new NotifyEvent() { + EventType = NotifyEventType.ObjectAge, UserId = sub.UserId, AyaType = newObject.AyaType, ObjectId = newObject.Id, + SubscriptionId = sub.Id, EventDate=DateTime.UtcNow + }; + await ct.NotifyEvent.AddAsync(n); + log.LogTrace($"Adding NotifyEvent: [{n.ToString()}]"); + SaveContext = true; + } + } + } + //------------------------------------------ //General ObjectCreated subscriptions { var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ObjectCreated && z.AyaType == newObject.AyaType).ToListAsync(); diff --git a/server/AyaNova/models/NotifyEvent.cs b/server/AyaNova/models/NotifyEvent.cs index 95e223c0..d9af38ad 100644 --- a/server/AyaNova/models/NotifyEvent.cs +++ b/server/AyaNova/models/NotifyEvent.cs @@ -30,8 +30,10 @@ namespace AyaNova.Models public decimal DecValue { get; set; } [Required] public TimeSpan AgeValue { get; set; } - public DateTime? EventDate { get; set; }//date of the event actually occuring, e.g. WarrantyExpiry date. Duped with delivery date as source of truth in case edit to advance setting in subscription changes delivery date - public DateTime? DeliverDate { get; set; }//date user wants the event notification delivered, usually same as event date but could be set earlier if Advance setting in effect. This is the date consulted for delivery only. + //date of the event actually occuring, e.g. WarrantyExpiry date. Compared with subscription to determine if deliverable or not + public DateTime? EventDate { get; set; } + //NO: Delivery code consults subscription instead of this + // public DateTime? DeliverDate { get; set; }//date user wants the event notification delivered, usually same as event date but could be set earlier if Advance setting in effect. This is the date consulted for delivery only. public string Message { get; set; } diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 71a2f96a..df47bb17 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -22,7 +22,7 @@ namespace AyaNova.Util //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!! private const int DESIRED_SCHEMA_LEVEL = 12; - internal const long EXPECTED_COLUMN_COUNT = 382; + internal const long EXPECTED_COLUMN_COUNT = 381; internal const long EXPECTED_INDEX_COUNT = 139; //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!! @@ -690,7 +690,7 @@ $BODY$; 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, subscriptionid bigint not null, userid bigint not null, " + - "idvalue bigint not null, decvalue decimal(19,4) not null, agevalue interval not null, eventdate timestamp, deliverdate timestamp, message text)"); + "idvalue bigint not null, decvalue decimal(19,4) not null, agevalue interval not null, eventdate timestamp, message text)"); await ExecQueryAsync("CREATE TABLE anotification (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, userid bigint not null, " + "created timestamp not null, ayatype integer not null, objectid bigint not null, eventtype integer not null, " +