Changed Client manager on Server

This commit is contained in:
Nicola Carminati
2019-05-17 09:33:53 +02:00
parent 1b377d0e36
commit 43b3d87ad6
12 changed files with 86 additions and 65 deletions
+33 -15
View File
@@ -978,8 +978,6 @@ public static class ThreadsFunctions
Thread.Sleep(1000);
}
if (ServerStartupConfig.AutoOpenCmsClient)
StartCMSClient(null);
if(NcConfig.NcVendor == NC_VENDOR.FANUC || NcConfig.NcVendor == NC_VENDOR.OSAI)
@@ -994,11 +992,15 @@ public static class ThreadsFunctions
// cmsError = toolTable.RestoreTableLock();
}
}
// Start/Restart NC threads
ThreadsHandler.StartWorkers();
if (!cmsError.IsError())
{
if (ServerStartupConfig.AutoOpenCmsClient)
StartCMSClient();
reconnectionIsRunning = false;
// Start/Restart NC threads
ThreadsHandler.StartWorkers();
reconnectionIsRunning = false;
}
}
public static void RestoreConnection()
@@ -1163,22 +1165,38 @@ public static class ThreadsFunctions
return sleep;
}
public static void StartCMSClient(string url)
public static void StartCMSClient()
{
//Setup the Path Variable
string CMSClientPath = "";
if (!ClientIsRunning())
{
// Check if the system is 64/32 bit
if (Environment.Is64BitOperatingSystem && File.Exists(CLIENT_PATH_64))
CMSClientPath = CLIENT_PATH_64;
else if (File.Exists(CLIENT_PATH_86))
CMSClientPath = CLIENT_PATH_86;
if (!String.IsNullOrEmpty(CMSClientPath))
Process.Start(CMSClientPath, url);
ThreadsHandler.StartClient = new Thread(() => clientProcess());
ThreadsHandler.StartClient.Start();
}
}
private static void clientProcess()
{
string CMSClientPath = "";
// Check if the system is 64/32 bit
if (Environment.Is64BitOperatingSystem && File.Exists(CLIENT_PATH_64))
CMSClientPath = CLIENT_PATH_64;
else if (File.Exists(CLIENT_PATH_86))
CMSClientPath = CLIENT_PATH_86;
if (!String.IsNullOrEmpty(CMSClientPath))
{
Process pr = Process.Start(CMSClientPath, null);
if (ServerStartupConfig.AutoOpenCmsClient)
{
pr.WaitForExit();
MessageServices.Current.Publish(SEND_STOP_SERVER);
}
}
}
private static bool ClientIsRunning()
{
Process[] p = Process.GetProcessesByName(CLIENT_EXE_NAME_NOEXT);