diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-10-06 04:13:10 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-10-06 04:13:10 +0300 |
| commit | c719c53ebb4d27e7f45c71f65588b2c5b7e75f86 (patch) | |
| tree | 8ce2c9cbb50783035fbc1503a6de1729ef1f282f /Software/Visual_Studio | |
| parent | 9de6ed771ef74d5fb4ba9d9353ca7a676921f0db (diff) | |
| download | Tango-c719c53ebb4d27e7f45c71f65588b2c5b7e75f86.tar.gz Tango-c719c53ebb4d27e7f45c71f65588b2c5b7e75f86.zip | |
Enable/Disable proxy PPC settings.
Diffstat (limited to 'Software/Visual_Studio')
4 files changed, 81 insertions, 6 deletions
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 374269522..bba5c2e7d 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 @@ -4,6 +4,7 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.ComponentModel.DataAnnotations; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -14,6 +15,7 @@ using Tango.BL.Entities; using Tango.BL.Enumerations; using Tango.ColorConversion; using Tango.Core.Commands; +using Tango.Core.Components; using Tango.Core.DI; using Tango.Core.ExtensionMethods; using Tango.PPC.Common; @@ -26,6 +28,7 @@ using Tango.PPC.Common.UWF; using Tango.Settings; using Tango.SharedUI.Components; using Tango.WiFi; +using static Tango.Core.Components.CmdCommand; namespace Tango.PPC.MachineSettings.ViewModels { @@ -243,6 +246,12 @@ namespace Tango.PPC.MachineSettings.ViewModels set { _useLightInks = value; RaisePropertyChangedAuto(); } } + private bool _enableProxy; + public bool EnableProxy + { + get { return _enableProxy; } + set { _enableProxy = value; RaisePropertyChangedAuto(); } + } #endregion @@ -333,6 +342,42 @@ namespace Tango.PPC.MachineSettings.ViewModels } } + if (EnableProxy != Settings.EnableProxifier) + { + CmdCommand cmd = null; + CmdCommandResult result = null; + + if (!EnableProxy) + { + try + { + cmd = new CmdCommand("taskkill", "/F /IM proxifier.exe"); + result = await cmd.Run(); + Settings.EnableProxifier = false; + Settings.Save(); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Unable to disable the proxy.\n{ex.Message}"); + await NotificationProvider.ShowError($"Unable to disable the proxy.\n{ex.Message}"); + } + } + else + { + try + { + Process.Start(@"C:\Program Files (x86)\Proxifier\Proxifier.exe"); + Settings.EnableProxifier = true; + Settings.Save(); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Unable to start the proxy service.\n{ex.Message}"); + await NotificationProvider.ShowError($"Unable to start the proxy service.\n{ex.Message}"); + } + } + } + if (_previousEnableUWF != EnableUWF) { await NotificationProvider.ShowWarning("Changes to disk protection (UWF) will take effect only after a full system restart."); @@ -393,6 +438,22 @@ namespace Tango.PPC.MachineSettings.ViewModels MachineDataSynchronizer.SynchronizationStarted += (_, __) => InvalidateRelayCommands(); MachineDataSynchronizer.SynchronizationEnded += (_, __) => InvalidateRelayCommands(); + if (!Settings.EnableProxifier) + { + CmdCommand cmd = null; + CmdCommandResult result = null; + + try + { + cmd = new CmdCommand("taskkill", "/F /IM proxifier.exe"); + result = await cmd.Run(); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Unable to disable the proxy.\n{ex.Message}"); + } + } + using (ObservablesContext db = ObservablesContext.CreateDefault()) { Rmls = (await new RmlsCollectionBuilder(db).SetAll().ForHeadType(MachineProvider.Machine.MachineHeadType).ForSite(MachineProvider.Machine.SiteGuid).BuildAsync()).OrderBy(x => x.FinalName).ToObservableCollection(); @@ -482,6 +543,8 @@ namespace Tango.PPC.MachineSettings.ViewModels { LogManager.Log(ex, "Error loading lubrication levels."); } + + EnableProxy = Settings.EnableProxifier; } private async void OnEnableRemoteAssistanceChanged() 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 7aba9a1ef..7e67bbf99 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 @@ -341,6 +341,11 @@ </DockPanel> <DockPanel Margin="0 20 0 0" TextElement.FontSize="{StaticResource TangoDefaultFontSize}"> + <TextBlock VerticalAlignment="Center">Enable Proxy</TextBlock> + <touch:TouchToggleSlider IsChecked="{Binding EnableProxy}" Margin="0 0 100 0" DockPanel.Dock="Right" Style="{StaticResource TangoToggleButtonGrayAccent}" HorizontalAlignment="Right" Width="90"></touch:TouchToggleSlider> + </DockPanel> + + <DockPanel Margin="0 20 0 0" TextElement.FontSize="{StaticResource TangoDefaultFontSize}"> <TextBlock VerticalAlignment="Center">Enable Automatic Thread Loading Support</TextBlock> <touch:TouchToggleSlider IsChecked="{Binding Settings.EnableAutomaticThreadLoading}" Margin="0 0 100 0" DockPanel.Dock="Right" Style="{StaticResource TangoToggleButtonGrayAccent}" HorizontalAlignment="Right" Width="90"></touch:TouchToggleSlider> </DockPanel> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index ef24fedcc..8bc753be9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -299,6 +299,11 @@ namespace Tango.PPC.Common public bool EnableSpoolReplacementDialog { get; set; } /// <summary> + /// Gets or sets a value indicating whether enable the proxifier process. + /// </summary> + public bool EnableProxifier { get; set; } + + /// <summary> /// Gets the machine service address. /// </summary> /// <returns></returns> @@ -357,6 +362,7 @@ namespace Tango.PPC.Common InsightsStorageCleanupInterval = TimeSpan.FromMinutes(60); EnableSpoolReplacementDialog = true; + EnableProxifier = true; } } } diff --git a/Software/Visual_Studio/Tango.Core/Components/CmdCommand.cs b/Software/Visual_Studio/Tango.Core/Components/CmdCommand.cs index afd763966..47bb66361 100644 --- a/Software/Visual_Studio/Tango.Core/Components/CmdCommand.cs +++ b/Software/Visual_Studio/Tango.Core/Components/CmdCommand.cs @@ -68,6 +68,8 @@ namespace Tango.Core.Components { return Task.Factory.StartNew<CmdCommandResult>(() => { + CmdCommandResult result = new CmdCommandResult(); + LogManager.Log($"Starting process {_process.StartInfo.FileName} with arguments {Arguments}..."); _process.Start(); @@ -99,12 +101,11 @@ namespace Tango.Core.Components throw new IOException($"The process {_process.StartInfo.FileName} has exited with the code {_process.ExitCode}.\n{error}"); } - return new CmdCommandResult() - { - StandardOutput = output, - StandardError = error, - ExitCode = _process.ExitCode, - }; + result.StandardOutput = output; + result.StandardError = error; + result.ExitCode = _process.ExitCode; + + return result; } else { |
