From c4154994f7944e4ece6f555e822c1568165197f2 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 24 Apr 2019 23:05:37 +0000 Subject: [PATCH] --- server/AyaNova/Startup.cs | 2 +- server/AyaNova/biz/BizRoles.cs | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index 611aea24..34479299 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -383,7 +383,7 @@ namespace AyaNova // ******************** TESTING WIPE DB ***************************** // //Set this to true to wipe the db and reinstall a trial license and re-seed the data - var TESTING_REFRESH_DB = true;//####################################################################################### + var TESTING_REFRESH_DB = false;//####################################################################################### #if (DEBUG) //TESTING diff --git a/server/AyaNova/biz/BizRoles.cs b/server/AyaNova/biz/BizRoles.cs index f12369bc..4397ff45 100644 --- a/server/AyaNova/biz/BizRoles.cs +++ b/server/AyaNova/biz/BizRoles.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using AyaNova.Biz; + namespace AyaNova.Biz { @@ -16,7 +17,7 @@ namespace AyaNova.Biz static BizRoles() { //TODO: change this entire block to work off a fragment of JSON that can be shared with the Client side project as well - + //Add all object roles here //NOTE: do not need to add change roles to read roles, Authorized.cs takes care of that automatically //by assuming if you can change you can read @@ -94,8 +95,8 @@ namespace AyaNova.Biz ReadFullRecord = AuthorizationRoles.OpsAdminFull | AuthorizationRoles.OpsAdminLimited }); - - + + //////////////////////////////////////////////////////////// //OPERATIONS / JOBS @@ -166,6 +167,33 @@ namespace AyaNova.Biz #endregion all roles init + #region output as JSON for client side +#if (DEBUG) + + //################## HOW TO USE ########## + //############## Uncomment SerializeObject line, put a break on lastRoles, copy from the output in the LOG (good for javascript with quotes formatted that way) ####### + // #### NEED to separately take a copy and update "lastRoles" string here by copying from the variable watch in the debugger because need the C# format escaped quotes string + + //GENERATE JSON FROM ROLES + string json = Newtonsoft.Json.JsonConvert.SerializeObject(roles, Newtonsoft.Json.Formatting.None); + + //Output roles JSON FRAGMENT string for CLIENT to log + System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", json); + + //ONGOING VALIDATION TO CATCH MISMATCH WHEN NEW ROLES ADDED (wont' catch changes to existing unfortunately) + var lastRoles = "{\r\n \"User\": {\r\n \"Change\": 2,\r\n \"EditOwn\": 0,\r\n \"ReadFullRecord\": 1\r\n },\r\n \"UserOptions\": {\r\n \"Change\": 2,\r\n \"EditOwn\": 0,\r\n \"ReadFullRecord\": 1\r\n },\r\n \"Widget\": {\r\n \"Change\": 34,\r\n \"EditOwn\": 256,\r\n \"ReadFullRecord\": 17\r\n },\r\n \"ServerState\": {\r\n \"Change\": 16384,\r\n \"EditOwn\": 0,\r\n \"ReadFullRecord\": 32767\r\n },\r\n \"License\": {\r\n \"Change\": 16386,\r\n \"EditOwn\": 0,\r\n \"ReadFullRecord\": 8193\r\n },\r\n \"LogFile\": {\r\n \"Change\": 0,\r\n \"EditOwn\": 0,\r\n \"ReadFullRecord\": 24576\r\n },\r\n \"JobOperations\": {\r\n \"Change\": 16384,\r\n \"EditOwn\": 0,\r\n \"ReadFullRecord\": 8195\r\n },\r\n \"AyaNova7Import\": {\r\n \"Change\": 16384,\r\n \"EditOwn\": 0,\r\n \"ReadFullRecord\": 0\r\n },\r\n \"Metrics\": {\r\n \"Change\": 0,\r\n \"EditOwn\": 0,\r\n \"ReadFullRecord\": 24576\r\n },\r\n \"Locale\": {\r\n \"Change\": 16386,\r\n \"EditOwn\": 0,\r\n \"ReadFullRecord\": 32767\r\n },\r\n \"DataFilter\": {\r\n \"Change\": 2,\r\n \"EditOwn\": 32767,\r\n \"ReadFullRecord\": 32767\r\n },\r\n \"FormCustom\": {\r\n \"Change\": 2,\r\n \"EditOwn\": 0,\r\n \"ReadFullRecord\": 32767\r\n }\r\n}"; + Dictionary lastRolesDeserialized = Newtonsoft.Json.JsonConvert.DeserializeObject>(lastRoles); + if (lastRolesDeserialized.Count != roles.Count) + { + throw new System.ArgumentException("BizRoles::Constructor - roles were modified from last snapshot for client!!!"); + } + + +#endif + #endregion + + + }//end of constructor