Beispiel #1
0
 private static bool ActivateRunningInstance(bool useHttps)
 {
     using (var client = new XWebClient(500))
       {
     try
     {
       var result = client.DownloadString((useHttps ? "https" : "http") + "://127.0.0.1:27963/bringToFront");
       if (result == "ok")
     return true;
     }
     catch
     {
     }
       }
       return false;
 }
Beispiel #2
0
        public void Run()
        {
            try
              {
            using (var client = new XWebClient(1000))
            {
              client.Encoding = Encoding.UTF8;

              string url = config.GetString("masterServer") + "/version";
              string remoteVersionInfo = client.DownloadString(new Uri(url));
              MasterServerVersionInfoReceived(remoteVersionInfo);
            }
              }
              catch (Exception ex)
              {
            Log("Failed to check for latest extraQL.exe version: " + ex.Message);
              }
        }
Beispiel #3
0
 private string DownloadText(string url)
 {
     try
       {
     using (var webRequest = new XWebClient())
     {
       webRequest.Encoding = Encoding.UTF8;
       return webRequest.DownloadString(url);
     }
       }
       catch (Exception ex)
       {
     Log(ex.Message);
     return null;
       }
 }
Beispiel #4
0
        private void LoginToQlFocus()
        {
            using (var webRequest = new XWebClient())
              {
            webRequest.Encoding = Encoding.UTF8;
            var html = webRequest.DownloadString("http://focus.quakelive.com/focusgate/");
            string js = @"
            document.loginform.login.value = '" + this.comboEmail.Text + @"';
            document.loginform.passwd.value = '" + this.txtPassword.Text + @"';
            document.loginform.submit();";
            html = html.Replace("document.loginform.login.focus();", js);
            var file = Path.GetTempFileName();
            File.Move(file, file + ".html");
            file += ".html";
            File.WriteAllText(file, html);
            Process.Start(file);

            Timer timer = new Timer();
            timer.Interval = 5000;
            timer.Tick += (sender2, args) =>
            {
              timer.Stop();
              File.Delete(file);
              ((IDisposable)sender2).Dispose();
            };
            timer.Start();
              }
        }
Beispiel #5
0
        public ScriptInfo GetScriptByIdOrUrl(string scriptIdOrUrl)
        {
            lock (this)
              {
            ScriptInfo script;
            if (scriptById.TryGetValue(scriptIdOrUrl, out script))
            {
              // refresh script info it file was modified locally (e.g. while developing)
              if (script.Timestamp < new FileInfo(script.Filepath).LastWriteTimeUtc.Ticks)
              {
            string content = File.ReadAllText(script.Filepath);
            ScriptHeaderFields meta = ParseHeaderFields(content);
            script = new ScriptInfo(script.Filepath, content, meta);
            scriptById[scriptIdOrUrl] = script;
              }
              return script;
            }
              }

              return null;
            #if false
              // download script from external URL
              using (var webRequest = new XWebClient())
              {
            webRequest.Encoding = Encoding.UTF8;
            string url = scriptIdOrUrl;
            try
            {
              string filename = Path.GetFileName(new Uri(url).AbsolutePath);
              var code = webRequest.DownloadString(url);
              var meta = this.ParseHeaderFields(code);
              var id = meta.ContainsKey("id") ? meta["id"][0] : "";
              if (string.IsNullOrEmpty(id))
            id = this.StripAllExtenstions(filename);
              var filePath = ScriptDir + "\\" + StripAllExtenstions(filename) + ".usr.js";
              File.WriteAllText(filePath, code);
              script = new ScriptInfo(id, filePath, meta, code);
              this.Log("Downloaded script from " + url);
              this.scriptById[scriptIdOrUrl] = script;
            }
            catch (Exception)
            {
              this.Log("Failed to download script from " + url);
            }
            return script;
              }
            #endif
        }