diff --git a/.vscode/launch.json b/.vscode/launch.json index b77f3b95..fcc80a75 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -53,7 +53,7 @@ "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", - "AYANOVA_SERVER_TEST_MODE": "false", + "AYANOVA_SERVER_TEST_MODE": "true", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\" diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index 549bf2a0..8bf3f2aa 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -1279,7 +1279,7 @@ namespace AyaNova.Biz AyaType = AyaType.WorkOrder, ObjectId = o.WorkOrderId, NotifySubscriptionId = sub.Id, - Name = WorkorderInfo.Serial.ToString() + Name = $"{WorkorderInfo.Serial.ToString()} - {wos.Name}" }; await ct.NotifyEvent.AddAsync(n); log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); @@ -1304,12 +1304,12 @@ namespace AyaNova.Biz { NotifyEvent n = new NotifyEvent() { - EventType = NotifyEventType.WorkorderStatusChange, + EventType = NotifyEventType.WorkorderStatusAge, UserId = sub.UserId, AyaType = AyaType.WorkOrder, ObjectId = o.WorkOrderId, NotifySubscriptionId = sub.Id, - Name = WorkorderInfo.Serial.ToString() + Name = $"{WorkorderInfo.Serial.ToString()} - {wos.Name}" }; await ct.NotifyEvent.AddAsync(n); log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]"); diff --git a/server/AyaNova/generator/CoreJobNotify.cs b/server/AyaNova/generator/CoreJobNotify.cs index 2d0ae4d2..4a282997 100644 --- a/server/AyaNova/generator/CoreJobNotify.cs +++ b/server/AyaNova/generator/CoreJobNotify.cs @@ -96,7 +96,7 @@ namespace AyaNova.Biz if (deliverAfter < DateTime.UtcNow) { if (Subscription.DeliveryMethod == NotifyDeliveryMethod.App) - await DeliverInApp(notifyevent, ct); + await DeliverInApp(notifyevent, Subscription.AgeValue, ct); else if (Subscription.DeliveryMethod == NotifyDeliveryMethod.SMTP) await DeliverSMTP(notifyevent, Subscription.DeliveryAddress, ct); } @@ -117,10 +117,10 @@ namespace AyaNova.Biz } - private static async Task DeliverInApp(NotifyEvent ne, AyContext ct) + private static async Task DeliverInApp(NotifyEvent ne, TimeSpan ageValue, AyContext ct) { log.LogTrace($"DeliverInApp notify event: {ne}"); - await ct.Notification.AddAsync(new Notification() { UserId = ne.UserId, AyaType = ne.AyaType, ObjectId = ne.ObjectId, EventType = ne.EventType, NotifySubscriptionId = ne.NotifySubscriptionId, Message = ne.Message, Name = ne.Name }); + await ct.Notification.AddAsync(new Notification() { UserId = ne.UserId, AyaType = ne.AyaType, ObjectId = ne.ObjectId, EventType = ne.EventType, NotifySubscriptionId = ne.NotifySubscriptionId, Message = ne.Message, Name = ne.Name, AgeValue = ageValue }); await ct.SaveChangesAsync(); ct.NotifyEvent.Remove(ne); await ct.SaveChangesAsync(); diff --git a/server/AyaNova/models/Notification.cs b/server/AyaNova/models/Notification.cs index 1b7ac55c..ad24eff4 100644 --- a/server/AyaNova/models/Notification.cs +++ b/server/AyaNova/models/Notification.cs @@ -21,12 +21,13 @@ 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 + public string Name { get; set; }//object name or closest equivalent for display [Required] public NotifyEventType EventType { get; set; } [Required] public long NotifySubscriptionId { get; set; } public string Message { get; set; } + public TimeSpan AgeValue { get; set; } [Required] public bool Fetched { get; set; } @@ -34,7 +35,8 @@ namespace AyaNova.Models { Created = DateTime.UtcNow; Fetched = false; - Name=string.Empty; + Name = string.Empty; + AgeValue = TimeSpan.Zero; } //linked entity diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index be2a0189..566b781c 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 = 1; - internal const long EXPECTED_COLUMN_COUNT = 925; + internal const long EXPECTED_COLUMN_COUNT = 926; internal const long EXPECTED_INDEX_COUNT = 137; internal const long EXPECTED_CHECK_CONSTRAINTS = 415; internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 116; @@ -31,7 +31,7 @@ namespace AyaNova.Util //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!! - ///////////////////////////////////////////////////////////////// C925:I137:CC415:FC116:V6:R2 + ///////////////////////////////////////////////////////////////// C926:I137:CC415:FC116:V6:R2 /* @@ -944,7 +944,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); //idvalue BIGINT NOT NULL, decvalue DECIMAL(38,18) NOT NULL, await ExecQueryAsync("CREATE TABLE anotification (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, userid BIGINT NOT NULL REFERENCES auser (id), " - + "created TIMESTAMP NOT NULL, ayatype INTEGER NOT NULL, objectid BIGINT NOT NULL, name TEXT NOT NULL, eventtype INTEGER NOT NULL, " + + "created TIMESTAMP NOT NULL, ayatype INTEGER NOT NULL, objectid BIGINT NOT NULL, name TEXT NOT NULL, agevalue INTERVAL, eventtype INTEGER NOT NULL, " + "notifysubscriptionid BIGINT NOT NULL REFERENCES anotifysubscription(id) ON DELETE CASCADE, message TEXT, fetched BOOL NOT NULL)"); await ExecQueryAsync("CREATE TABLE anotifydeliverylog (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, processed TIMESTAMP NOT NULL, "