From dc5945d308fbd3b0579f55a869e8f8b53a884203 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 9 Jul 2020 21:42:15 +0000 Subject: [PATCH] --- server/AyaNova/biz/NotifyDeliveryMethod.cs | 20 +++++++++++ server/AyaNova/models/AyContext.cs | 3 ++ server/AyaNova/models/NotifySubscription.cs | 40 ++++++++++----------- server/AyaNova/util/AySchema.cs | 6 ++-- 4 files changed, 44 insertions(+), 25 deletions(-) create mode 100644 server/AyaNova/biz/NotifyDeliveryMethod.cs diff --git a/server/AyaNova/biz/NotifyDeliveryMethod.cs b/server/AyaNova/biz/NotifyDeliveryMethod.cs new file mode 100644 index 00000000..e677bc7e --- /dev/null +++ b/server/AyaNova/biz/NotifyDeliveryMethod.cs @@ -0,0 +1,20 @@ +namespace AyaNova.Biz +{ + + + /// + /// All AyaNova notification delivery methods + /// + /// + public enum NotifyDeliveryMethod : int + { + + App = 1,//deliver in app via notification system + SMTP = 2//deliver to an email address or other entity reachable via smtp such as sms from email etc + + //NEW ITEMS REQUIRE translation KEYS + + } + + +}//eons diff --git a/server/AyaNova/models/AyContext.cs b/server/AyaNova/models/AyContext.cs index eebf4ff4..61c4d836 100644 --- a/server/AyaNova/models/AyContext.cs +++ b/server/AyaNova/models/AyContext.cs @@ -30,6 +30,9 @@ namespace AyaNova.Models public virtual DbSet Contract { get; set; } public virtual DbSet HeadOffice { get; set; } public virtual DbSet LoanUnit { get; set; } + + public virtual DbSet NotifySubscription { get; set; } + public virtual DbSet Part { get; set; } public virtual DbSet PM { get; set; } public virtual DbSet PMItem { get; set; } diff --git a/server/AyaNova/models/NotifySubscription.cs b/server/AyaNova/models/NotifySubscription.cs index 9bb51491..70b92b11 100644 --- a/server/AyaNova/models/NotifySubscription.cs +++ b/server/AyaNova/models/NotifySubscription.cs @@ -8,35 +8,31 @@ 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 NotifySubscription : ICoreBizObjectModel + + public class NotifySubscription { public long Id { get; set; } public uint Concurrency { get; set; } - -[Required] -public long SubscriberId { get; set; } -[Required] -public long SubscriberAyaType { get; set; } - - - - - - [Required] - public string Name { get; set; } - - public bool Active { get; set; } - public string Notes { get; set; } - public string Wiki {get;set;} - public string CustomFields { get; set; } - public List Tags { get; set; } - + [Required] + public long UserId { get; set; } + public AyaType? AyaType { get; set; } + [Required] + public NotifyEventType EventType { get; set; } + public TimeSpan? AdvanceNotice { get; set; } //Note: I've been doing nullable wrong sort of: https://stackoverflow.com/a/29149207/8939 + public long? IdValue { get; set; } + public decimal? DecValue { get; set; } + [Required] + public NotifyDeliveryMethod DeliveryMethod { get; set; } + public string DeliveryAddress { get; set; } + public long? AttachReportId { get; set; } + public List InTags { get; set; } + public List OutTags { get; set; } public NotifySubscription() { - Tags = new List(); + InTags = new List(); + OutTags = new List(); } }//eoc diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 9fbd799f..68eb945d 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -682,15 +682,15 @@ $BODY$; await ExecQueryAsync("CREATE TABLE anotifysubscription (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, " + "userid bigint not null, ayatype integer, eventtype integer not null, advancenotice interval, " + - "idvalue integer, decvalue decimal(19,4), deliverymethod integer not null, deliveryaddress text, attachreportid bigint, intags varchar(255) ARRAY, outtags varchar(255) ARRAY)"); + "idvalue bigint, decvalue decimal(19,4), deliverymethod integer not null, deliveryaddress text, attachreportid bigint, intags varchar(255) ARRAY, outtags varchar(255) ARRAY)"); 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 integer, decvalue decimal(19,4), eventdate timestamp, savedmessage text"); + "ayatype integer, objectid bigint, eventtype integer not null, subscriptionid bigint not null, idvalue bigint, decvalue decimal(19,4), eventdate timestamp, savedmessage 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 anotifydeliverylog (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, ayatype integer, objectid bigint, "+ - "eventtype integer not null, subscriptionid bigint not null, idvalue integer, decvalue decimal(19,4), processed timestamp not null, touserid bigint not null, deliverymethod integer not null, fail bool, error text"); + "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 SetSchemaLevelAsync(++currentSchema); }