From 27888e18f7622e2a8428c020ddd997d2f11443d2 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 4 Mar 2022 21:20:53 +0000 Subject: [PATCH] --- server/AyaNova/biz/AyaType.cs | 2 +- .../models/CustomerNotifySubscription.cs | 44 +++++++++++++++++++ server/AyaNova/util/AySchema.cs | 10 +++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 server/AyaNova/models/CustomerNotifySubscription.cs diff --git a/server/AyaNova/biz/AyaType.cs b/server/AyaNova/biz/AyaType.cs index adf6e6bb..a0ae4cbe 100644 --- a/server/AyaNova/biz/AyaType.cs +++ b/server/AyaNova/biz/AyaType.cs @@ -160,7 +160,7 @@ namespace AyaNova.Biz PMItemLoan = 82, [CoreBizObject, ReportableBizObject] PMItemPart = 83, - //UNUSED_84 = 84, + CustomerNotifySubscription = 84,//proxy subs for customers [CoreBizObject, ReportableBizObject] PMItemScheduledUser = 85, [CoreBizObject, ReportableBizObject] diff --git a/server/AyaNova/models/CustomerNotifySubscription.cs b/server/AyaNova/models/CustomerNotifySubscription.cs new file mode 100644 index 00000000..21aca59c --- /dev/null +++ b/server/AyaNova/models/CustomerNotifySubscription.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using AyaNova.Biz; +using System.ComponentModel.DataAnnotations; +using Newtonsoft.Json; + +namespace AyaNova.Models +{ + + + public class CustomerNotifySubscription + { + public long Id { get; set; } + public uint Concurrency { get; set; } + public List CustomerTags { get; set; }//Tags to match customer with this notification + public TimeSpan AdvanceNotice { get; set; } + public long LinkReportId { get; set; } + + //CREATE NOTIFY EVENT CONDITIONS - Following fields are all conditions set on whether to create a notify event or not + public AyaType AyaType { get; set; }//Note: must be specific object, not global for any object related stuff to avoid many role issues and also potential overload + [Required] + public NotifyEventType EventType { get; set; } + [Required] + public long IdValue { get; set; }//if required, this must match, default is zero to match to not set + public decimal DecValue { get; set; }//if required this must match or be greater or something + public List Tags { get; set; }//Tags to filter an event, object *must* have these tags to generate event related to it (AT TIME OF UPDATE) + + //DELIVERY CONDITIONS - following are all conditions on *whether* to deliver the existing notify event or not + public TimeSpan AgeValue { get; set; }//for events that depend on an age of something (e.g. WorkorderStatusAge), This value determines when event has "come of age" but advancenotice controls how far in advance of this delivery is made + + public CustomerNotifySubscription() + { + Tags = new List(); + AyaType = AyaType.NoType; + IdValue = 0; + DecValue = 0; + AgeValue = TimeSpan.Zero; + AdvanceNotice = TimeSpan.Zero; + LinkReportId = 0; + } + + }//eoc + +}//eons diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 57440a8e..9e536898 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -1324,6 +1324,16 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("CREATE TABLE anotifydeliverylog (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, processed TIMESTAMPTZ NOT NULL, " + "objectid BIGINT NOT NULL, notifysubscriptionid BIGINT NOT NULL, fail BOOL NOT NULL, error TEXT)"); + + //CUSTOMER "proxy" NOTIFICATION + await ExecQueryAsync("CREATE TABLE acustomernotifysubscription (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, " + + "customertags VARCHAR(255) ARRAY, ayatype INTEGER NOT NULL, eventtype INTEGER NOT NULL, advancenotice INTERVAL NOT NULL, " + + "idvalue BIGINT NOT NULL, decvalue DECIMAL(38,18) NOT NULL, agevalue INTERVAL NOT NULL, " + + "linkreportid BIGINT NOT NULL, tags VARCHAR(255) ARRAY)"); + + + + //UNITMETERREADING await ExecQueryAsync("CREATE TABLE aunitmeterreading (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, meterdate TIMESTAMPTZ NOT NULL, notes TEXT, " + "meter BIGINT NOT NULL, unitid BIGINT NOT NULL REFERENCES aunit(id) ON DELETE CASCADE, workorderitemunitid BIGINT REFERENCES aworkorderitemunit(id) ON DELETE SET NULL)");