diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index 42f2b085..9f8c5c4f 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 5547be46..c9297d8c 100644 --- a/Step.Core/ThreadsFunctions.cs +++ b/Step.Core/ThreadsFunctions.cs @@ -804,115 +804,120 @@ public static class ThreadsFunctions // if is already running ignore if (processes.Count() == 0) if (File.Exists(ApplicationPath)) - Process.Start(ApplicationPath); - } - - foreach (M154DataModel m154 in data) - { - if(ServerStartupConfig.CMSConnectReady) - { - - if (m154.Parameters.Count() >= 2 && m154.Parameters[0] == "SOUR") { - // Convert tag string in Pascal Case and add to result string - switch (m154.Parameters[1].ToLower()) - { - case "currprog": - if (m154.Parameters.Count() < 3) - return; - RedisController.WriteProductionName(m154.Process, m154.Parameters[2]); - break; - - case "repstarget": - if (m154.Parameters.Count() < 3) - return; - RedisController.WriteProductionRepsTarget(m154.Process, m154.Parameters[2]); - break; - - case "repsdone": - if (m154.Parameters.Count() < 3) - return; - RedisController.WriteProductionRepsDone(m154.Process, m154.Parameters[2]); - break; - - default: - string notif = m154.Parameters[1]; - if (m154.Parameters.Count() > 2) - notif += m154.Parameters[2]; - RedisController.WriteProductionNotification(m154.Process, notif); - break; - } + ProcessStartInfo PSI = new ProcessStartInfo(ApplicationPath); + PSI.WorkingDirectory = new FileInfo(ApplicationPath).Directory.FullName; + Process.Start(PSI); } + } + } + + foreach (M154DataModel m154 in data) + { + if(ServerStartupConfig.CMSConnectReady) + { + + if (m154.Parameters.Count() >= 2 && m154.Parameters[0] == "SOUR") + { + // Convert tag string in Pascal Case and add to result string + switch (m154.Parameters[1].ToLower()) + { + case "currprog": + if (m154.Parameters.Count() < 3) + return; + RedisController.WriteProductionName(m154.Process, m154.Parameters[2]); + break; + + case "repstarget": + if (m154.Parameters.Count() < 3) + return; + RedisController.WriteProductionRepsTarget(m154.Process, m154.Parameters[2]); + break; + + case "repsdone": + if (m154.Parameters.Count() < 3) + return; + RedisController.WriteProductionRepsDone(m154.Process, m154.Parameters[2]); + break; + + default: + string notif = m154.Parameters[1]; + if (m154.Parameters.Count() > 2) + notif += m154.Parameters[2]; + RedisController.WriteProductionNotification(m154.Process, notif); + break; + } + } + + // Write ack + libraryError = ncHandler.WriteM154Ack((int)m154.Process); + if (libraryError.IsError()) + ManageLibraryError(libraryError); + } + else //MTC + { + string stringVal = "Path_" + m154.Process + "_"; + string val = ""; + + // Check if command is MTC + if (m154.Parameters[0] == "MTC") + { + // Convert tag string in Pascal Case and add to result string + switch (m154.Parameters[1].ToLower()) + { + case "currprog": + stringVal += "CurrProg"; + break; + + case "partid": + stringVal += "PartId"; + break; + + default: + stringVal += m154.Parameters[1]; + break; + } + // Set value + if (m154.Parameters.Count() > 2) + val = m154.Parameters[2]; + + // Create MTC Directory if not exist + if (!Directory.Exists(ServerStartupConfig.MTCFolderPath)) + Directory.CreateDirectory(ServerStartupConfig.MTCFolderPath); + + string outputFileName = ServerStartupConfig.MTCFolderPath + "\\DATA\\CmsGeneralStatus.mtc"; + // Create file if not exits + if (!File.Exists(outputFileName)) + using (var f = File.Create(outputFileName)) { }; + // Read file + List fileLines = File.ReadAllLines(outputFileName).ToList(); + string[] parametersInLine; + bool found = false; + for (int i = 0; i < fileLines.Count() && !found; i++) + { + // Get tag & value from row + parametersInLine = fileLines[i].Split('|'); + if (parametersInLine[0] == stringVal) + { + found = true; + fileLines[i] = stringVal + "|" + val; + } + } + // If tag doesn't exists, append new line + if (!found) + fileLines.Add(stringVal + "|" + val); + + // Write file + File.WriteAllLines(outputFileName, fileLines.ToArray()); // Write ack libraryError = ncHandler.WriteM154Ack((int)m154.Process); if (libraryError.IsError()) ManageLibraryError(libraryError); } - else //MTC - { - string stringVal = "Path_" + m154.Process + "_"; - string val = ""; - - // Check if command is MTC - if (m154.Parameters[0] == "MTC") - { - // Convert tag string in Pascal Case and add to result string - switch (m154.Parameters[1].ToLower()) - { - case "currprog": - stringVal += "CurrProg"; - break; - - case "partid": - stringVal += "PartId"; - break; - - default: - stringVal += m154.Parameters[1]; - break; - } - // Set value - if (m154.Parameters.Count() > 2) - val = m154.Parameters[2]; - - // Create MTC Directory if not exist - if (!Directory.Exists(ServerStartupConfig.MTCFolderPath)) - Directory.CreateDirectory(ServerStartupConfig.MTCFolderPath); - - string outputFileName = ServerStartupConfig.MTCFolderPath + "\\DATA\\CmsGeneralStatus.mtc"; - // Create file if not exits - if (!File.Exists(outputFileName)) - using (var f = File.Create(outputFileName)) { }; - // Read file - List fileLines = File.ReadAllLines(outputFileName).ToList(); - string[] parametersInLine; - bool found = false; - for (int i = 0; i < fileLines.Count() && !found; i++) - { - // Get tag & value from row - parametersInLine = fileLines[i].Split('|'); - if (parametersInLine[0] == stringVal) - { - found = true; - fileLines[i] = stringVal + "|" + val; - } - } - // If tag doesn't exists, append new line - if (!found) - fileLines.Add(stringVal + "|" + val); - - // Write file - File.WriteAllLines(outputFileName, fileLines.ToArray()); - - // Write ack - libraryError = ncHandler.WriteM154Ack((int)m154.Process); - if (libraryError.IsError()) - ManageLibraryError(libraryError); - } - } } } + } else RestoreConnection();