From 3e3379cd7cf5352b40aa606de3ff8a70dd5a1207 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 9 Jul 2020 21:58:28 +0000 Subject: [PATCH] --- server/AyaNova/models/AyContext.cs | 1 + server/AyaNova/models/Notification.cs | 34 +++++++++++++++++ server/AyaNova/models/NotifyDeliveryLog.cs | 43 ++++++++++++++++++++++ server/AyaNova/util/AySchema.cs | 8 ++-- 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 server/AyaNova/models/Notification.cs create mode 100644 server/AyaNova/models/NotifyDeliveryLog.cs diff --git a/server/AyaNova/models/AyContext.cs b/server/AyaNova/models/AyContext.cs index 58c9d415..7d96e21c 100644 --- a/server/AyaNova/models/AyContext.cs +++ b/server/AyaNova/models/AyContext.cs @@ -33,6 +33,7 @@ namespace AyaNova.Models public virtual DbSet NotifySubscription { get; set; } public virtual DbSet NotifyEvent { get; set; } + public virtual DbSet Notification { get; set; } public virtual DbSet Part { get; set; } public virtual DbSet PM { get; set; } diff --git a/server/AyaNova/models/Notification.cs b/server/AyaNova/models/Notification.cs new file mode 100644 index 00000000..753ee337 --- /dev/null +++ b/server/AyaNova/models/Notification.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using AyaNova.Biz; +using System.ComponentModel.DataAnnotations; +using Newtonsoft.Json; + +namespace AyaNova.Models +{ + //NOTE: Any non required field (nullable in DB) sb nullable here, i.e. decimal? not decimal, + //otherwise the server will call it an invalid record if the field isn't sent from client + + public class Notification + { + public long Id { get; set; } + public uint Concurrency { get; set; } + + [Required] + public DateTime Created { get; set; } + public AyaType? AyaType { get; set; } + public long? ObjectId { get; set; } + [Required] + public NotifyEventType EventType { get; set; } + [Required] + public long SubscriptionId { get; set; } + public string Message { get; set; } + + public Notification() + { + Created = DateTime.UtcNow; + } + + }//eoc + +}//eons diff --git a/server/AyaNova/models/NotifyDeliveryLog.cs b/server/AyaNova/models/NotifyDeliveryLog.cs new file mode 100644 index 00000000..be0953e8 --- /dev/null +++ b/server/AyaNova/models/NotifyDeliveryLog.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using AyaNova.Biz; +using System.ComponentModel.DataAnnotations; +using Newtonsoft.Json; + +namespace AyaNova.Models +{ + //NOTE: Any non required field (nullable in DB) sb nullable here, i.e. decimal? not decimal, + //otherwise the server will call it an invalid record if the field isn't sent from client + + public class NotifyDeliveryLog + { + public long Id { get; set; } + public uint Concurrency { get; set; } + + [Required] + public DateTime Processed { get; set; } + public AyaType? AyaType { get; set; } + public long? ObjectId { get; set; } + [Required] + public NotifyEventType EventType { get; set; } + [Required] + public long SubscriptionId { get; set; } + public long? IdValue { get; set; } + public decimal? DecValue { get; set; } + [Required] + public long UserId { get; set; } + [Required] + public NotifyDeliveryMethod DeliveryMethod { get; set; } + [Required] + public bool Fail { get; set; } + public string Error { get; set; } + + + public NotifyDeliveryLog() + { + Processed = DateTime.UtcNow; + } + + }//eoc + +}//eons diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 2391963f..d7755495 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -687,10 +687,12 @@ $BODY$; await ExecQueryAsync("CREATE TABLE anotifyevent (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created timestamp not null, " + "ayatype integer, objectid bigint, eventtype integer not null, subscriptionid bigint not null, idvalue bigint, decvalue decimal(19,4), eventdate timestamp, message text"); - await ExecQueryAsync("CREATE TABLE anotification (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, ayatype integer, objectid bigint, eventtype integer not null, subscriptionid bigint not null, message text"); + await ExecQueryAsync("CREATE TABLE anotification (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created timestamp not null, ayatype integer, objectid bigint, eventtype integer not null, " + + "subscriptionid bigint not null, message text"); - await ExecQueryAsync("CREATE TABLE anotifydeliverylog (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, ayatype integer, objectid bigint, "+ - "eventtype integer not null, subscriptionid bigint not null, idvalue bigint, decvalue decimal(19,4), processed timestamp not null, touserid bigint not null, deliverymethod integer not null, fail bool, error text"); + await ExecQueryAsync("CREATE TABLE anotifydeliverylog (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, processed timestamp not null, ayatype integer, objectid bigint, " + + "eventtype integer not null, subscriptionid bigint not null, idvalue bigint, decvalue decimal(19,4), userid bigint not null, " + + "deliverymethod integer not null, fail bool not null, error text"); await SetSchemaLevelAsync(++currentSchema); }