diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index e7b2efc3..ef12a8f5 100644 Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ diff --git a/Step.Core/ThreadsFunctions.cs b/Step.Core/ThreadsFunctions.cs index 70a4d55d..a9c7946c 100644 --- a/Step.Core/ThreadsFunctions.cs +++ b/Step.Core/ThreadsFunctions.cs @@ -1003,7 +1003,7 @@ public static class ThreadsFunctions break; case CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING: - Manage(ERROR_LEVEL.FATAL, cmsError.localizationKey); + Manage(ERROR_LEVEL.FATAL, "SIEMENS HMI NOT RUNNING"); break; case CMS_ERROR_CODES.INTERNAL_ERROR: diff --git a/Step.Database/Controllers/MachinesUsersController.cs b/Step.Database/Controllers/MachinesUsersController.cs index 32a0d8ef..9e7c8896 100644 --- a/Step.Database/Controllers/MachinesUsersController.cs +++ b/Step.Database/Controllers/MachinesUsersController.cs @@ -70,7 +70,7 @@ namespace Step.Database.Controllers .Where(x => x.MachineId == machineId && x.UserId == userId) // Find by machine id and user id, joining with role .FirstOrDefault(); - if(machineUser != null) + if (machineUser != null) { RoleModel role = machineUser.Role; return new DTORoleModel() @@ -83,7 +83,6 @@ namespace Step.Database.Controllers return null; } - public bool UserIsCmsAdmin(int machineId, int userId) { MachineUserModel user = FindByUserId(machineId, userId); @@ -93,7 +92,6 @@ namespace Step.Database.Controllers return false; } - public int CompareUsersRole(int firstUserId, int secondUserId, int machineId) { MachineUserModel firstUser = FindByUserId(machineId, firstUserId); diff --git a/Step.Database/Controllers/MaintenancesController.cs b/Step.Database/Controllers/MaintenancesController.cs index b9caa86f..67f1bf4a 100644 --- a/Step.Database/Controllers/MaintenancesController.cs +++ b/Step.Database/Controllers/MaintenancesController.cs @@ -2,6 +2,7 @@ using Step.Model.DTOModels; using Step.Model.DTOModels.MaintenanceModels; using System; +using System.Collections; using System.Collections.Generic; using System.Data.Entity; using System.IO; @@ -356,5 +357,75 @@ namespace Step.Database.Controllers } #endregion Attachment + + + private void GetDataFromMaintenancePassword(string password, out int number, out int hours, out int cw) + { + string tmpPassword1 = "", + tmpPassword3 = "", + tmpPassword4 = "", + tmpPassword5 = ""; + int controlNumber = 0; + + Hashtable htCifrario = new Hashtable + { + { "K", "0" }, + { "M", "1" }, + { "X", "2" }, + { "N", "3" }, + { "G", "4" }, + { "V", "5" }, + { "P", "6" }, + { "Z", "7" }, + { "H", "8" }, + { "Q", "9" } + }; + + // Create tmpPassword5 changing characters that matches with characters in the hashtable + foreach (char c in password) + { + if (htCifrario.Contains(c)) + tmpPassword5 += htCifrario[c].ToString(); // Change character with hashtable val + else + tmpPassword5 += c; + } + + // Get control number + controlNumber = Convert.ToInt32(Right(tmpPassword5, 1)); + tmpPassword4 = tmpPassword5.Remove(tmpPassword5.Length - 1); + + // Create tmpPassoword3 + foreach(char c in tmpPassword4) + { + // If tmpPassword is empty copy the first character + if(tmpPassword3.Length == 0) + { + tmpPassword3 = c.ToString(); + } + else + { + // Check if character is a number + if (char.IsNumber(c)) + // Add first digit of -> Number + 10 - control number + tmpPassword3 += Right((Convert.ToInt32(c) + 10 - controlNumber).ToString(), 1); + else + tmpPassword3 += c.ToString(); + } + } + + tmpPassword1 = tmpPassword3.PadLeft(11, '0'); + hours = Convert.ToInt32(tmpPassword1.Substring(0, 5), 16); // Convert from hexadecimal + number = Convert.ToInt32(tmpPassword1.Substring(5, 4), 16); // Convert from hexadecimal + cw = Convert.ToInt32(tmpPassword1.Substring(9, 2), 16); // Convert from hexadecimal + } + + private static string Right(string value, int size) + { + // if length is greater than "size" resets "size" + size = (value.Length < size ? value.Length : size); + // Substring is the equivalent of VB NET RIGHT + string newValue = value.Substring(value.Length - size); + return newValue; + } } } \ No newline at end of file diff --git a/Step.Utils/ExceptionManager.cs b/Step.Utils/ExceptionManager.cs index 8e207723..3a74d0d6 100644 --- a/Step.Utils/ExceptionManager.cs +++ b/Step.Utils/ExceptionManager.cs @@ -43,6 +43,8 @@ namespace Step.Utils Manage(errorLevel, exception.Message); } + private static bool MessageBoxShow = false; + public static void Manage(ERROR_LEVEL errorLevel, string message) { switch (errorLevel) @@ -70,16 +72,24 @@ namespace Step.Utils case ERROR_LEVEL.FATAL: { LogFatal(message); - NotifyUsers(CreateMessageModel("Fatal Error!", message, ERROR_LEVEL.FATAL)); - // Close the application - Environment.Exit(1); + if (!MessageBoxShow) + { + MessageBoxShow = true; + NotifyUsers(CreateMessageModel("Fatal Error!", message, ERROR_LEVEL.FATAL)); + // Close the application + Environment.Exit(1); + } }break; default: { LogFatal(message); - NotifyUsers(CreateMessageModel("Generic Error!", message, ERROR_LEVEL.FATAL)); - // Close the application - Environment.Exit(1); + if (!MessageBoxShow) + { + MessageBoxShow = true; + NotifyUsers(CreateMessageModel("Generic Error!", message, ERROR_LEVEL.FATAL)); + // Close the application + Environment.Exit(1); + } } break; } @@ -92,19 +102,12 @@ namespace Step.Utils NotifyUsers(error); } - private static bool MessageBoxShow = false; - private static void NotifyUsers(ErrorMessageModel error) { if (error.ErrorLevel > (int)ERROR_LEVEL.WARNING) { - if (!MessageBoxShow) - { - MessageBoxShow = true; - - // Notify user - MessageBox.Show(error.Message, error.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); - } + // Notify user + MessageBox.Show(error.Message, error.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { diff --git a/Step/Controllers/WebApi/FavoriteUserSoftKeyController.cs b/Step/Controllers/WebApi/FavoriteUserSoftKeyController.cs index 39b03ce8..e6ee69c0 100644 --- a/Step/Controllers/WebApi/FavoriteUserSoftKeyController.cs +++ b/Step/Controllers/WebApi/FavoriteUserSoftKeyController.cs @@ -53,7 +53,5 @@ namespace Step.Controllers.WebApi return Ok(favorite); } } - - } } diff --git a/Step/wwwroot/src/app_modules/machine/components/m155-dialog.vue b/Step/wwwroot/src/app_modules/machine/components/m155-dialog.vue index 47cf80c0..147b145d 100644 --- a/Step/wwwroot/src/app_modules/machine/components/m155-dialog.vue +++ b/Step/wwwroot/src/app_modules/machine/components/m155-dialog.vue @@ -1,8 +1,8 @@