diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-12-12 18:23:24 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-12-12 18:23:24 +0200 |
| commit | d9a89773f2f283fbf5596799dd4d50d231817203 (patch) | |
| tree | d213bc8024342356dc54654235b77decbdbd26b8 /Software/Visual_Studio | |
| parent | de0b06ac48e9765914f4e07c0e03497033066296 (diff) | |
| download | Tango-d9a89773f2f283fbf5596799dd4d50d231817203.tar.gz Tango-d9a89773f2f283fbf5596799dd4d50d231817203.zip | |
IHotSpot Provider & IRemoteAssistance Provider.
Diffstat (limited to 'Software/Visual_Studio')
23 files changed, 612 insertions, 115 deletions
diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk Binary files differindex 2577f9a96..83636b215 100644 --- a/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk +++ b/Software/Visual_Studio/Build/Shortcuts/Machine Emulator.lnk diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk Binary files differindex fe3b0d60c..fdcc9c9f3 100644 --- a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk +++ b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk diff --git a/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk b/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk Binary files differindex a1cb5f5c1..bbe8a4be2 100644 --- a/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk +++ b/Software/Visual_Studio/Build/Shortcuts/Proto Compiler GUI.lnk diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index b9c27e4f9..4fba0cc0b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -740,7 +740,11 @@ <Image Source="../Images/ruler.png" Width="32"></Image> <TextBlock VerticalAlignment="Center" Margin="5 0 0 0" FontSize="10">Segment Length</TextBlock> </StackPanel> - <mahapps:NumericUpDown x:Name="numSegmentLength" FontSize="{StaticResource NumbersFontSize}" HideUpDownButtons="True" Width="90" HorizontalAlignment="Left" FontFamily="{StaticResource digital-7}" StringFormat="{}{0:N1} m" Margin="0 2 0 0" Minimum="1" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0 0 0 1" BorderBrush="DimGray" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding SelectedSegment.Length,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></mahapps:NumericUpDown> + <mahapps:NumericUpDown x:Name="numSegmentLength" FontSize="{StaticResource NumbersFontSize}" HideUpDownButtons="True" Width="90" HorizontalAlignment="Left" FontFamily="{StaticResource digital-7}" StringFormat="{}{0:N1} m" Margin="0 2 0 0" Minimum="1" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0 0 0 1" BorderBrush="DimGray" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding SelectedSegment.Length,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"> + <mahapps:NumericUpDown.Resources> + <StaticResource ResourceKey="SelectAllTextBoxResource"></StaticResource> + </mahapps:NumericUpDown.Resources> + </mahapps:NumericUpDown> </StackPanel> </Border> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs index 267012e2e..7c6bed928 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs @@ -72,6 +72,13 @@ namespace Tango.PPC.MachineSettings.ViewModels set { _externalBridgePassword = value; RaisePropertyChangedAuto(); } } + private bool _enableRemoteAssistance; + public bool EnableRemoteAssistance + { + get { return _enableRemoteAssistance; } + set { _enableRemoteAssistance = value; RaisePropertyChangedAuto(); OnEnableRemoteAssistanceChanged(); } + } + #endregion #region Commands @@ -137,13 +144,54 @@ namespace Tango.PPC.MachineSettings.ViewModels Machine = new Machine(); MachineProvider.Machine.ShallowCopyTo(Machine); RaisePropertyChanged(nameof(Machine)); - _enableHotSpot = ConnectivityProvider.IsHotspotActive; + + _enableHotSpot = HotSpotProvider.IsEnabled; RaisePropertyChanged(nameof(EnableHotSpot)); + HotSpotPassword = Settings.HotSpotPassword; + + _enableExternalBridge = ExternalBridgeService.Enabled; + RaisePropertyChanged(nameof(EnableExternalBridge)); + + ExternalBridgePassword = Settings.ExternalBridgePassword; + + _enableRemoteAssistance = RemoteAssistanceProvider.IsEnabled; + RaisePropertyChanged(nameof(EnableRemoteAssistance)); + SelectedJobTypes = new SelectedObjectCollection<JobTypes>(Enum.GetValues(typeof(JobTypes)).Cast<JobTypes>().ToObservableCollection(), Machine.SupportedJobTypes.ToObservableCollection()); } + private async void OnEnableRemoteAssistanceChanged() + { + if (EnableRemoteAssistance) + { + try + { + await RemoteAssistanceProvider.EnableRemoteAssistance(); + } + catch + { + await NotificationProvider.ShowError("An error occurred while trying to activate the remote assistance service. Please check your device settings and try again."); + _enableRemoteAssistance = false; + } + } + else + { + try + { + await RemoteAssistanceProvider.DisableRemoteAssistance(); + } + catch + { + await NotificationProvider.ShowError("An error occurred while trying to deactivate the remote assistance service. Please check your device settings and try again."); + _enableRemoteAssistance = true; + } + } + + RaisePropertyChanged(nameof(EnableRemoteAssistance)); + } + private async void OnEnableHotSpotChanged() { if (EnableHotSpot) @@ -158,7 +206,7 @@ namespace Tango.PPC.MachineSettings.ViewModels try { - await ConnectivityProvider.EnableHotSpot(HotSpotPassword); + await HotSpotProvider.EnableHotSpot(HotSpotPassword); } catch { @@ -170,7 +218,7 @@ namespace Tango.PPC.MachineSettings.ViewModels { try { - await ConnectivityProvider.DisableHotSpot(); + await HotSpotProvider.DisableHotSpot(); } catch { diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml index 7a64891c9..337647790 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml @@ -108,6 +108,14 @@ </controls:TableGrid> </touch:TouchExpander> + + <!--REMOTE ASSISTANCE--> + <touch:TouchExpander Margin="0 20 0 0" Header="Remote Assistance" IsExpanded="True" FontSize="{StaticResource TangoExpanderHeaderFontSize}"> + <controls:TableGrid Margin="10" RowHeight="70" MakeFirstColumnVerticalAlignmentBottom="False" TextElement.FontSize="{StaticResource TangoDefaultFontSize}"> + <TextBlock VerticalAlignment="Center">Enable Remote Assistance</TextBlock> + <touch:TouchToggleSlider Style="{StaticResource TangoToggleButtonGrayAccent}" HorizontalAlignment="Right" Margin="0 0 110 0" Width="90" IsChecked="{Binding EnableRemoteAssistance}"></touch:TouchToggleSlider> + </controls:TableGrid> + </touch:TouchExpander> </StackPanel> </touch:LightTouchScrollViewer> </Grid> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/IConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/IConnectivityProvider.cs index 077f05110..85c25128a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/IConnectivityProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/IConnectivityProvider.cs @@ -79,23 +79,5 @@ namespace Tango.PPC.Common.Connectivity /// <param name="network">The network.</param> /// <returns></returns> void Disconnect(WiFiNetwork network); - - /// <summary> - /// Gets a value indicating whether the hot spot network is active. - /// </summary> - bool IsHotspotActive { get; } - - /// <summary> - /// Enables the hot spot. - /// </summary> - /// <param name="password">The password.</param> - /// <returns></returns> - Task EnableHotSpot(String password); - - /// <summary> - /// Disables the hot spot. - /// </summary> - /// <returns></returns> - Task DisableHotSpot(); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs new file mode 100644 index 000000000..1126a84bc --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.PPC.Common.Application; +using Tango.PPC.Common.Connection; +using Tango.PPC.Common.Scripting; +using Tango.Settings; + +namespace Tango.PPC.Common.HotSpot +{ + /// <summary> + /// Represents the default hot spot provider. + /// </summary> + /// <seealso cref="Tango.Core.ExtendedObject" /> + /// <seealso cref="Tango.PPC.Common.HotSpot.IHotSpotProvider" /> + public class DefaultHotSpotProvider : ExtendedObject, IHotSpotProvider + { + private IMachineProvider _machineProvider; + + private bool _isEnabled; + /// <summary> + /// Gets a value indicating whether the hot spot network is active. + /// </summary> + public bool IsEnabled + { + get { return _isEnabled; } + private set { _isEnabled = value; RaisePropertyChangedAuto(); } + } + + /// <summary> + /// Initializes a new instance of the <see cref="DefaultHotSpotProvider"/> class. + /// </summary> + /// <param name="applicationManager">The application manager.</param> + /// <param name="machineProvider">The machine provider.</param> + public DefaultHotSpotProvider(IPPCApplicationManager applicationManager, IMachineProvider machineProvider) + { + _machineProvider = machineProvider; + applicationManager.ApplicationReady += ApplicationManager_ApplicationReady; + } + + /// <summary> + /// Handles the ApplicationReady event of the ApplicationManager. + /// </summary> + /// <param name="sender">The source of the event.</param> + /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> + private void ApplicationManager_ApplicationReady(object sender, EventArgs e) + { + Task.Factory.StartNew(async () => + { + var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); + + if (settings.EnableHotSpot) + { + try + { + await EnableHotSpot(settings.HotSpotPassword); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error starting on application startup."); + } + } + }); + } + + /// <summary> + /// Enables the hot spot. + /// </summary> + /// <param name="password">The password.</param> + /// <returns></returns> + public async Task EnableHotSpot(string password) + { + if (!IsEnabled) + { + try + { + CmdCommand command = new CmdCommand("netsh", $"wlan set hostednetwork mode=allow ssid='{"Tango_" + _machineProvider.Machine.SerialNumber}' key='{password}'"); + await command.Run(); + IsEnabled = true; + } + catch (Exception ex) + { + LogManager.Log(ex, "Error activating hot spot."); + throw; + } + } + } + + /// <summary> + /// Disables the hot spot. + /// </summary> + /// <returns></returns> + public async Task DisableHotSpot() + { + if (IsEnabled) + { + try + { + CmdCommand command = new CmdCommand("netsh", "wlan stop hosted network"); + await command.Run(); + IsEnabled = false; + } + catch (Exception ex) + { + LogManager.Log(ex, "Error deactivating hot spot."); + throw; + } + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/IHotSpotProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/IHotSpotProvider.cs new file mode 100644 index 000000000..1a4dabae3 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/IHotSpotProvider.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.HotSpot +{ + /// <summary> + /// Represents a hot-spot network provider. + /// </summary> + public interface IHotSpotProvider + { + /// <summary> + /// Gets a value indicating whether the hot spot network is active. + /// </summary> + bool IsEnabled { get; } + + /// <summary> + /// Enables the hot spot. + /// </summary> + /// <param name="password">The password.</param> + /// <returns></returns> + Task EnableHotSpot(String password); + + /// <summary> + /// Disables the hot spot. + /// </summary> + /// <returns></returns> + Task DisableHotSpot(); + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index 3c70e0744..3d816c89a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -74,14 +74,25 @@ namespace Tango.PPC.Common.MachineSetup { LogManager.Log($"Starting machine setup for serial number {serialNumber}..."); - //Connecting to machine... - LogManager.Log("Initiating machine connection..."); + IMachineOperator op = null; - UpdateProgress("Connecting to machine", "Connecting..."); - IMachineOperator op = await DefaultMachineProvider.CreateMinimalMachineOperator((msg) => + var demoMode = SettingsManager.Default.GetOrCreate<PPCSettings>().DemoMode; + + if (!demoMode) { - UpdateProgress("Connecting to machine", msg); - }); + //Connecting to machine... + LogManager.Log("Initiating machine connection..."); + + UpdateProgress("Connecting to machine", "Connecting..."); + op = await DefaultMachineProvider.CreateMinimalMachineOperator((msg) => + { + UpdateProgress("Connecting to machine", msg); + }); + } + else + { + LogManager.Log("Application in demo mode. Skipping machine connection..."); + } //Connect to machine service and get matching packages for this machine. UpdateProgress("Downloading software package", "Connecting to machine service..."); @@ -238,39 +249,50 @@ namespace Tango.PPC.Common.MachineSetup throw LogManager.Log(ex, "Setup manager error while trying to synchronize database."); } - //Updating firmware - UpdateProgress("Updating Firmware", "Connecting to firmware device..."); - LogManager.Log(""); - LogManager.Log("-------------------------------------------------------------------------"); - LogManager.Log("Updating Firmware..."); - - UpdateProgress("Updating Firmware", "Loading firmware package..."); - var tfpPath = Path.Combine(_newPackageTempFolder, "firmware_package.tfp"); - var stream = new FileStream(tfpPath, FileMode.Open); - var handler = await op.UpgradeFirmware(stream); - handler.Failed += (_, ex) => + if (!demoMode) { - stream.Dispose(); - result.SetException(ex); - }; - handler.Completed += (_, __) => + //Updating firmware + UpdateProgress("Updating Firmware", "Connecting to firmware device..."); + LogManager.Log(""); + LogManager.Log("-------------------------------------------------------------------------"); + LogManager.Log("Updating Firmware..."); + + UpdateProgress("Updating Firmware", "Loading firmware package..."); + var tfpPath = Path.Combine(_newPackageTempFolder, "firmware_package.tfp"); + var stream = new FileStream(tfpPath, FileMode.Open); + var handler = await op.UpgradeFirmware(stream); + handler.Failed += (_, ex) => + { + stream.Dispose(); + result.SetException(ex); + }; + handler.Completed += (_, __) => + { + UpdateProgress("Updating Firmware", "Firmware update completed successfully."); + stream.Dispose(); + result.SetResult(new MachineSetupResult() + { + UpdatePackagePath = _newPackageTempFolder, + }); + }; + handler.Canceled += (_, __) => + { + stream.Dispose(); + result.SetException(new Exception("The operation has been canceled.")); + }; + handler.Progress += (_, e) => + { + UpdateProgress("Updating Firmware", e.Message, false, e.Current, e.Total); + }; + } + else { - UpdateProgress("Updating Firmware", "Firmware update completed successfully."); - stream.Dispose(); + LogManager.Log("Application in demo mode. Skipping firmware upgrade..."); result.SetResult(new MachineSetupResult() { UpdatePackagePath = _newPackageTempFolder, }); - }; - handler.Canceled += (_, __) => - { - stream.Dispose(); - result.SetException(new Exception("The operation has been canceled.")); - }; - handler.Progress += (_, e) => - { - UpdateProgress("Updating Firmware", e.Message, false, e.Current, e.Total); - }; + } } catch (Exception ex) { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index b6ab9c163..142c3afe9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -81,6 +81,11 @@ namespace Tango.PPC.Common public String HotSpotPassword { get; set; } /// <summary> + /// Gets or sets a value indicating whether to enable team viewer service. + /// </summary> + public bool EnableRemoteAssistance { get; set; } + + /// <summary> /// Initializes a new instance of the <see cref="PPCSettings"/> class. /// </summary> public PPCSettings() diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs index dc67d2137..289683855 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs @@ -11,9 +11,11 @@ using Tango.PPC.Common.Connection; using Tango.PPC.Common.Connectivity; using Tango.PPC.Common.EventLogging; using Tango.PPC.Common.ExternalBridge; +using Tango.PPC.Common.HotSpot; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; using Tango.PPC.Common.Printing; +using Tango.PPC.Common.RemoteAssistance; using Tango.PPC.Common.Storage; using Tango.Settings; using Tango.SharedUI; @@ -84,6 +86,18 @@ namespace Tango.PPC.Common public IConnectivityProvider ConnectivityProvider { get; set; } /// <summary> + /// Gets or sets the hot spot provider. + /// </summary> + [TangoInject] + public IHotSpotProvider HotSpotProvider { get; set; } + + /// <summary> + /// Gets or sets the remote assistance provider. + /// </summary> + [TangoInject] + public IRemoteAssistanceProvider RemoteAssistanceProvider { get; set; } + + /// <summary> /// Gets or sets the storage provider. /// </summary> [TangoInject] diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs new file mode 100644 index 000000000..53596544a --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/DefaultRemoteAssistanceProvider.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.PPC.Common.Connection; +using Tango.PPC.Common.Scripting; + +namespace Tango.PPC.Common.RemoteAssistance +{ + /// <summary> + /// Represents the default remote assistance provider. + /// </summary> + /// <seealso cref="Tango.Core.ExtendedObject" /> + /// <seealso cref="Tango.PPC.Common.RemoteAssistance.IRemoteAssistanceProvider" /> + public class DefaultRemoteAssistanceProvider : ExtendedObject, IRemoteAssistanceProvider + { + private IMachineProvider _machineProvider; + + private bool _isEnabled; + /// <summary> + /// Gets a value indicating whether the remote assistance service is enabled. + /// </summary> + public bool IsEnabled + { + get { return _isEnabled; } + private set { _isEnabled = value; RaisePropertyChangedAuto(); } + } + + /// <summary> + /// Initializes a new instance of the <see cref="DefaultRemoteAssistanceProvider"/> class. + /// </summary> + /// <param name="machineProvider">The machine provider.</param> + public DefaultRemoteAssistanceProvider(IMachineProvider machineProvider) + { + _machineProvider = machineProvider; + } + + /// <summary> + /// Enables the remote assistance. + /// </summary> + /// <returns></returns> + public async Task EnableRemoteAssistance() + { + if (!IsEnabled) + { + try + { + CmdCommand command = new CmdCommand("sc.exe", "config TeamViewer start=auto"); + command.Timeout = TimeSpan.FromSeconds(10); + await command.Run(); + + command = new CmdCommand("net", "start TeamViewer"); + command.Timeout = TimeSpan.FromSeconds(10); + await command.Run(); + + IsEnabled = true; + } + catch (Exception ex) + { + LogManager.Log(ex, "Error enabling remote assistance."); + throw; + } + } + } + + /// <summary> + /// Disables the remote assistance. + /// </summary> + /// <returns></returns> + public async Task DisableRemoteAssistance() + { + if (IsEnabled) + { + try + { + CmdCommand command = new CmdCommand("sc.exe", "config TeamViewer start=disabled"); + command.Timeout = TimeSpan.FromSeconds(10); + await command.Run(); + + command = new CmdCommand("net", "stop TeamViewer"); + command.Timeout = TimeSpan.FromSeconds(10); + await command.Run(); + IsEnabled = false; + } + catch (Exception ex) + { + LogManager.Log(ex, "Error disabling remote assistance."); + throw; + } + } + } + + /// <summary> + /// Installs the remote assistance. + /// </summary> + /// <param name="groupName">Name of the group.</param> + /// <param name="computerName">Name of the computer.</param> + /// <returns></returns> + public async Task InstallRemoteAssistance(string groupName, string computerName) + { + try + { + CmdCommand command = new CmdCommand("msiexec.exe", $"/i \"C:\\Program Files(x86)\\TeamViewer\\TeamViewer_Host.msi\" /qn CUSTOMCONFIGID=ke43ann APITOKEN=4765529-gon1LwO1N1TTrlLI21ji ASSIGNMENTOPTIONS=\" --reassign --alias {"TANGO-" + _machineProvider.Machine.SerialNumber} --grant-easy-access\""); + await command.Run(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error installing remote assistance."); + throw; + } + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/IRemoteAssistanceProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/IRemoteAssistanceProvider.cs new file mode 100644 index 000000000..288b5c652 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteAssistance/IRemoteAssistanceProvider.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.RemoteAssistance +{ + /// <summary> + /// Represents a remote assistance provider. + /// </summary> + public interface IRemoteAssistanceProvider + { + /// <summary> + /// Gets a value indicating whether the remote assistance service is enabled. + /// </summary> + bool IsEnabled { get; } + + /// <summary> + /// Enables the remote assistance. + /// </summary> + /// <returns></returns> + Task EnableRemoteAssistance(); + + /// <summary> + /// Disables the remote assistance. + /// </summary> + /// <returns></returns> + Task DisableRemoteAssistance(); + + /// <summary> + /// Installs the remote assistance. + /// </summary> + /// <param name="groupName">Name of the group.</param> + /// <param name="computerName">Name of the computer.</param> + /// <returns></returns> + Task InstallRemoteAssistance(String groupName, String computerName); + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Scripting/CmdCommand.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Scripting/CmdCommand.cs index 2ee0d83d9..abae98f06 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Scripting/CmdCommand.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Scripting/CmdCommand.cs @@ -29,6 +29,7 @@ namespace Tango.PPC.Common.Scripting _process.StartInfo.RedirectStandardError = true; _process.StartInfo.RedirectStandardOutput = true; _process.StartInfo.Arguments = arguments; + _process.StartInfo.Verb = "runas"; Arguments = arguments; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index b9d9c7620..2f95d5060 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -128,6 +128,8 @@ <Compile Include="ExtensionMethods\ObservableCollectionExtensions.cs" /> <Compile Include="ExternalBridge\IPPCExternalBridgeService.cs" /> <Compile Include="ExternalBridge\PPCExternalBridgeService.cs" /> + <Compile Include="HotSpot\DefaultHotSpotProvider.cs" /> + <Compile Include="HotSpot\IHotSpotProvider.cs" /> <Compile Include="IPPCView.cs" /> <Compile Include="MachineSetup\IMachineSetupManager.cs" /> <Compile Include="MachineSetup\MachineSetupManager.cs" /> @@ -158,6 +160,8 @@ <Compile Include="PPCModuleAttribute.cs" /> <Compile Include="PPCModuleBase.cs" /> <Compile Include="Printing\IPrintingManager.cs" /> + <Compile Include="RemoteAssistance\DefaultRemoteAssistanceProvider.cs" /> + <Compile Include="RemoteAssistance\IRemoteAssistanceProvider.cs" /> <Compile Include="Scripting\CmdCommand.cs" /> <Compile Include="Storage\DefaultStorageProvider.cs" /> <Compile Include="Storage\IStorageProvider.cs" /> @@ -326,7 +330,7 @@ </Target> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs index fbc619e12..a05e66f10 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs @@ -138,18 +138,6 @@ namespace Tango.PPC.UI.Connectivity { await Connect(auto_connect_network); } - - if (settings.EnableHotSpot) - { - try - { - await EnableHotSpot(settings.HotSpotPassword); - } - catch (Exception ex) - { - LogManager.Log(ex, "Error starting on application startup."); - } - } }); } @@ -289,50 +277,5 @@ namespace Tango.PPC.UI.Connectivity IsConnected = connected; ConnectionStateChanged?.Invoke(this, new ConnectionStateEventArgs() { IsConnected = connected }); } - - /// <summary> - /// Enables the hot spot. - /// </summary> - /// <param name="password">The password.</param> - /// <returns></returns> - public async Task EnableHotSpot(string password) - { - if (!IsHotspotActive) - { - try - { - CmdCommand command = new CmdCommand("netsh", $"wlan set hostednetwork mode=allow ssid='{"Tango_" + _machineProvider.Machine.SerialNumber}' key='{password}'"); - await command.Run(); - IsHotspotActive = true; - } - catch (Exception ex) - { - LogManager.Log(ex, "Error activating hot spot."); - throw; - } - } - } - - /// <summary> - /// Disables the hot spot. - /// </summary> - /// <returns></returns> - public async Task DisableHotSpot() - { - if (IsHotspotActive) - { - try - { - CmdCommand command = new CmdCommand("netsh", "wlan stop hosted network"); - await command.Run(); - IsHotspotActive = false; - } - catch (Exception ex) - { - LogManager.Log(ex, "Error deactivating hot spot."); - throw; - } - } - } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs index c21f513ae..740b0d203 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs @@ -8,4 +8,4 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Application")] -[assembly: AssemblyVersion("2.0.13.1608")] +[assembly: AssemblyVersion("2.0.15.1608")] diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index 786eca0c9..406568f71 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -50,6 +50,9 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> + <PropertyGroup> + <ApplicationManifest>app.manifest</ApplicationManifest> + </PropertyGroup> <ItemGroup> <Reference Include="ControlzEx, Version=3.0.2.4, Culture=neutral, processorArchitecture=MSIL"> <HintPath>..\..\packages\ControlzEx.3.0.2.4\lib\net45\ControlzEx.dll</HintPath> @@ -253,6 +256,7 @@ <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> + <None Include="app.manifest" /> <None Include="packages.config" /> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> @@ -468,7 +472,7 @@ del "$(TargetDir)firmware_package.tfp"</PostBuildEvent> </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index 11751d822..645456216 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -10,12 +10,14 @@ using Tango.PPC.Common.Connectivity; using Tango.PPC.Common.Diagnostics; using Tango.PPC.Common.EventLogging; using Tango.PPC.Common.ExternalBridge; +using Tango.PPC.Common.HotSpot; using Tango.PPC.Common.MachineSetup; using Tango.PPC.Common.MachineUpdate; using Tango.PPC.Common.Modules; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; using Tango.PPC.Common.Printing; +using Tango.PPC.Common.RemoteAssistance; using Tango.PPC.Common.Storage; using Tango.PPC.Common.Threading; using Tango.PPC.UI.Authentication; @@ -60,6 +62,8 @@ namespace Tango.PPC.UI TangoIOC.Default.Unregister<IMachineUpdateManager>(); TangoIOC.Default.Unregister<IPrintingManager>(); TangoIOC.Default.Unregister<IConnectivityProvider>(); + TangoIOC.Default.Unregister<IHotSpotProvider>(); + TangoIOC.Default.Unregister<IRemoteAssistanceProvider>(); TangoIOC.Default.Unregister<IStorageProvider>(); TangoIOC.Default.Register<IDispatcherProvider, DefaultDispatcherProvider>(new DefaultDispatcherProvider(Application.Current.Dispatcher)); @@ -77,6 +81,8 @@ namespace Tango.PPC.UI TangoIOC.Default.Register<IMachineUpdateManager, MachineUpdateManager>(); TangoIOC.Default.Register<IPrintingManager, DefaultPrintingManager>(); TangoIOC.Default.Register<IConnectivityProvider, DefaultConnectivityProvider>(); + TangoIOC.Default.Register<IHotSpotProvider, DefaultHotSpotProvider>(); + TangoIOC.Default.Register<IRemoteAssistanceProvider, DefaultRemoteAssistanceProvider>(); TangoIOC.Default.Register<IStorageProvider, DefaultStorageProvider>(); //TangoIOC.Default.Register<TeamFoundationServiceExtendedClient>(new TeamFoundationServiceExtendedClient("https://twinetfs.visualstudio.com", String.Empty, "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa")); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest new file mode 100644 index 000000000..d72e75011 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="utf-8"?> +<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> + <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> + <security> + <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> + <!-- UAC Manifest Options + If you want to change the Windows User Account Control level replace the + requestedExecutionLevel node with one of the following. + + <requestedExecutionLevel level="asInvoker" uiAccess="false" /> + <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> + <requestedExecutionLevel level="highestAvailable" uiAccess="false" /> + + Specifying requestedExecutionLevel element will disable file and registry virtualization. + Remove this element if your application requires this virtualization for backwards + compatibility. + --> + <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> + </requestedPrivileges> + </security> + </trustInfo> + + <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> + <application> + <!-- A list of the Windows versions that this application has been tested on + and is designed to work with. Uncomment the appropriate elements + and Windows will automatically select the most compatible environment. --> + + <!-- Windows Vista --> + <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />--> + + <!-- Windows 7 --> + <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />--> + + <!-- Windows 8 --> + <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />--> + + <!-- Windows 8.1 --> + <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />--> + + <!-- Windows 10 --> + <!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />--> + + </application> + </compatibility> + + <!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher + DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need + to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should + also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. --> + <!-- + <application xmlns="urn:schemas-microsoft-com:asm.v3"> + <windowsSettings> + <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> + </windowsSettings> + </application> + --> + + <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) --> + <!-- + <dependency> + <dependentAssembly> + <assemblyIdentity + type="win32" + name="Microsoft.Windows.Common-Controls" + version="6.0.0.0" + processorArchitecture="*" + publicKeyToken="6595b64144ccf1df" + language="*" + /> + </dependentAssembly> + </dependency> + --> + +</assembly> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Updater/Tango.PPC.Updater.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Updater/Tango.PPC.Updater.csproj index 11cc17854..3f232c4d2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Updater/Tango.PPC.Updater.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Updater/Tango.PPC.Updater.csproj @@ -33,6 +33,9 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> + <PropertyGroup> + <ApplicationManifest>app.manifest</ApplicationManifest> + </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Data" /> @@ -87,6 +90,7 @@ <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> + <None Include="app.manifest" /> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings.Designer.cs</LastGenOutput> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Updater/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.Updater/app.manifest new file mode 100644 index 000000000..d72e75011 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Updater/app.manifest @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="utf-8"?> +<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> + <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> + <security> + <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> + <!-- UAC Manifest Options + If you want to change the Windows User Account Control level replace the + requestedExecutionLevel node with one of the following. + + <requestedExecutionLevel level="asInvoker" uiAccess="false" /> + <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> + <requestedExecutionLevel level="highestAvailable" uiAccess="false" /> + + Specifying requestedExecutionLevel element will disable file and registry virtualization. + Remove this element if your application requires this virtualization for backwards + compatibility. + --> + <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> + </requestedPrivileges> + </security> + </trustInfo> + + <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> + <application> + <!-- A list of the Windows versions that this application has been tested on + and is designed to work with. Uncomment the appropriate elements + and Windows will automatically select the most compatible environment. --> + + <!-- Windows Vista --> + <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />--> + + <!-- Windows 7 --> + <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />--> + + <!-- Windows 8 --> + <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />--> + + <!-- Windows 8.1 --> + <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />--> + + <!-- Windows 10 --> + <!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />--> + + </application> + </compatibility> + + <!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher + DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need + to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should + also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. --> + <!-- + <application xmlns="urn:schemas-microsoft-com:asm.v3"> + <windowsSettings> + <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> + </windowsSettings> + </application> + --> + + <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) --> + <!-- + <dependency> + <dependentAssembly> + <assemblyIdentity + type="win32" + name="Microsoft.Windows.Common-Controls" + version="6.0.0.0" + processorArchitecture="*" + publicKeyToken="6595b64144ccf1df" + language="*" + /> + </dependentAssembly> + </dependency> + --> + +</assembly> |
