aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-01-21 13:53:00 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-01-21 13:53:00 +0200
commit63579cee4493c4a8e3d64348d644fd2eecaca055 (patch)
treebc8e92b3a2751c5fe186ad9af08d88ad8fc02628 /Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance
parent1d69ae8399a8e2419af3c4391ea387f5180561c3 (diff)
downloadTango-63579cee4493c4a8e3d64348d644fd2eecaca055.tar.gz
Tango-63579cee4493c4a8e3d64348d644fd2eecaca055.zip
PPC v1.0.0
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs61
1 files changed, 43 insertions, 18 deletions
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<bool> 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;
+ }
+
/// <summary>
/// Installs the remote assistance.
/// </summary>
@@ -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)