From 8966f0e8e4c50fd183017bb54fe4df2bd14a584c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 1 Mar 2022 20:26:05 +0000 Subject: [PATCH] --- server/AyaNova/biz/UserOptionsBiz.cs | 10 +++--- server/AyaNova/kpi/KPIFetcher.cs | 32 ++++++++----------- ...rkOrderItemLaborQuantityEveryoneSummary.cs | 5 ++- server/AyaNova/models/UserOptions.cs | 10 +++--- server/AyaNova/util/AySchema.cs | 8 ++--- server/AyaNova/util/Seeder.cs | 2 +- 6 files changed, 31 insertions(+), 36 deletions(-) diff --git a/server/AyaNova/biz/UserOptionsBiz.cs b/server/AyaNova/biz/UserOptionsBiz.cs index 0500ec5c..5cfab9da 100644 --- a/server/AyaNova/biz/UserOptionsBiz.cs +++ b/server/AyaNova/biz/UserOptionsBiz.cs @@ -135,11 +135,11 @@ namespace AyaNova.Biz AddError(ApiErrorCode.VALIDATION_REQUIRED, "UserId"); - // //Hexadecimal notation: #RGB[A] R (red), G (green), B (blue), and A (alpha) are hexadecimal characters (0–9, A–F). A is optional. The three-digit notation (#RGB) is a shorter version of the six-digit form (#RRGGBB). For example, #f09 is the same color as #ff0099. Likewise, the four-digit RGB notation (#RGBA) is a shorter version of the eight-digit form (#RRGGBBAA). For example, #0f38 is the same color as #00ff3388. - // if (inObj.UiColor.Length > 12 || inObj.UiColor.Length < 4 || inObj.UiColor[0] != '#') - // { - // AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "UiColor", "UiColor must be valid HEX color value"); - // } + //Hexadecimal notation: #RGB[A] R (red), G (green), B (blue), and A (alpha) are hexadecimal characters (0–9, A–F). A is optional. The three-digit notation (#RGB) is a shorter version of the six-digit form (#RRGGBB). For example, #f09 is the same color as #ff0099. Likewise, the four-digit RGB notation (#RGBA) is a shorter version of the eight-digit form (#RRGGBBAA). For example, #0f38 is the same color as #00ff3388. + if (inObj.UiColor.Length > 12 || inObj.UiColor.Length < 4 || inObj.UiColor[0] != '#') + { + AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "UiColor", "UiColor must be valid HEX color value"); + } return; } diff --git a/server/AyaNova/kpi/KPIFetcher.cs b/server/AyaNova/kpi/KPIFetcher.cs index 417db899..4d3dcbdb 100644 --- a/server/AyaNova/kpi/KPIFetcher.cs +++ b/server/AyaNova/kpi/KPIFetcher.cs @@ -52,7 +52,7 @@ namespace AyaNova.KPI JArray jData = new JArray(); - string sMeta = null; + JArray jMeta = new JArray(); #if (DEBUG && AYSHOWKPIQUERYINFO) System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); @@ -86,11 +86,9 @@ namespace AyaNova.KPI } } - - if (!string.IsNullOrWhiteSpace(kpi.MetaQuery)) { - //GET META DATA + //GET META DATA ROWS command.CommandText = kpi.MetaQuery; #if (DEBUG && AYSHOWQUERYINFO) stopWatch.Start(); @@ -101,14 +99,14 @@ namespace AyaNova.KPI stopWatch.Stop(); log.LogInformation($"(debug) KPIFetcher:GetResponse META query took {stopWatch.ElapsedMilliseconds}ms to execute: {qTotalRecordsQuery}"); #endif - if (dr.Read()) + while (dr.Read()) { - sMeta = dr.GetString(0); + //only one column and it's the zeroth json string column + if (!dr.IsDBNull(0)) + jMeta.Add(JObject.Parse(dr.GetString(0))); } } } - - } catch (Npgsql.PostgresException e) { @@ -133,17 +131,13 @@ namespace AyaNova.KPI throw new System.Exception("KPIFetcher:GetResponseAsync - unexpected failure see log"); } - if (!string.IsNullOrWhiteSpace(sMeta)) - return JObject.FromObject(new - { - meta = JObject.Parse(sMeta), - data = jData - }); - else - return JObject.FromObject(new - { - data = jData - }); + + return JObject.FromObject(new + { + meta = jMeta, + data = jData + }); + } } diff --git a/server/AyaNova/kpi/WorkOrderItemLaborQuantityEveryoneSummary.cs b/server/AyaNova/kpi/WorkOrderItemLaborQuantityEveryoneSummary.cs index 3a295c67..2c335596 100644 --- a/server/AyaNova/kpi/WorkOrderItemLaborQuantityEveryoneSummary.cs +++ b/server/AyaNova/kpi/WorkOrderItemLaborQuantityEveryoneSummary.cs @@ -80,7 +80,10 @@ ORDER BY X ASC ) t"; _metaQuery = @"SELECT row_to_json(t) as res from ( - select name from auser where id = 10 + select auser.id as userid, name, uicolor, usertype from auser +left outer join auseroptions on auser.id=auseroptions.userid +where auser.usertype=1 or auser.usertype=5 +order by name ) t"; } diff --git a/server/AyaNova/models/UserOptions.cs b/server/AyaNova/models/UserOptions.cs index 9c9281b9..d5ebbb4c 100644 --- a/server/AyaNova/models/UserOptions.cs +++ b/server/AyaNova/models/UserOptions.cs @@ -25,11 +25,9 @@ namespace AyaNova.Models Hexadecimal notation: #RGB[A] R (red), G (green), B (blue), and A (alpha) are hexadecimal characters (0–9, A–F). A is optional. The three-digit notation (#RGB) is a shorter version of the six-digit form (#RRGGBB). For example, #f09 is the same color as #ff0099. Likewise, the four-digit RGB notation (#RGBA) is a shorter version of the eight-digit form (#RRGGBBAA). For example, #0f38 is the same color as #00ff3388. */ - //removed for v8 alpha due to schedule not really supporting colors and - //it's kind of tacky in my opinion and outdated and it would detract from the use of colors already in teh schedule - //plus no where else does ayanova use this value so it's a lot of nothing - // [MaxLength(12)] - // public string UiColor { get; set; } + + [MaxLength(12)] + public string UiColor { get; set; } //browser forced overrides public string LanguageOverride { get; set; } @@ -52,7 +50,7 @@ namespace AyaNova.Models { CurrencyName = "USD"; Hour12 = true; - // UiColor = "#000000";//black is the default + UiColor = "#ffffff";//black is the default } } diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 4ff39411..57440a8e 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -22,16 +22,16 @@ namespace AyaNova.Util //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImportingAsync WHEN NEW TABLES ADDED!!!! private const int DESIRED_SCHEMA_LEVEL = 1; - internal const long EXPECTED_COLUMN_COUNT = 1325; + internal const long EXPECTED_COLUMN_COUNT = 1326; internal const long EXPECTED_INDEX_COUNT = 153; - internal const long EXPECTED_CHECK_CONSTRAINTS = 520; + internal const long EXPECTED_CHECK_CONSTRAINTS = 521; internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 198; internal const long EXPECTED_VIEWS = 11; internal const long EXPECTED_ROUTINES = 2; //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImportingAsync WHEN NEW TABLES ADDED!!!! - ///////////////////////////////////////// C1325:I153:CC520:FC198:V11:R2 + ///////////////////////////////////////// C1326:I153:CC521:FC198:V11:R2 @@ -617,7 +617,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); //Add user options table await ExecQueryAsync("CREATE TABLE auseroptions (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, " + "userid BIGINT NOT NULL UNIQUE REFERENCES auser (id) ON DELETE CASCADE, translationid BIGINT NOT NULL REFERENCES atranslation (id), languageoverride TEXT, timezoneoverride TEXT, " - + "currencyname TEXT, hour12 BOOL NOT NULL, emailaddress TEXT, phone1 TEXT, phone2 TEXT, phone3 TEXT, mapurltemplate TEXT)"); + + "currencyname TEXT, hour12 BOOL NOT NULL, emailaddress TEXT, phone1 TEXT, phone2 TEXT, phone3 TEXT, mapurltemplate TEXT, uicolor VARCHAR(12) NOT NULL default '#ffffff')"); //Prime the db with the default SuperUser account diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 26eec15e..84de92d6 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -1802,7 +1802,7 @@ namespace AyaNova.Util u.UserOptions.EmailAddress = bogusEmail; u.UserOptions.Hour12 = true; u.UserOptions.CurrencyName = "USD"; - //u.UserOptions.UiColor = Fake.Internet.Color().ToUpperInvariant(); + u.UserOptions.UiColor = Fake.Internet.Color().ToUpperInvariant(); //this seems wrong to get a new context inside a loop but in testing is actually faster!?