Exemplo n.º 1
0
        public void Dispose()
        {
            if (_endpoint != null)
            {
                _endpoint.Dispose();
                _endpoint = null;
            }

            if (_firefox_process != null)
            {
                if (!_firefox_process.HasExited)
                {
                    _firefox_process.Kill();
                    _firefox_process.WaitForExit();
                }
                _firefox_process.Dispose();
                _firefox_process = null;
            }

            if (_profile_dir != null && !this.Persistant && Directory.Exists(_profile_dir))
            {
                IOExt.DeleteDirectoryByShell(_profile_dir);
                _profile_dir = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Releases all resources.
        /// </summary>
        public void Dispose()
        {
            _endpoint.Dispose();

            if (_process != null)
            {
                if (!_process.HasExited)
                {
                    _process.Kill();
                }
                _process.Dispose();
                _process = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Stops the service.
        /// </summary>
        public void Quit(RemoteServer server)
        {
            if (_process == null || _process.HasExited)
            {
                return;
            }

            server.ShutDown();

            if (_process.WaitForExit(5000))
            {
                _process.Dispose();
                _process = null;
            }
        }
Exemplo n.º 4
0
        private async Task <Unit> OnRestartPos()
        {
            await Task.Run(() =>
            {
                ProcessExt.ForceKillProcess(SettingsData.AlohaIber.Replace(SettingsData.Constants.EXTENSION_EXE, String.Empty));

                if (!PosService.DeletePosFoldersDataAndNewDataIfPosIsDown())
                {
                    ShowPosApp();
                    return;
                }
                ReloadPosAction.SafeExecuteAction();
            });

            return(new Unit());
        }
Exemplo n.º 5
0
        public object GetUiSettings()
        {
            if (_webOverlaySettings == null || _webOverlaySettings.IsDisposed)
            {
                var filesLocation = WebSocketDataGetter.HttpContentRoot(_saver);
                var webUrl        = WebSocketDataGetter.BaseAddress(_settings);
                _webOverlaySettings = new WebOverlaySettings(_settings, OverlayConfiguration);
                _webOverlaySettings.ResetSettings      += (_, __) => ResetSettings();
                _webOverlaySettings.OpenWebUrl         += (_, __) => ProcessExt.OpenUrl(webUrl);
                _webOverlaySettings.OpenFilesFolder    += (_, __) => Process.Start("explorer.exe", filesLocation);
                _webOverlaySettings.FilesLocation       = filesLocation;
                _webOverlaySettings.WebUrl              = webUrl;
                _webOverlaySettings.RemoteAccessEnabled = WebSocketDataGetter.RemoteAccessEnabled(_settings);
                _webOverlaySettings.ToggleRemoteAccess += (_, __) => ToggleRemoteAccess();
            }

            return(_webOverlaySettings);
        }
Exemplo n.º 6
0
        public void StartApplication(string firefoxPath, IEnumerable arguments, string profilePath)
        {
            Hashtable env = ProcessExt.GetStdEnvironmentVariables();

            env["TEMP"]                      = _working_dir;
            env["TMP"]                       = _working_dir;
            env["XRE_PROFILE_PATH"]          = profilePath;
            env["MOZ_NO_REMOTE"]             = "1";
            env["MOZ_CRASHREPORTER_DISABLE"] = "1";
            env["NO_EM_RESTART"]             = "1";

            //start the process
            _firefox_process = ProcessExt.Start(firefoxPath, arguments, null, env, false, true);

            //Waits for the port to be listening
            SysWaiter.Wait(200);
            if (!_endpoint.WaitForListening(15000, 100))
            {
                throw new Errors.TimeoutError("Firefox failed to open the listening port {0} within 15s", _endpoint);
            }
        }
Exemplo n.º 7
0
        static void CreateProfile(string binary_path, string appdata_dir, string profile_name, out string profile_dir)
        {
            Hashtable env = ProcessExt.GetStdEnvironmentVariables();

            env["MOZ_NO_REMOTE"] = "1";

            string[] args = { "-CreateProfile", profile_name };

            using (var p = ProcessExt.Start(binary_path, args, null, env, false, false)) {
                if (!p.WaitForExit(10000))
                {
                    throw new Errors.TimeoutError("Failed to create the profile. The process didn't exit within 10s.");
                }
            }

            var profiles = ParseExistingProfiles(appdata_dir);

            if (!profiles.TryGetValue(profile_name, out profile_dir))
            {
                throw new SeleniumError("Failed to create the profile: {0}", profile_name);
            }
        }
Exemplo n.º 8
0
        public void Start(string filename, bool hide = true)
        {
            Hashtable env = ProcessExt.GetStdEnvironmentVariables();

            env["TEMP"] = _temp_folder;
            env["TMP"]  = _temp_folder;

            string servicePath = Path.Combine(_library_dir, filename);

            if (!File.Exists(servicePath))
            {
                throw new Errors.FileNotFoundError(servicePath);
            }

            //Start the process
            _process = ProcessExt.Start(servicePath, _arguments, null, env, true, true);

            //Waits for the port to be listening
            if (!_endpoint.WaitForListening(10000, 150))
            {
                throw new Errors.TimeoutError("The driver failed to open the listening port {0} within 10s", _endpoint);
            }
        }
Exemplo n.º 9
0
 private void pictureBox2_Click(object sender, System.EventArgs e)
 {
     ProcessExt.OpenUrl(@"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CX2ZC3JKVAK74");
 }
Exemplo n.º 10
0
 private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
 {
     ProcessExt.OpenUrl(e.LinkText);
 }
Exemplo n.º 11
0
 private void button_message_Click(object sender, EventArgs e)
 {
     Clipboard.SetText(string.Format(errorTemplate, textBox1.Text));
     ProcessExt.OpenUrl(@"https://osu.ppy.sh/forum/ucp.php?i=pm&mode=compose&u=304520");
 }
Exemplo n.º 12
0
 private void linkLabel_UICredit2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     ProcessExt.OpenUrl("https://osu.ppy.sh/users/4944211");
 }
Exemplo n.º 13
0
 private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     ProcessExt.OpenUrl(@"https://osu.ppy.sh/forum/t/164486");
 }
Exemplo n.º 14
0
 private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     ProcessExt.OpenUrl(@"http://osupost.givenameplz.de/");
 }
Exemplo n.º 15
0
 private void ShowPosApp()
 {
     ProcessExt.ForceSetFocusApp(SettingsData.AlohaIber.Replace(SettingsData.Constants.EXTENSION_EXE, String.Empty));
 }
Exemplo n.º 16
0
        public ActionResult Index()
        {
            dynamic result = null;

            ViewBag.TempDirectory = null;

            var script = routeParser.GetScript(RouteData);

            if (script == null)
            {
                return(BadRequest());
            }

            var interpreter = interpretersManager.GetInterpreter(script.Interpreter);

            if (interpreter == null)
            {
                return(BadRequest());
            }

            if (Request.Method == "POST")
            {
                // We will save posted data into a temp directory
                script.CopyToTemp = true;
            }

            if (script.CopyToTemp)
            {
                ViewBag.TempDirectory = Utilities.CreateTempDirectory(interpretersManager.WorkingDirectory);
                Utilities.CopyFiles(script.Location, ViewBag.TempDirectory);
            }

            if (Request.Method == "POST")
            {
                string path = Path.Combine(ViewBag.TempDirectory, "input.json");
                Utilities.SavePostRequestData(this.Request, path);
            }

            string arguments     = ArgumentsBuilder.Build(interpreter, script, this.Request);
            string workDirectory = script.CopyToTemp ? ViewBag.TempDirectory : script.Location;

            var process = ProcessExt.Create();

            process.NoOutput                   = script.NoOutput;
            process.StartInfo.FileName         = interpreter.Path;
            process.StartInfo.Arguments        = arguments;
            process.StartInfo.WorkingDirectory = workDirectory;

            process.StartAndWait();

            var outputFile = new OutputFile(script);

            if (outputFile.IsDefined)
            {
                string path = Path.Combine(workDirectory, outputFile.FileName);
                logger.LogInformation($"Output file: \"{path}\"");

                if (!System.IO.File.Exists(path))
                {
                    logger.LogError($"Output file \"{outputFile.FileName}\" not found");
                    return(BadRequest());
                }

                if (outputFile.IsJson)
                {
                    result = outputFile.ReadJson(path);
                }
                else
                {
                    return(outputFile.ReadFileStream(path));
                }
            }

            return(Json(new { Output = process.Output, Result = result },
                        new JsonSerializerSettings {
                Formatting = Formatting.Indented
            }));
        }