This commit is contained in:
@@ -208,6 +208,10 @@ namespace AyaNova.Biz
|
|||||||
// CLEAN OUT OLD EVENTS
|
// CLEAN OUT OLD EVENTS
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
//Any specific event created in objects biz code (not simply "Modified")
|
||||||
|
//should trigger this remove code prior to updates etc where it creates a new one
|
||||||
|
//particularly for future delivery ones but will catch the case of a quick double edit of an object that
|
||||||
|
//would alter what gets delivered in the notification and before it's sent out yet
|
||||||
public static async Task ClearPriorEventsForObject(AyContext ct, AyaType ayaType, long objectId, NotifyEventType eventType)
|
public static async Task ClearPriorEventsForObject(AyContext ct, AyaType ayaType, long objectId, NotifyEventType eventType)
|
||||||
{
|
{
|
||||||
var eventsToDelete = await ct.NotifyEvent.Where(z => z.AyaType == ayaType && z.ObjectId == objectId && z.EventType == eventType).ToListAsync();
|
var eventsToDelete = await ct.NotifyEvent.Where(z => z.AyaType == ayaType && z.ObjectId == objectId && z.EventType == eventType).ToListAsync();
|
||||||
@@ -215,6 +219,9 @@ namespace AyaNova.Biz
|
|||||||
ct.NotifyEvent.RemoveRange(eventsToDelete);
|
ct.NotifyEvent.RemoveRange(eventsToDelete);
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//scorched earth one for outright delete of objects when you don't want any prior events left for it
|
||||||
|
//probably only ever used for the delete event, can't think of another one right now new years morning early 2021 a bit hungover but possibly there is :)
|
||||||
public static async Task ClearPriorEventsForObject(AyContext ct, AyaType ayaType, long objectId)
|
public static async Task ClearPriorEventsForObject(AyContext ct, AyaType ayaType, long objectId)
|
||||||
{
|
{
|
||||||
var eventsToDelete = await ct.NotifyEvent.Where(z => z.AyaType == ayaType && z.ObjectId == objectId).ToListAsync();
|
var eventsToDelete = await ct.NotifyEvent.Where(z => z.AyaType == ayaType && z.ObjectId == objectId).ToListAsync();
|
||||||
|
|||||||
@@ -288,9 +288,7 @@ namespace AyaNova.Biz
|
|||||||
/*
|
/*
|
||||||
UnitWarrantyExpiry = 25,//* Unit object created, advance notice can be used, tag conditional
|
UnitWarrantyExpiry = 25,//* Unit object created, advance notice can be used, tag conditional
|
||||||
|
|
||||||
//MIGRATE_OUTSTANDING
|
|
||||||
UnitMeterReadingMultipleExceeded = 26,//* UnitMeterReading object, Created, conditional on DecValue as the Multiple threshold, if passed then notifies
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
//## DELETED EVENTS
|
//## DELETED EVENTS
|
||||||
//TODO: there are no specific deleted events
|
//TODO: there are no specific deleted events
|
||||||
@@ -300,15 +298,16 @@ namespace AyaNova.Biz
|
|||||||
//let this code below handle the refreshing addition that could have changes
|
//let this code below handle the refreshing addition that could have changes
|
||||||
|
|
||||||
|
|
||||||
//## CREATED EVENTS
|
//## CREATED / MODIFIED EVENTS
|
||||||
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
if (ayaEvent == AyaEvent.Created || ayaEvent == AyaEvent.Modified)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
Unit o = (Unit)proposedObj;
|
Unit o = (Unit)proposedObj;
|
||||||
|
|
||||||
//UNIT WARRANTY EXPIRY
|
//# UNIT WARRANTY EXPIRY
|
||||||
{
|
{
|
||||||
|
//first remove any existing, potentially stale notifyevents for this exact object and notifyeventtype
|
||||||
|
await NotifyEventHelper.ClearPriorEventsForObject(ct, AyaType.Unit, o.Id, NotifyEventType.UnitWarrantyExpiry);
|
||||||
|
|
||||||
//does the unit even have a model or warranty?
|
//does the unit even have a model or warranty?
|
||||||
int effectiveWarrantyMonths = 0;
|
int effectiveWarrantyMonths = 0;
|
||||||
//unit has own warranty terms
|
//unit has own warranty terms
|
||||||
@@ -359,7 +358,23 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}//warranty expiry event
|
||||||
|
|
||||||
|
|
||||||
|
//#todo: METER READING EVENT
|
||||||
|
//MIGRATE_OUTSTANDING need meter reading object to complete unit notification for UnitMeterReadingMultipleExceeded
|
||||||
|
//UnitMeterReadingMultipleExceeded = 26,//* UnitMeterReading object, Created, conditional on DecValue as the Multiple threshold, if passed then notifies
|
||||||
|
//{
|
||||||
|
//first remove any existing, potentially stale notifyevents for this exact object and notifyeventtype
|
||||||
|
//await NotifyEventHelper.ClearPriorEventsForObject(ct, AyaType.Unit, o.Id, NotifyEventType.UnitMeterReadingMultipleExceeded);
|
||||||
|
|
||||||
|
//then check if unit is still metered etc etc and do the rest once the unit meter reading is coded
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ namespace AyaNova.Models
|
|||||||
public NotifyEvent()
|
public NotifyEvent()
|
||||||
{
|
{
|
||||||
Created = EventDate = DateTime.UtcNow;
|
Created = EventDate = DateTime.UtcNow;
|
||||||
IdValue = 0;
|
// IdValue = 0;
|
||||||
DecValue = 0;
|
// DecValue = 0;
|
||||||
AyaType = AyaType.NoType;
|
AyaType = AyaType.NoType;
|
||||||
ObjectId = 0;
|
ObjectId = 0;
|
||||||
Name = string.Empty;
|
Name = string.Empty;
|
||||||
|
|||||||
@@ -58,12 +58,12 @@ namespace AyaNova.Models
|
|||||||
public Customer Customer { get; set; }
|
public Customer Customer { get; set; }
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public UnitModel UnitModel { get; set; }
|
public UnitModel UnitModel { get; set; }
|
||||||
[JsonIgnore]
|
// [JsonIgnore]
|
||||||
public Unit ParentUnit { get; set; }
|
// public Unit ParentUnit { get; set; }
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public Vendor PurchasedFromVendor { get; set; }
|
public Vendor PurchasedFromVendor { get; set; }
|
||||||
[JsonIgnore]
|
// [JsonIgnore]
|
||||||
public Unit ReplacedByUnit { get; set; }
|
// public Unit ReplacedByUnit { get; set; }
|
||||||
|
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace AyaNova.Util
|
|||||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
||||||
private const int DESIRED_SCHEMA_LEVEL = 15;
|
private const int DESIRED_SCHEMA_LEVEL = 15;
|
||||||
|
|
||||||
internal const long EXPECTED_COLUMN_COUNT = 596;
|
internal const long EXPECTED_COLUMN_COUNT = 614;
|
||||||
internal const long EXPECTED_INDEX_COUNT = 175;
|
internal const long EXPECTED_INDEX_COUNT = 175;
|
||||||
|
|
||||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
||||||
@@ -714,21 +714,6 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
|||||||
await ExecQueryAsync("CREATE INDEX avendor_tags ON avendor using GIN(tags)");
|
await ExecQueryAsync("CREATE INDEX avendor_tags ON avendor using GIN(tags)");
|
||||||
await ExecQueryAsync("ALTER TABLE auser add FOREIGN KEY (vendorid) REFERENCES avendor(id)");
|
await ExecQueryAsync("ALTER TABLE auser add FOREIGN KEY (vendorid) REFERENCES avendor(id)");
|
||||||
|
|
||||||
//UNIT
|
|
||||||
await ExecQueryAsync("CREATE TABLE aunit (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, active bool, " +
|
|
||||||
"notes text, wiki text, customfields text, tags varchar(255) ARRAY, " +
|
|
||||||
"serial text not null, customerid bigint not null references acustomer(id), parentunitid bigint null references aunit(id), " +
|
|
||||||
"unitmodelid bigint null references aunitmodel(id), unithasownaddress bool, boughthere bool, purchasedfromvendorid bigint null references avendor(id), " +
|
|
||||||
"receipt text null, purchaseddate timestamp null, description text null, replacedbyunitid bigint null references aunit(id), " +
|
|
||||||
"overridemodelwarranty bool, warrantylength integer null, warrantyterms text null, usesbanking bool, metered bool, lifetimewarranty bool, " +
|
|
||||||
"text1 text null, text2 text null, text3 text null, text4 text null, " +
|
|
||||||
"CONSTRAINT UNQ_UnitSerialModelId UNIQUE (serial, unitmodelid) " +
|
|
||||||
" )");
|
|
||||||
|
|
||||||
await ExecQueryAsync("CREATE UNIQUE INDEX aunit_serial_id_idx ON aunit (id, serial);");
|
|
||||||
await ExecQueryAsync("CREATE INDEX aunit_tags ON aunit using GIN(tags)");
|
|
||||||
|
|
||||||
|
|
||||||
//UNITMODEL
|
//UNITMODEL
|
||||||
await ExecQueryAsync("CREATE TABLE aunitmodel (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text null, active bool, " +
|
await ExecQueryAsync("CREATE TABLE aunitmodel (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text null, active bool, " +
|
||||||
"notes text, wiki text, customfields text, tags varchar(255) ARRAY, " +
|
"notes text, wiki text, customfields text, tags varchar(255) ARRAY, " +
|
||||||
@@ -739,6 +724,20 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
|||||||
await ExecQueryAsync("CREATE INDEX aunitmodel_tags ON aunitmodel using GIN(tags)");
|
await ExecQueryAsync("CREATE INDEX aunitmodel_tags ON aunitmodel using GIN(tags)");
|
||||||
|
|
||||||
|
|
||||||
|
//UNIT
|
||||||
|
await ExecQueryAsync("CREATE TABLE aunit (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, active bool, " +
|
||||||
|
"notes text, wiki text, customfields text, tags varchar(255) ARRAY, " +
|
||||||
|
"serial text not null, customerid bigint not null references acustomer(id), parentunitid bigint null references aunit(id), " +
|
||||||
|
"unitmodelid bigint null references aunitmodel(id), unithasownaddress bool, boughthere bool, purchasedfromvendorid bigint null references avendor(id), " +
|
||||||
|
"receipt text null, purchaseddate timestamp null, description text null, replacedbyunitid bigint null references aunit(id), " +
|
||||||
|
"overridemodelwarranty bool, warrantylength integer null, warrantyterms text null, usesbanking bool, metered bool, lifetimewarranty bool, " +
|
||||||
|
"text1 text null, text2 text null, text3 text null, text4 text null, " +
|
||||||
|
"CONSTRAINT UNQ_UnitSerialModelId UNIQUE (serial, unitmodelid) " +
|
||||||
|
" )");
|
||||||
|
|
||||||
|
await ExecQueryAsync("CREATE UNIQUE INDEX aunit_serial_id_idx ON aunit (id, serial);");
|
||||||
|
await ExecQueryAsync("CREATE INDEX aunit_tags ON aunit using GIN(tags)");
|
||||||
|
|
||||||
|
|
||||||
//----------
|
//----------
|
||||||
//WORKORDER
|
//WORKORDER
|
||||||
|
|||||||
Reference in New Issue
Block a user