diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index 5b097c2a..cd76ced8 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -210,7 +210,6 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } - public static void ReadAlarms() { NcAdapter ncAdapter = new NcAdapter(); @@ -254,7 +253,6 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } - public static void ReadPowerOnData() { NcAdapter ncAdapter = new NcAdapter(); @@ -296,7 +294,6 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } - public static void ReadProcessesPPStatus() { NcAdapter ncAdapter = new NcAdapter(); @@ -350,7 +347,6 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } - public static void ReadEnabledFunctionality() { NcAdapter ncAdapter = new NcAdapter(); @@ -394,7 +390,6 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } - public static void ReadExpiredMaintenances() { NcAdapter ncAdapter = new NcAdapter(); @@ -450,7 +445,6 @@ public static class ThreadsFunctions } } - public static void ReadUserSoftKeysData() { NcAdapter ncAdapter = new NcAdapter(); @@ -494,7 +488,6 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } - public static void ReadAxesNamesData() { NcAdapter ncAdapter = new NcAdapter(); @@ -538,7 +531,6 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } - public static void ReadAxesPositionsData() { NcAdapter ncAdapter = new NcAdapter(); @@ -582,7 +574,6 @@ public static class ThreadsFunctions ncAdapter.Dispose(); } } - public static void ReadScadaData() { NcAdapter ncAdapter = new NcAdapter(); @@ -1256,7 +1247,6 @@ public static class ThreadsFunctions reconnectionIsRunning = false; } } - public static void RestoreConnection() { if (reconnectionIsRunning == false) @@ -1271,13 +1261,11 @@ public static class ThreadsFunctions ConnThread.Start(); } } - public static void AbortNcConnection() { if (ConnThread != null && ConnThread.IsAlive) ConnThread.Abort(); } - public static void ManageLibraryError(CmsError libraryError) { switch (libraryError.errorCode) @@ -1309,7 +1297,6 @@ public static class ThreadsFunctions break; } } - internal static void UpdateStat(string functionName, long timer) { if (!Timers.ContainsKey(functionName)) @@ -1323,7 +1310,6 @@ public static class ThreadsFunctions else Counter[functionName]++; } - internal static void StatThread() { while (true) @@ -1343,7 +1329,6 @@ public static class ThreadsFunctions Thread.Sleep(2000); } } - private static void StatReset() { foreach (var value in Counter) @@ -1352,7 +1337,6 @@ public static class ThreadsFunctions Counter[value.Key] = 0; } } - private static int CalcSleepTime(int maxSleep, int execTime) { int sleep = 0; @@ -1378,7 +1362,6 @@ public static class ThreadsFunctions ThreadsHandler.StartClient.Start(); } } - private static void clientProcess() { string CMSClientPath = ""; @@ -1399,7 +1382,6 @@ public static class ThreadsFunctions } } } - private static bool ClientIsRunning() { Process[] p = Process.GetProcessesByName(CLIENT_EXE_NAME_NOEXT); @@ -1414,7 +1396,6 @@ public static class ThreadsFunctions } return false; } - private static Dictionary GetPlcAlarmsTranslations(string language) { using (NcAdapter ncAdapter = new NcAdapter()) diff --git a/Thermo.Active.Database/Migrations/Configuration.cs b/Thermo.Active.Database/Migrations/Configuration.cs index fb926f21..c0c193b7 100644 --- a/Thermo.Active.Database/Migrations/Configuration.cs +++ b/Thermo.Active.Database/Migrations/Configuration.cs @@ -53,7 +53,8 @@ namespace Thermo.Active.Database.Migrations new FunctionAccessModel() { Name = "scadaArea", Area = GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = 0 }, new FunctionAccessModel() { Name = "usersArea", Area = GENERAL_KEY, Enabled = true, WriteLevelMin = 30, ReadLevelMin = 1, PlcId = 0 }, new FunctionAccessModel() { Name = "jobeditorArea", Area = GENERAL_KEY, Enabled = true, WriteLevelMin = 20, ReadLevelMin = 1, PlcId = 0 }, - new FunctionAccessModel() { Name = "utilitiesArea", Area = GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = 0 } + new FunctionAccessModel() { Name = "utilitiesArea", Area = GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = 0 }, + new FunctionAccessModel() { Name = RECIPE_MANAGER, Area = GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = 0 } ); context.SaveChanges(); diff --git a/Thermo.Active.Model/Constants.cs b/Thermo.Active.Model/Constants.cs index 7c5ff9df..bf6fa060 100644 --- a/Thermo.Active.Model/Constants.cs +++ b/Thermo.Active.Model/Constants.cs @@ -347,6 +347,7 @@ namespace Thermo.Active.Model public const string AXES_SELECTION = "axesSoftkeys"; public const string THERMO_MANAGER = "thermoManager"; public const string RISC_MANAGER = "riscManager"; + public const string RECIPE_MANAGER = "thermoRecipeManager"; } public static class API_ERROR_KEYS diff --git a/Thermo.Active/Controllers/WebApi/RecipeController.cs b/Thermo.Active/Controllers/WebApi/RecipeController.cs index 1a98d457..1ce8f766 100644 --- a/Thermo.Active/Controllers/WebApi/RecipeController.cs +++ b/Thermo.Active/Controllers/WebApi/RecipeController.cs @@ -314,10 +314,10 @@ namespace Thermo.Active.Controllers.WebApi /// /// [Route("save"), HttpPut] - //[WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.USER_FUNCTIONS, Action = ACTIONS.READ)] + [WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.RECIPE_MANAGER, Action = ACTIONS.READ)] public IHttpActionResult Save() { -#if false + int currUserId = 0; // recupero dati utente loggato var identity = User.Identity as ClaimsIdentity; // Find user id from the bearer token @@ -328,9 +328,8 @@ namespace Thermo.Active.Controllers.WebApi using (UsersController usersController = new UsersController()) { var userData = usersController.GetUserInfo(Convert.ToInt32(userId.Value)); + currUserId = userData.Id; } -#endif - // recupero i dati LIVE dei parametri HMI della ricetta... @@ -357,6 +356,19 @@ namespace Thermo.Active.Controllers.WebApi [Route("saveAs"), HttpPut] public IHttpActionResult SaveAs(string newName) { +#if false + // recupero dati utente loggato + var identity = User.Identity as ClaimsIdentity; + // Find user id from the bearer token + var userId = identity.Claims.FirstOrDefault(c => c.Type == USER_ID_KEY); + if (userId == null) + return Unauthorized(); + + using (UsersController usersController = new UsersController()) + { + var userData = usersController.GetUserInfo(Convert.ToInt32(userId.Value)); + } +#endif // recupero i dati LIVE dei parametri HMI della ricetta... CmsError libraryError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); if (libraryError.IsError()) @@ -458,8 +470,23 @@ namespace Thermo.Active.Controllers.WebApi [Route("saveAll"), HttpPost] + //[WebApiAuthorize(FunctionAccess = FUNCTIONALITY_NAMES.USER_FUNCTIONS, Action = ACTIONS.READ)] public async Task SaveAll(string newName, double estimTimeSec) { +#if false + // recupero dati utente loggato + var identity = User.Identity as ClaimsIdentity; + // Find user id from the bearer token + var userId = identity.Claims.FirstOrDefault(c => c.Type == USER_ID_KEY); + if (userId == null) + return Unauthorized(); + + using (UsersController usersController = new UsersController()) + { + var userData = usersController.GetUserInfo(Convert.ToInt32(userId.Value)); + } +#endif + bool imageUploaded = false; if (!Request.Content.IsMimeMultipartContent())