Fleshing otu workorder

This commit is contained in:
2020-05-03 22:55:45 +00:00
parent b9da7a45b6
commit ff54daac8f
7 changed files with 78 additions and 117 deletions

View File

@@ -383,13 +383,13 @@ namespace AyaNova.Util
await ExecQueryAsync("CREATE INDEX avendor_tags ON avendor using GIN(tags)");
//WORKORDER
await ExecQueryAsync("CREATE TABLE aworkorder (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " +
await ExecQueryAsync("CREATE TABLE aworkorder (id BIGSERIAL PRIMARY KEY, serial bigint not null, active bool, " +
"notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)");
await ExecQueryAsync("CREATE UNIQUE INDEX aworkorder_name_id_idx ON aworkorder (id, name);");
await ExecQueryAsync("CREATE INDEX aworkorder_number_id_idx ON aworkorder (id, serial);");
await ExecQueryAsync("CREATE INDEX aworkorder_tags ON aworkorder using GIN(tags)");
//WORKORDERITEM
await ExecQueryAsync("CREATE TABLE aworkorderitem (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " +
await ExecQueryAsync("CREATE TABLE aworkorderitem (id BIGSERIAL PRIMARY KEY, workorderid bigint not null REFERENCES aworkorder (id), name varchar(255) not null unique, active bool, " +
"notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)");
await ExecQueryAsync("CREATE UNIQUE INDEX aworkorderitem_name_id_idx ON aworkorderitem (id, name);");
await ExecQueryAsync("CREATE INDEX aworkorderitem_tags ON aworkorderitem using GIN(tags)");

View File

@@ -15,9 +15,9 @@ namespace AyaNova.Util
//AUTOID's
//Get the highest id number issued previously and start the auto-id at that level
//Get the most recent id number issued previously and start the auto-id at that level
internal static AutoId WIDGET_SERIAL { get; set; }
internal static AutoId WORKORDER_SERIAL { get; set; }
//Diagnostic static values used during development, may not be related to config at all, this is just a convenient class to put them in
#if (DEBUG)
@@ -226,12 +226,22 @@ namespace AyaNova.Util
//query for most recently used serial number
//(note, can't query for highest serial as it can and likely will reset or be changed manually from time to time
// so the algorithm is to keep the most recent sequence going on startup of the server)
var MostRecentWidget = ct.Widget.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
uint MaxWidgetId = 0;
if (MostRecentWidget != null)
MaxWidgetId = MostRecentWidget.Serial;
WIDGET_SERIAL = new AutoId(MaxWidgetId);
var serializedObject = ct.Widget.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
WIDGET_SERIAL = new AutoId(serializedObject == null ? 0 : serializedObject.Serial);
// var MostRecentWidget = ct.Widget.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
// uint MaxWidgetId = 0;
// if (MostRecentWidget != null)
// MaxWidgetId = MostRecentWidget.Serial;
// WIDGET_SERIAL = new AutoId(MaxWidgetId);
}
//Workorder
if (WORKORDER_SERIAL == null)
{
var serializedObject = ct.WorkOrder.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
WORKORDER_SERIAL = new AutoId(serializedObject == null ? 0 : serializedObject.Serial);
}
//OTHER SERIALS HERE IN FUTURE...