This commit is contained in:
2022-03-04 21:20:53 +00:00
parent 7db8643c1f
commit 27888e18f7
3 changed files with 55 additions and 1 deletions

View File

@@ -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]

View File

@@ -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<string> 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<string> 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<string>();
AyaType = AyaType.NoType;
IdValue = 0;
DecValue = 0;
AgeValue = TimeSpan.Zero;
AdvanceNotice = TimeSpan.Zero;
LinkReportId = 0;
}
}//eoc
}//eons

View File

@@ -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)");