public RunningWebProxy(ServicesKeyword servicesKeyword) { _runningApplication = RunningApplication.Instance(); _webProxy = new LocalWebProxy(); ProxyIsEnabled = servicesKeyword.ProgramConfiguration.Configuration.ProxyEnabled; ProxyIsRunning = false; SetupWebProxyForProgramStart(servicesKeyword); }
private void SetupWebProxyForProgramStart(ServicesKeyword servicesKeyword) { if (ProxyIsEnabled) { try { _webProxy.LoadProxyProfileFromFileSystem(); UpdatePortNumber(Int32.Parse(servicesKeyword.ProgramConfiguration.Configuration.ProxyPortNumber)); Start(); } catch (WebProxyNoProfilesFileException e) { string errorTitle = "Back on Track - proxy file does not exit"; string errorMessage = e.Message; ProgramStartShuttingDownProxy(errorTitle, errorMessage, servicesKeyword); } catch (WebProxyBrokenProfileConfigurationException e) { string errorTitle = "Back on Track - Proxy profile configuration file is broken"; string errorMessage = e.Message; ProgramStartShuttingDownProxy(errorTitle, errorMessage, servicesKeyword); } catch (WebProxyPortAlreadyInUseException e) { string errorTitle = "Back on Track - Proxy port number already in use"; string errorMessage = e.Message; ProgramStartShuttingDownProxy(errorTitle, errorMessage, servicesKeyword); } } else { try { //still load settings _webProxy.LoadProxyProfileFromFileSystem(); } catch (Exception) { } } }
private void Setup() { string[] settings = new string[] {}; if (!UnitTestSetup) { Show();//used for onSourceInitialized Hide(); System.Windows.Application.Current.Resources["AccentColor"] = Colors.Teal; settings = Environment.GetCommandLineArgs(); _programSettingsPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); } try { DoUiTestsSetup(settings); Services = new ServicesKeyword(); UI = new UiKeyword(!settings.Contains("-startWithoutUi")); if (!UnitTestSetup) { if (settings.Contains("-startWithoutUi")) { MinimizeToTray(); } } } catch (UnauthorizedAccessException e) { Messages.CreateMessageBox( "Please make sure you have admin rights and start the application again.", "No admin rights", true); Shutdown(); } catch (System.IO.IOException e) { Messages.CreateMessageBox($"The following error occured with a file:{Environment.NewLine}{Environment.NewLine}{e.Message}", "Error with file", true); Shutdown(); } }
private void ProgramStartShuttingDownProxy(string errorTitle, string errorMessage, ServicesKeyword servicesKeyword) { Messages.CreateMessageBox( errorMessage, errorTitle, true); Messages.CreateMessageBox( "Proxy is shutting down.", "Back on Track - Proxy shutting down", true); ProxyIsEnabled = false; servicesKeyword.ProgramConfiguration.TempConfiguration.ProxyEnabled = false; servicesKeyword.ProgramConfiguration.SaveCurrentConfiguration(); }