From dc17731a5cb959029baee9fe0edaa3f284d488e2 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 19 Jun 2020 15:32:29 +0200 Subject: [PATCH] Completed update of errors istance name --- Thermo.Active.Core/ThreadsFunctions.cs | 30 ++--- Thermo.Active.NC/NcFileAdapter.cs | 101 ++++++++-------- Thermo.Active/Controllers/SignalR/NcHub.cs | 12 +- .../WebApi/ApiMaintenanceController.cs | 48 ++++---- .../Controllers/WebApi/LanguageController.cs | 6 +- .../Controllers/WebApi/ModulesController.cs | 8 +- .../Controllers/WebApi/NcFileController.cs | 90 +++++++-------- .../Controllers/WebApi/ProdController.cs | 48 ++++---- .../Controllers/WebApi/RecipeController.cs | 109 +++++++++--------- .../Controllers/WebApi/ScadaController.cs | 18 +-- .../Controllers/WebApi/WarmersController.cs | 72 ++++++------ 11 files changed, 270 insertions(+), 272 deletions(-) diff --git a/Thermo.Active.Core/ThreadsFunctions.cs b/Thermo.Active.Core/ThreadsFunctions.cs index a4fea7f6..55299fba 100644 --- a/Thermo.Active.Core/ThreadsFunctions.cs +++ b/Thermo.Active.Core/ThreadsFunctions.cs @@ -1119,9 +1119,9 @@ public static class ThreadsFunctions ICollection cultureInfos = new List(); // Get nc available language - CmsError cmsError = ncAdapter.numericalControl.NC_GetAvailableLanguages(ref cultureInfos); - if (cmsError.IsError()) - ManageLibraryError(cmsError); + CmsError libraryError = ncAdapter.numericalControl.NC_GetAvailableLanguages(ref cultureInfos); + if (libraryError.IsError()) + ManageLibraryError(libraryError); // Filter available language with availableLanguages = availableLanguages.Where(x => cultureInfos.Any(y => y.TwoLetterISOLanguageName == x.IsoId)).ToList(); @@ -1180,15 +1180,15 @@ public static class ThreadsFunctions ThreadsHandler.Stop(); StatReset(); NcAdapter ncAdapter = new NcAdapter(); - CmsError cmsError = NO_ERROR; + CmsError libraryError = NO_ERROR; // Run loop until NC is connected while (!ncAdapter.numericalControl.NC_IsConnected()) { // Try reconnection - cmsError = ncAdapter.Connect(); - if (cmsError.errorCode == CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND || cmsError.errorCode == CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING || cmsError.errorCode == CMS_ERROR_CODES.OSAI_TT_FOLDER_NOT_FOUND) - ManageLibraryError(cmsError); - else if (cmsError.errorCode != CMS_ERROR_CODES.OK) + libraryError = ncAdapter.Connect(); + if (libraryError.errorCode == CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND || libraryError.errorCode == CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING || libraryError.errorCode == CMS_ERROR_CODES.OSAI_TT_FOLDER_NOT_FOUND) + ManageLibraryError(libraryError); + else if (libraryError.errorCode != CMS_ERROR_CODES.OK) { ncAdapter.Dispose(); } @@ -1199,7 +1199,7 @@ public static class ThreadsFunctions Thread.Sleep(1000); } - if (!cmsError.IsError()) + if (!libraryError.IsError()) { if (ServerStartupConfig.AutoOpenCmsClient) StartCMSClient(); @@ -1231,12 +1231,12 @@ public static class ThreadsFunctions ConnThread.Abort(); } - public static void ManageLibraryError(CmsError cmsError) + public static void ManageLibraryError(CmsError libraryError) { - switch (cmsError.errorCode) + switch (libraryError.errorCode) { case CMS_ERROR_CODES.NC_PROD_ERROR: - ManageError(ERROR_LEVEL.WARNING, cmsError.localizationKey); + ManageError(ERROR_LEVEL.WARNING, libraryError.localizationKey); break; case CMS_ERROR_CODES.NOT_CONNECTED: @@ -1246,7 +1246,7 @@ public static class ThreadsFunctions case CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND: case CMS_ERROR_CODES.OSAI_TT_FOLDER_NOT_FOUND: case CMS_ERROR_CODES.OPTION_NOT_CONSISTENT: - ManageError(ERROR_LEVEL.FATAL, cmsError.localizationKey); + ManageError(ERROR_LEVEL.FATAL, libraryError.localizationKey); break; case CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING: @@ -1254,11 +1254,11 @@ public static class ThreadsFunctions break; case CMS_ERROR_CODES.SELECTED_PROCESS: - ManageError(ERROR_LEVEL.WARNING, cmsError.localizationKey); + ManageError(ERROR_LEVEL.WARNING, libraryError.localizationKey); break; case CMS_ERROR_CODES.INTERNAL_ERROR: - ManageException(ERROR_LEVEL.FATAL, cmsError.exception); + ManageException(ERROR_LEVEL.FATAL, libraryError.exception); break; } } diff --git a/Thermo.Active.NC/NcFileAdapter.cs b/Thermo.Active.NC/NcFileAdapter.cs index 83366ebf..a7739b4f 100644 --- a/Thermo.Active.NC/NcFileAdapter.cs +++ b/Thermo.Active.NC/NcFileAdapter.cs @@ -83,18 +83,17 @@ namespace Thermo.Active.NC public CmsError GetFileInfo(string path, out InfoFile fileInfo) { fileInfo = new InfoFile(); - // CmsError cmsError = NO_ERROR; // if (FileExistWithNc(path)) - // cmsError = LocalPartProgramFileInfo(path, out fileInfo); + // libraryError = LocalPartProgramFileInfo(path, out fileInfo); // else - // cmsError = numericalControl.FILES_RGetFileInfo(path, ref fileInfo); + // libraryError = numericalControl.FILES_RGetFileInfo(path, ref fileInfo); - CmsError cmsError = numericalControl.FILES_RGetFileInfo(path, ref fileInfo); + CmsError libraryError = numericalControl.FILES_RGetFileInfo(path, ref fileInfo); - if (cmsError.IsError()) - return cmsError; + if (libraryError.IsError()) + return libraryError; string[] names = fileInfo.Name.Split('/'); if (names.Length > 0) @@ -128,15 +127,15 @@ namespace Thermo.Active.NC fileInfo = new DTOActiveImageAndNameDataModel(); PROGRAM_TYPE_ENUM program = PROGRAM_TYPE_ENUM.NONE; - CmsError cmsError = numericalControl.FILES_RGetProgramType(ref program); - if (cmsError.IsError()) - return cmsError; + CmsError libraryError = numericalControl.FILES_RGetProgramType(ref program); + if (libraryError.IsError()) + return libraryError; // Get selected process ushort selectedProcess = 0; - cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); - if (cmsError.IsError()) - return cmsError; + libraryError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); + if (libraryError.IsError()) + return libraryError; // JOB CASE if (program == PROGRAM_TYPE_ENUM.JOB) @@ -162,9 +161,9 @@ namespace Thermo.Active.NC else { string name = ""; - cmsError = numericalControl.PROC_RSelectedPPName(selectedProcess, ref name); - if (cmsError.IsError()) - return cmsError; + libraryError = numericalControl.PROC_RSelectedPPName(selectedProcess, ref name); + if (libraryError.IsError()) + return libraryError; fileInfo = new DTOActiveImageAndNameDataModel() { @@ -219,13 +218,13 @@ namespace Thermo.Active.NC dtoData = new DTOActiveProgramDataModel(); // Get selectedProcess process id ushort selectedProcess = 0; - CmsError cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); - if (cmsError.IsError()) - return cmsError; + CmsError libraryError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); + if (libraryError.IsError()) + return libraryError; // Read active program data ActiveProgramDataModel data = new ActiveProgramDataModel(); - cmsError = numericalControl.FILES_RActiveProgramData(selectedProcess, ref data); + libraryError = numericalControl.FILES_RActiveProgramData(selectedProcess, ref data); dtoData = new DTOActiveProgramDataModel() { @@ -234,7 +233,7 @@ namespace Thermo.Active.NC TimeLeft = data.TimeLeft }; - return cmsError; // TODO FIX OSAI + return libraryError; // TODO FIX OSAI } public CmsError SetActiveProgramInfo(string path, out DTOActiveProgramDataModel dtoData) @@ -242,12 +241,12 @@ namespace Thermo.Active.NC dtoData = new DTOActiveProgramDataModel(); // Get selectedProcess process id ushort selectedProcess = 1; - CmsError cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); - //if (cmsError.IsError()) - // return cmsError; + CmsError libraryError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); + //if (libraryError.IsError()) + // return libraryError; ActiveProgramDataModel data = new ActiveProgramDataModel(); - cmsError = numericalControl.FILES_WSetActiveProgram(selectedProcess, path, ref data); + libraryError = numericalControl.FILES_WSetActiveProgram(selectedProcess, path, ref data); dtoData = new DTOActiveProgramDataModel() { @@ -256,7 +255,7 @@ namespace Thermo.Active.NC TimeLeft = data.TimeLeft }; - return cmsError; + return libraryError; } public CmsError DeactivateProgram(out DTOActiveProgramDataModel dtoData) @@ -264,12 +263,12 @@ namespace Thermo.Active.NC dtoData = new DTOActiveProgramDataModel(); // Get selectedProcess process id ushort selectedProcess = 0; - CmsError cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); - if (cmsError.IsError()) - return cmsError; + CmsError libraryError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); + if (libraryError.IsError()) + return libraryError; ActiveProgramDataModel data = new ActiveProgramDataModel(); - cmsError = numericalControl.FILES_WDeactivateProgram(selectedProcess); + libraryError = numericalControl.FILES_WDeactivateProgram(selectedProcess); dtoData = new DTOActiveProgramDataModel() { @@ -278,21 +277,21 @@ namespace Thermo.Active.NC TimeLeft = data.TimeLeft }; - return cmsError; + return libraryError; } public CmsError UploadPartProgram(string localPath, string fileName, out string newFilePath) { // Upload to NC newFilePath = ""; - CmsError cmsError = numericalControl.FILES_UploadPartProgram(localPath, fileName, ref newFilePath); - if (cmsError.IsError()) - return cmsError; + CmsError libraryError = numericalControl.FILES_UploadPartProgram(localPath, fileName, ref newFilePath); + if (libraryError.IsError()) + return libraryError; // Delete local file File.Delete(localPath + "\\" + fileName); - return cmsError; + return libraryError; } public CmsError UploadPartProgramAndActivate(string localPath, string fileName, out ActiveProgramDataModel programData) @@ -301,16 +300,16 @@ namespace Thermo.Active.NC // Get selectedProcess id ushort selectedProcess = 0; - CmsError cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); - if (cmsError.IsError()) - return cmsError; + CmsError libraryError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); + if (libraryError.IsError()) + return libraryError; if (!JOB_EXTENSIONS.Contains(Path.GetExtension(fileName))) { // Upload to NC - cmsError = UploadPartProgram(localPath, fileName, out string newFilePath); - if (cmsError.IsError()) - return cmsError; + libraryError = UploadPartProgram(localPath, fileName, out string newFilePath); + if (libraryError.IsError()) + return libraryError; // Custom part program management //if(String.IsNullOrEmpty(CMSMainProgramContent)) @@ -335,9 +334,9 @@ namespace Thermo.Active.NC // Get selectedProcess id ushort selectedProcess = 0; - CmsError cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); - if (cmsError.IsError()) - return cmsError; + CmsError libraryError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); + if (libraryError.IsError()) + return libraryError; queueItem = new DTOQueueModel() { @@ -362,7 +361,7 @@ namespace Thermo.Active.NC queueController.UpdateQueue(); } - return cmsError; + return libraryError; } public CmsError UpdateQueue() @@ -370,7 +369,7 @@ namespace Thermo.Active.NC // Get queue data List queueData = new List(); - CmsError cmsError = numericalControl.FILES_RQueueData(ref queueData); + CmsError libraryError = numericalControl.FILES_RQueueData(ref queueData); foreach (var item in queueData) { @@ -415,14 +414,14 @@ namespace Thermo.Active.NC } else // Upload & activate new part program - cmsError = numericalControl + libraryError = numericalControl .FILES_WLoadNextPartProgram( PartProgramQueue[item.ProcessId][QueueRunningIndexes[item.ProcessId]].AbsolutePath, QUEUE_FILE_NAME ); - if (cmsError.IsError()) - return cmsError; + if (libraryError.IsError()) + return libraryError; } } } @@ -451,9 +450,9 @@ namespace Thermo.Active.NC queueList = new List(); // Get selected process ushort selectedProcess = 0; - CmsError cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); - if (cmsError.IsError()) - return cmsError; + CmsError libraryError = numericalControl.PROC_RSelectedProcess(ref selectedProcess); + if (libraryError.IsError()) + return libraryError; queueList = new List(); // Check if there is already a pp queue diff --git a/Thermo.Active/Controllers/SignalR/NcHub.cs b/Thermo.Active/Controllers/SignalR/NcHub.cs index 3816e810..fa220825 100644 --- a/Thermo.Active/Controllers/SignalR/NcHub.cs +++ b/Thermo.Active/Controllers/SignalR/NcHub.cs @@ -218,9 +218,9 @@ namespace Thermo.Active.Controllers.SignalR using (NcAdapter ncAdapter = new NcAdapter()) { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.WriteM155Data(process, responseVal); - if (cmsError.IsError()) - throw new HubException(cmsError.localizationKey); + CmsError libraryError = ncAdapter.WriteM155Data(process, responseVal); + if (libraryError.IsError()) + throw new HubException(libraryError.localizationKey); } } @@ -230,9 +230,9 @@ namespace Thermo.Active.Controllers.SignalR using (NcAdapter ncAdapter = new NcAdapter()) { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.WriteScada(memIndex, memType, value); - if (cmsError.IsError()) - throw new HubException(cmsError.localizationKey); + CmsError libraryError = ncAdapter.WriteScada(memIndex, memType, value); + if (libraryError.IsError()) + throw new HubException(libraryError.localizationKey); } } diff --git a/Thermo.Active/Controllers/WebApi/ApiMaintenanceController.cs b/Thermo.Active/Controllers/WebApi/ApiMaintenanceController.cs index 1038b45e..32479740 100644 --- a/Thermo.Active/Controllers/WebApi/ApiMaintenanceController.cs +++ b/Thermo.Active/Controllers/WebApi/ApiMaintenanceController.cs @@ -37,9 +37,9 @@ namespace Thermo.Active.Controllers.WebApi { ncAdapter.Connect(); // Get list of maintenances with user's permission - CmsError cmsError = ncAdapter.GetMaintenancesWithPermissions(out List maintenances, Convert.ToInt32(userId.Value)); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.GetMaintenancesWithPermissions(out List maintenances, Convert.ToInt32(userId.Value)); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(maintenances); } @@ -67,11 +67,11 @@ namespace Thermo.Active.Controllers.WebApi using (NcAdapter ncAdapter = new NcAdapter()) { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.GetMaintenanceDataById(dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel maintenance); - if (cmsError.IsError()) + CmsError libraryError = ncAdapter.GetMaintenanceDataById(dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel maintenance); + if (libraryError.IsError()) { maintenancesController.Delete(dbMaint); - return BadRequest(cmsError.localizationKey); + return BadRequest(libraryError.localizationKey); } PerformedMaintenanceModel performed = maintenancesController.PerformeMaintenance(maintenance.OriginalPlcCounter / 60, dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), -2); @@ -81,9 +81,9 @@ namespace Thermo.Active.Controllers.WebApi return NotFound(); } - cmsError = ncAdapter.GetMaintenanceDataById(dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel endMaintenance); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + libraryError = ncAdapter.GetMaintenanceDataById(dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel endMaintenance); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(endMaintenance); @@ -94,9 +94,9 @@ namespace Thermo.Active.Controllers.WebApi using (NcAdapter ncAdapter = new NcAdapter()) { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.GetMaintenanceDataById(dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel maintenance); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.GetMaintenanceDataById(dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel maintenance); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(maintenance); } @@ -139,9 +139,9 @@ namespace Thermo.Active.Controllers.WebApi using (NcAdapter ncAdapter = new NcAdapter()) { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.GetMaintenanceDataById(dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel maintenance); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.GetMaintenanceDataById(dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel maintenance); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(maintenance); } @@ -198,18 +198,18 @@ namespace Thermo.Active.Controllers.WebApi using (NcAdapter ncAdapter = new NcAdapter()) { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.GetMaintenanceDataById(maintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel maintData); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.GetMaintenanceDataById(maintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel maintData); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); if (!maintData.CanPerform) return Unauthorized(); using (MaintenancesController maintenancesController = new MaintenancesController()) { - cmsError = ncAdapter.GetNcGenericData(out DTONcGenericDataModel data); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + libraryError = ncAdapter.GetNcGenericData(out DTONcGenericDataModel data); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); int controlWord = -1; if (maintData.CreatedByCms) @@ -225,9 +225,9 @@ namespace Thermo.Active.Controllers.WebApi if (performed == null) return NotFound(); - cmsError = ncAdapter.GetMaintenanceDataById(maintenanceId, Convert.ToInt32(userId.Value), out maintData); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + libraryError = ncAdapter.GetMaintenanceDataById(maintenanceId, Convert.ToInt32(userId.Value), out maintData); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(maintData); } diff --git a/Thermo.Active/Controllers/WebApi/LanguageController.cs b/Thermo.Active/Controllers/WebApi/LanguageController.cs index 06d0ac3a..c4cc269a 100644 --- a/Thermo.Active/Controllers/WebApi/LanguageController.cs +++ b/Thermo.Active/Controllers/WebApi/LanguageController.cs @@ -27,9 +27,9 @@ namespace Thermo.Active.Controllers.WebApi ICollection cultureInfos = new List(); // Get nc available language - CmsError cmsError = ncAdapter.numericalControl.NC_GetAvailableLanguages(ref cultureInfos); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.numericalControl.NC_GetAvailableLanguages(ref cultureInfos); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); // Filter available language with availableLanguages = availableLanguages.Where(x => cultureInfos.Any(y => y.TwoLetterISOLanguageName == x.IsoId)).ToList(); } diff --git a/Thermo.Active/Controllers/WebApi/ModulesController.cs b/Thermo.Active/Controllers/WebApi/ModulesController.cs index 22927ded..4c5fe34d 100644 --- a/Thermo.Active/Controllers/WebApi/ModulesController.cs +++ b/Thermo.Active/Controllers/WebApi/ModulesController.cs @@ -33,11 +33,11 @@ namespace Thermo.Active.Controllers.WebApi return InternalServerError(); } - CmsError cmsError = ncAdapter.ReadModulesBlock(out Dictionary currModules); - if (cmsError.IsError()) + libraryError = ncAdapter.ReadModulesBlock(out Dictionary currModules); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"GetRecipeOverview error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"GetRecipeOverview error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } return Ok(currModules); diff --git a/Thermo.Active/Controllers/WebApi/NcFileController.cs b/Thermo.Active/Controllers/WebApi/NcFileController.cs index fb9b3c08..fd743aee 100644 --- a/Thermo.Active/Controllers/WebApi/NcFileController.cs +++ b/Thermo.Active/Controllers/WebApi/NcFileController.cs @@ -25,9 +25,9 @@ namespace Thermo.Active.Controllers.WebApi { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.GetFileList(filePath, out List fileList); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.GetFileList(filePath, out List fileList); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(fileList); } @@ -40,9 +40,9 @@ namespace Thermo.Active.Controllers.WebApi { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.GetFileInfo(filePath, out InfoFile fileInfo); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.GetFileInfo(filePath, out InfoFile fileInfo); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(fileInfo); } @@ -55,9 +55,9 @@ namespace Thermo.Active.Controllers.WebApi { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.GetActiveFileInfo(filePath, out DTOActiveImageAndNameDataModel fileInfo); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.GetActiveFileInfo(filePath, out DTOActiveImageAndNameDataModel fileInfo); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(fileInfo); } @@ -70,9 +70,9 @@ namespace Thermo.Active.Controllers.WebApi { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.SetActiveProgramInfo(filePath, out DTOActiveProgramDataModel fileInfo); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.SetActiveProgramInfo(filePath, out DTOActiveProgramDataModel fileInfo); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(fileInfo); } @@ -85,9 +85,9 @@ namespace Thermo.Active.Controllers.WebApi { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.DeactivateProgram(out DTOActiveProgramDataModel fileInfo); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.DeactivateProgram(out DTOActiveProgramDataModel fileInfo); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(fileInfo); } @@ -114,9 +114,9 @@ namespace Thermo.Active.Controllers.WebApi if (NcConfig.NcVendor == NC_VENDOR.OSAI) { // Clean upload folder only OSAI - CmsError cmsError = ncFileHandler.CleanUploadFolder(); - if (cmsError.IsError() && cmsError.errorCode != CMS_ERROR_CODES.FILE_NOT_FOUND) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncFileHandler.CleanUploadFolder(); + if (libraryError.IsError() && libraryError.errorCode != CMS_ERROR_CODES.FILE_NOT_FOUND) + return BadRequest(libraryError.localizationKey); } ActiveProgramDataModel programData = new ActiveProgramDataModel(); @@ -130,9 +130,9 @@ namespace Thermo.Active.Controllers.WebApi programs.Add(item.FileName); // Upload main program - CmsError cmsError = ncFileHandler.UploadPartProgramAndActivate(TEMP_PP_FOLDER, item.FileName, out programData); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncFileHandler.UploadPartProgramAndActivate(TEMP_PP_FOLDER, item.FileName, out programData); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); mainPPName = Path.GetFileNameWithoutExtension(programData.Path); } @@ -142,9 +142,9 @@ namespace Thermo.Active.Controllers.WebApi programs.Add(item.FileName); // Upload files - CmsError cmsError = ncFileHandler.UploadPartProgram(TEMP_PP_FOLDER, item.FileName, out string programPath); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncFileHandler.UploadPartProgram(TEMP_PP_FOLDER, item.FileName, out string programPath); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); } else if (item.ParameterName == "image") { @@ -348,9 +348,9 @@ namespace Thermo.Active.Controllers.WebApi if (repsParam == null || !int.TryParse(repsParam.Value, out int reps)) return BadRequest(); // Upload - CmsError cmsError = ncAdapter.UploadPartProgramAndAddToQueue(QUEUE_TMP_FOLDER, item.FileName, reps, out queueItem); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.UploadPartProgramAndAddToQueue(QUEUE_TMP_FOLDER, item.FileName, reps, out queueItem); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); } } else if (item.ParameterName == "image") @@ -370,9 +370,9 @@ namespace Thermo.Active.Controllers.WebApi { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.RemoveFromQueue(processId, itemId); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.RemoveFromQueue(processId, itemId); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); } return Ok(); @@ -383,9 +383,9 @@ namespace Thermo.Active.Controllers.WebApi { using (NcFileAdapter ncAdapter = new NcFileAdapter()) { - CmsError cmsError = ncAdapter.MoveQueueItems(processId, itemsPositions.ObjectId, itemsPositions.NewPosition, out List queue); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.MoveQueueItems(processId, itemsPositions.ObjectId, itemsPositions.NewPosition, out List queue); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(queue); } @@ -399,9 +399,9 @@ namespace Thermo.Active.Controllers.WebApi if (reps.Reps < 1) return BadRequest(INCORRECT_PARAMETERS_ERROR.localizationKey); - CmsError cmsError = ncAdapter.EditQueueItemReps(processId, itemId, reps.Reps, out DTOQueueModel queueItem); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.EditQueueItemReps(processId, itemId, reps.Reps, out DTOQueueModel queueItem); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(queueItem); } @@ -412,9 +412,9 @@ namespace Thermo.Active.Controllers.WebApi { using (NcFileAdapter ncAdapter = new NcFileAdapter()) { - CmsError cmsError = ncAdapter.EmptyQueue(processId); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.EmptyQueue(processId); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(); } @@ -427,9 +427,9 @@ namespace Thermo.Active.Controllers.WebApi { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.StartWorkingQueue(processId); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.StartWorkingQueue(processId); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(); } @@ -442,9 +442,9 @@ namespace Thermo.Active.Controllers.WebApi { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.StopWorkingQueue(processId); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.StopWorkingQueue(processId); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); return Ok(); } diff --git a/Thermo.Active/Controllers/WebApi/ProdController.cs b/Thermo.Active/Controllers/WebApi/ProdController.cs index e9175d5d..571bc186 100644 --- a/Thermo.Active/Controllers/WebApi/ProdController.cs +++ b/Thermo.Active/Controllers/WebApi/ProdController.cs @@ -40,11 +40,11 @@ namespace Thermo.Active.Controllers.WebApi } // scrivo sul PLC il comando strobe richiesta AUTO! - CmsError cmsError = ncAdapter.StrobeMode(Model.DTOModels.ThermoProd.Mode.MANUAL); - if (cmsError.IsError()) + libraryError = ncAdapter.StrobeMode(Model.DTOModels.ThermoProd.Mode.MANUAL); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"RequestManual error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"RequestManual error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // ritorno solo fatto! @@ -69,11 +69,11 @@ namespace Thermo.Active.Controllers.WebApi } // scrivo sul PLC il comando strobe richiesta AUTO! - CmsError cmsError = ncAdapter.StrobeMode(Model.DTOModels.ThermoProd.Mode.AUTO); - if (cmsError.IsError()) + libraryError = ncAdapter.StrobeMode(Model.DTOModels.ThermoProd.Mode.AUTO); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"RequestAuto error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"RequestAuto error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // ritorno solo fatto! @@ -98,11 +98,11 @@ namespace Thermo.Active.Controllers.WebApi } // scrivo sul PLC il comando strobe richiesta AUTO! - CmsError cmsError = ncAdapter.StrobeMode(Model.DTOModels.ThermoProd.Mode.SETUP); - if (cmsError.IsError()) + libraryError = ncAdapter.StrobeMode(Model.DTOModels.ThermoProd.Mode.SETUP); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"RequestSetup error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"RequestSetup error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // ritorno solo fatto! @@ -129,11 +129,11 @@ namespace Thermo.Active.Controllers.WebApi } // scrivo sul PLC il comando strobe richiesta AUTO! - CmsError cmsError = ncAdapter.UpdateProdInfoData((short)requestQty, newWorkOrder); - if (cmsError.IsError()) + libraryError = ncAdapter.UpdateProdInfoData((short)requestQty, newWorkOrder); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"StartProd error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"StartProd error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // ritorno solo fatto! @@ -158,11 +158,11 @@ namespace Thermo.Active.Controllers.WebApi } // scrivo sul PLC il comando strobe richiesta AUTO! - CmsError cmsError = ncAdapter.ReadProdInfoData(out ThermoModels.ProdInfoModel prodInfoDat); - if (cmsError.IsError()) + libraryError = ncAdapter.ReadProdInfoData(out ThermoModels.ProdInfoModel prodInfoDat); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"GetProd error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"GetProd error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // ritorno solo fatto! @@ -187,11 +187,11 @@ namespace Thermo.Active.Controllers.WebApi } // scrivo sul PLC il comando strobe richiesta AUTO! - CmsError cmsError = ncAdapter.GetHistProdInfoData(out List prodInfoDataList, indexStart, numRecord); - if (cmsError.IsError()) + libraryError = ncAdapter.GetHistProdInfoData(out List prodInfoDataList, indexStart, numRecord); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"GetHistory error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"GetHistory error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // ritorno solo fatto! diff --git a/Thermo.Active/Controllers/WebApi/RecipeController.cs b/Thermo.Active/Controllers/WebApi/RecipeController.cs index 50011adc..bfb7ba55 100644 --- a/Thermo.Active/Controllers/WebApi/RecipeController.cs +++ b/Thermo.Active/Controllers/WebApi/RecipeController.cs @@ -34,11 +34,11 @@ namespace Thermo.Active.Controllers.WebApi return InternalServerError(); } - CmsError cmsError = ncAdapter.GetRecipeOverview(out Dictionary currOverview); - if (cmsError.IsError()) + libraryError = ncAdapter.GetRecipeOverview(out Dictionary currOverview); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"GetRecipeOverview error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"GetRecipeOverview error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } return Ok(currOverview); @@ -57,11 +57,11 @@ namespace Thermo.Active.Controllers.WebApi return InternalServerError(); } - CmsError cmsError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); - if (cmsError.IsError()) + libraryError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"GetRecipeOverview error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"GetRecipeOverview error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } return Ok(currRecipe); @@ -86,11 +86,11 @@ namespace Thermo.Active.Controllers.WebApi } // read recipe! - CmsError cmsError = ncAdapter.ReadFullRecipe(out Dictionary prevRecipe); - if (cmsError.IsError()) + libraryError = ncAdapter.ReadFullRecipe(out Dictionary prevRecipe); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"GetRecipeOverview error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"GetRecipeOverview error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } Dictionary updtRecipe = new Dictionary(); @@ -152,19 +152,19 @@ namespace Thermo.Active.Controllers.WebApi } // scrivo sul PLC il comando conferma! - CmsError cmsError = ncAdapter.ConfirmRecipeData(true); - if (cmsError.IsError()) + libraryError = ncAdapter.ConfirmRecipeData(true); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"ConfirmEdit error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"ConfirmEdit error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // recupero i dati LIVE dei parametri HMI della ricetta... - cmsError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); - if (cmsError.IsError()) + libraryError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"ConfirmEdit error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"ConfirmEdit error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // rileggo la ricetta @@ -208,19 +208,19 @@ namespace Thermo.Active.Controllers.WebApi } // scrivo sul PLC il comando annula! - CmsError cmsError = ncAdapter.ConfirmRecipeData(false); - if (cmsError.IsError()) + libraryError = ncAdapter.ConfirmRecipeData(false); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"ConfirmEdit error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"ConfirmEdit error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // recupero i dati LIVE dei parametri HMI della ricetta... - cmsError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); - if (cmsError.IsError()) + libraryError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"ConfirmEdit error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"ConfirmEdit error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } var currParams = new Dictionary(); @@ -262,7 +262,6 @@ namespace Thermo.Active.Controllers.WebApi } // chiamo metodo di lettura... - //CmsError cmsError = ServerConfigController.LoadRecipe(newName); bool fatto = ServerConfigController.LoadRecipe(newName); if (!fatto) { @@ -270,11 +269,11 @@ namespace Thermo.Active.Controllers.WebApi return NotFound(); } - CmsError cmsError = WriteCurrentRecipeToPlc(); - if (cmsError.IsError()) + libraryError = WriteCurrentRecipeToPlc(); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"ConfirmEdit error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"ConfirmEdit error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // ritorno solo fatto! @@ -300,11 +299,11 @@ namespace Thermo.Active.Controllers.WebApi return NotFound(); } - CmsError cmsError = WriteCurrentRecipeToPlc(); - if (cmsError.IsError()) + CmsError libraryError = WriteCurrentRecipeToPlc(); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"ConfirmEdit error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"ConfirmEdit error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } } @@ -323,9 +322,9 @@ namespace Thermo.Active.Controllers.WebApi { // recupero i dati LIVE dei parametri HMI della ricetta... - CmsError cmsError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); var currParams = new Dictionary(); foreach (var item in currRecipe) @@ -350,11 +349,11 @@ namespace Thermo.Active.Controllers.WebApi using (NcFileAdapter ncAdapter = new NcFileAdapter()) { // recupero i dati LIVE dei parametri HMI della ricetta... - CmsError cmsError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); - if (cmsError.IsError()) + CmsError libraryError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"SaveAs error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"SaveAs error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } var currParams = new Dictionary(); @@ -382,20 +381,20 @@ namespace Thermo.Active.Controllers.WebApi using (NcFileAdapter ncAdapter = new NcFileAdapter()) { // recupero i dati LIVE dei parametri HMI della ricetta... - CmsError cmsError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); - if (cmsError.IsError()) + CmsError libraryError = ncAdapter.ReadFullRecipe(out Dictionary currRecipe); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"SaveTemplate error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"SaveTemplate error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // recupero i dati LIVE dei carichi load dei cahnnels di riscaldo... - cmsError = ncAdapter.ReadWarmers(out Dictionary currWarmers); - if (cmsError.IsError()) + libraryError = ncAdapter.ReadWarmers(out Dictionary currWarmers); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"ReadWarmers error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"ReadWarmers error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // uso i valopri HMI... @@ -512,10 +511,10 @@ namespace Thermo.Active.Controllers.WebApi } // enable recipe! scrivo sul PLC il comando conferma! - CmsError cmsError = ncAdapter.ConfirmRecipeData(true); - if (cmsError.IsError()) + libraryError = ncAdapter.ConfirmRecipeData(true); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"ReadWarmers error | {cmsError.exception}"); + ThermoActiveLogger.LogError($"ReadWarmers error | {libraryError.exception}"); return checkError; } } diff --git a/Thermo.Active/Controllers/WebApi/ScadaController.cs b/Thermo.Active/Controllers/WebApi/ScadaController.cs index fdce1c0b..a222fc7d 100644 --- a/Thermo.Active/Controllers/WebApi/ScadaController.cs +++ b/Thermo.Active/Controllers/WebApi/ScadaController.cs @@ -41,9 +41,9 @@ namespace Thermo.Active.Controllers.WebApi { ncAdapter.Connect(); // Read the selected scada data - CmsError cmsError = ncAdapter.ReadScadaData(selectedScadaSchema, out DTOScadaModel values); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.ReadScadaData(selectedScadaSchema, out DTOScadaModel values); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); // Add to the subscriber list SubscribedScada.Add(selectedScadaSchema); @@ -77,9 +77,9 @@ namespace Thermo.Active.Controllers.WebApi using(NcAdapter ncAdapter = new NcAdapter()) { ncAdapter.Connect(); - CmsError cmsError = ncAdapter.ReadScadasData(ProductionScadaSchema, out List values); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.ReadScadasData(ProductionScadaSchema, out List values); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); ScadaDataAndSchema data = new ScadaDataAndSchema() @@ -150,9 +150,9 @@ namespace Thermo.Active.Controllers.WebApi if (memIndex == "") return BadRequest(INCORRECT_PARAMETERS_ERROR.localizationKey); - CmsError cmsError = ncAdapter.WriteScada(memIndex, memType, value); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); + CmsError libraryError = ncAdapter.WriteScada(memIndex, memType, value); + if (libraryError.IsError()) + return BadRequest(libraryError.localizationKey); } return Ok(); diff --git a/Thermo.Active/Controllers/WebApi/WarmersController.cs b/Thermo.Active/Controllers/WebApi/WarmersController.cs index cad3695c..2e2a5124 100644 --- a/Thermo.Active/Controllers/WebApi/WarmersController.cs +++ b/Thermo.Active/Controllers/WebApi/WarmersController.cs @@ -34,11 +34,11 @@ namespace Thermo.Active.Controllers.WebApi return InternalServerError(); } - CmsError cmsError = ncAdapter.ReadWarmers(out Dictionary currWarmers); - if (cmsError.IsError()) + libraryError = ncAdapter.ReadWarmers(out Dictionary currWarmers); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"GetRecipeOverview error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"GetRecipeOverview error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } return Ok(currWarmers); @@ -57,11 +57,11 @@ namespace Thermo.Active.Controllers.WebApi return InternalServerError(); } - CmsError cmsError = ncAdapter.GetWarmersResistances(out Dictionary currWarmers); - if (cmsError.IsError()) + libraryError = ncAdapter.GetWarmersResistances(out Dictionary currWarmers); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"GetCurrentWarmersResistances error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"GetCurrentWarmersResistances error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } return Ok(currWarmers); @@ -82,11 +82,11 @@ namespace Thermo.Active.Controllers.WebApi } // recupera aree % X / Y - CmsError cmsError = ncAdapter.GetWarmMaterialArea(out Dictionary currAreaPerc); - if (cmsError.IsError()) + libraryError = ncAdapter.GetWarmMaterialArea(out Dictionary currAreaPerc); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"GetCurrentAreaPerc error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"GetCurrentAreaPerc error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } return Ok(currAreaPerc); @@ -110,11 +110,11 @@ namespace Thermo.Active.Controllers.WebApi return InternalServerError(); } // scrivo sul PLC - CmsError cmsError = ncAdapter.WriteRecipeWarmChSetpHMI(channelsLoad); - if (cmsError.IsError()) + libraryError = ncAdapter.WriteRecipeWarmChSetpHMI(channelsLoad); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"WriteSetpoints error | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"WriteSetpoints error | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // ritorno solo fatto! @@ -145,19 +145,19 @@ namespace Thermo.Active.Controllers.WebApi } // scrivo sul PLC il comando conferma! - CmsError cmsError = ncAdapter.ConfirmRecipeData(true); - if (cmsError.IsError()) + libraryError = ncAdapter.ConfirmRecipeData(true); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"Warmers ConfirmEdit error | ConfirmRecipeData | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"Warmers ConfirmEdit error | ConfirmRecipeData | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // recupero i dati LIVE dei parametri HMI dei riscaldi... - cmsError = ncAdapter.ReadWarmers(out Dictionary currWarmers); - if (cmsError.IsError()) + libraryError = ncAdapter.ReadWarmers(out Dictionary currWarmers); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"Warmers ConfirmEdit error | ReadWarmers | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"Warmers ConfirmEdit error | ReadWarmers | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // rileggo la ricetta @@ -192,19 +192,19 @@ namespace Thermo.Active.Controllers.WebApi } // scrivo sul PLC il comando annula! - CmsError cmsError = ncAdapter.ConfirmRecipeData(false); - if (cmsError.IsError()) + libraryError = ncAdapter.ConfirmRecipeData(false); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"Warmers CancelEdit error | ConfirmRecipeData | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"Warmers CancelEdit error | ConfirmRecipeData | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // recupero i dati LIVE dei parametri HMI dei riscaldi... - cmsError = ncAdapter.ReadWarmers(out Dictionary currWarmers); - if (cmsError.IsError()) + libraryError = ncAdapter.ReadWarmers(out Dictionary currWarmers); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"Warmers ConfirmEdit error | ReadWarmers | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"Warmers ConfirmEdit error | ReadWarmers | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // rileggo la ricetta @@ -237,11 +237,11 @@ namespace Thermo.Active.Controllers.WebApi } // scrivo sul PLC - CmsError cmsError = ncAdapter.WriteRecipeWarmConfig(); - if (cmsError.IsError()) + libraryError = ncAdapter.WriteRecipeWarmConfig(); + if (libraryError.IsError()) { - ThermoActiveLogger.LogError($"Warmers SetConfig error | WriteRecipeWarmConfig | {cmsError.exception}"); - return BadRequest(cmsError.localizationKey); + ThermoActiveLogger.LogError($"Warmers SetConfig error | WriteRecipeWarmConfig | {libraryError.exception}"); + return BadRequest(libraryError.localizationKey); } // ritorno solo fatto!