From 63579cee4493c4a8e3d64348d644fd2eecaca055 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 21 Jan 2019 13:53:00 +0200 Subject: PPC v1.0.0 --- .../DefaultRemoteAssistanceProvider.cs | 61 +++++++++++++++------- 1 file changed, 43 insertions(+), 18 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs index 040546b59..e8d19aa20 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs @@ -94,6 +94,36 @@ namespace Tango.PPC.Common.RemoteAssistance } } + private async Task IsRemoteAssistanceInstalled() + { + bool exist = false; + + for (int i = 0; i < 6; i++) + { + LogManager.Log("Checking remote assistance service..."); + await Task.Delay(1000); + CmdCommand command = new CmdCommand("sc.exe", "query TeamViewer"); + try + { + await command.Run(); + exist = true; + break; + } + catch { } + } + + if (exist) + { + LogManager.Log("Remote assistance service found."); + } + else + { + LogManager.Log("Remote assistance service was not found."); + } + + return exist; + } + /// /// Installs the remote assistance. /// @@ -108,31 +138,26 @@ namespace Tango.PPC.Common.RemoteAssistance throw new FileNotFoundException($"The remote assistance installer file could not be found at {_installer_path}."); } - CmdCommand command = new CmdCommand("msiexec.exe", $"/i \"{_installer_path}\" /qn CUSTOMCONFIGID=ke43ann APITOKEN=4765529-gon1LwO1N1TTrlLI21ji ASSIGNMENTOPTIONS=\" --reassign --alias {"TANGO-" + machineSerialNumber} --grant-easy-access\""); - await command.Run(); + if (!(await IsRemoteAssistanceInstalled())) + { + CmdCommand command = new CmdCommand("msiexec.exe", $"/i \"{_installer_path}\" /qn CUSTOMCONFIGID=ke43ann APITOKEN=4765529-gon1LwO1N1TTrlLI21ji ASSIGNMENTOPTIONS=\" --reassign --alias {"TANGO-" + machineSerialNumber} --grant-easy-access\""); + command.Timeout = TimeSpan.FromSeconds(30); + await command.Run(); - bool exist = false; + bool exist = await IsRemoteAssistanceInstalled(); - for (int i = 0; i < 6; i++) - { - await Task.Delay(1000); - command = new CmdCommand("sc.exe", "query TeamViewer"); - try + if (exist) { - await command.Run(); - exist = true; - break; + await DisableRemoteAssistance(); + } + else + { + throw new ApplicationException("The remote assistance service was installed but could not be found."); } - catch { } - } - - if (exist) - { - await DisableRemoteAssistance(); } else { - throw new ApplicationException("The remote assistance service was installed but could not be found."); + LogManager.Log("Remote assistance is already installed."); } } catch (Exception ex) -- cgit v1.3.1