private void SendWithCmd( )
        {
            WebClient.CancelAsync();
            var jsonString          = Writer.Write(AsServerInfoRaw);
            var nameValueCollection = new NameValueCollection {
                { "data", jsonString }
            };
            Uri uri = new Uri(URI);

            WebClient.UploadValuesAsync(uri, nameValueCollection);
        }
Example #2
0
        private void sendOrderRequest(NameValueCollection parameters)
        {
            var client = new WebClient();

            client.UploadValuesCompleted += OnPayRequestCompleted;
            client.UploadValuesAsync(new Uri(cardpaymentUrl), "POST", parameters);
        }
Example #3
0
        internal static void ReportError(string realm, Exception exception)
        {
            if (DoNotSend)
            {
                return;
            }

            try
            {
                NameValueCollection values = new NameValueCollection();
                values.Add("realm", realm);

                values.Add("message", exception.Message);
                values.Add("trace", exception.StackTrace);

                if (exception.InnerException != null)
                {
                    values.Add("innerMessage", exception.InnerException.Message);
                    values.Add("innerTrace", exception.InnerException.StackTrace);
                }

                WebClient wc = new WebClient();
                wc.UploadValuesAsync(new Uri(baseUrl + "reportError"), values);
            }
            catch (Exception)
            {
                // Don't error handle the error reporting
            }
        }
Example #4
0
 public static async Task ConcurrentOperations_Throw()
 {
     await LoopbackServer.CreateServerAsync((server, url) =>
     {
         var wc       = new WebClient();
         Task ignored = wc.DownloadDataTaskAsync(url); // won't complete
         Assert.Throws <NotSupportedException>(() => { wc.DownloadData(url); });
         Assert.Throws <NotSupportedException>(() => { wc.DownloadDataAsync(url); });
         Assert.Throws <NotSupportedException>(() => { wc.DownloadDataTaskAsync(url); });
         Assert.Throws <NotSupportedException>(() => { wc.DownloadString(url); });
         Assert.Throws <NotSupportedException>(() => { wc.DownloadStringAsync(url); });
         Assert.Throws <NotSupportedException>(() => { wc.DownloadStringTaskAsync(url); });
         Assert.Throws <NotSupportedException>(() => { wc.DownloadFile(url, "path"); });
         Assert.Throws <NotSupportedException>(() => { wc.DownloadFileAsync(url, "path"); });
         Assert.Throws <NotSupportedException>(() => { wc.DownloadFileTaskAsync(url, "path"); });
         Assert.Throws <NotSupportedException>(() => { wc.UploadData(url, new byte[42]); });
         Assert.Throws <NotSupportedException>(() => { wc.UploadDataAsync(url, new byte[42]); });
         Assert.Throws <NotSupportedException>(() => { wc.UploadDataTaskAsync(url, new byte[42]); });
         Assert.Throws <NotSupportedException>(() => { wc.UploadString(url, "42"); });
         Assert.Throws <NotSupportedException>(() => { wc.UploadStringAsync(url, "42"); });
         Assert.Throws <NotSupportedException>(() => { wc.UploadStringTaskAsync(url, "42"); });
         Assert.Throws <NotSupportedException>(() => { wc.UploadFile(url, "path"); });
         Assert.Throws <NotSupportedException>(() => { wc.UploadFileAsync(url, "path"); });
         Assert.Throws <NotSupportedException>(() => { wc.UploadFileTaskAsync(url, "path"); });
         Assert.Throws <NotSupportedException>(() => { wc.UploadValues(url, new NameValueCollection()); });
         Assert.Throws <NotSupportedException>(() => { wc.UploadValuesAsync(url, new NameValueCollection()); });
         Assert.Throws <NotSupportedException>(() => { wc.UploadValuesTaskAsync(url, new NameValueCollection()); });
         return(Task.CompletedTask);
     });
 }
        public static void Insert(string parent, object contents, Action <bool, string> onFinished = null)
        {
            if (Application.Manifest == null || string.IsNullOrEmpty(Application.Manifest.DatabaseUrl))
            {
                return;
            }
            Add add = new Add()
            {
                Auth    = Application.Integration.Auth,
                Content = JsonConvert.SerializeObject(contents),
                Parent  = parent
            };
            NameValueCollection nameValueCollection = new NameValueCollection()
            {
                { "data", JsonConvert.SerializeObject(add) }
            };
            Uri       uri       = new Uri(Application.Manifest.DatabaseUrl.Replace("{action}", "add"));
            WebClient webClient = new WebClient()
            {
                Encoding = Encoding.UTF8
            };

            if (onFinished != null)
            {
                webClient.UploadValuesCompleted += new UploadValuesCompletedEventHandler((object s, UploadValuesCompletedEventArgs e) => {
                    AddResponse addResponse = JsonConvert.DeserializeObject <AddResponse>(Encoding.UTF8.GetString(e.Result));
                    onFinished(addResponse.Status == "ok", addResponse.Id);
                });
            }
            webClient.UploadValuesAsync(uri, "POST", nameValueCollection);
        }
        private void Client_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            client = new WebClient();
            uri    = new Uri("http://" + ip + "/sendEmailReschedule.php");
            NameValueCollection parameter = new NameValueCollection();

            parameter.Add("cname", cname);
            parameter.Add("ename", ename);
            parameter.Add("adate", "2018/" + amonth + "/" + aday);
            parameter.Add("atime", ahour + ":" + amin);
            parameter.Add("service", aservice);
            client.UploadValuesAsync(uri, parameter);


            if (type.Equals("1"))
            {
                var intent = new Intent(this, typeof(ScheduleActivity));
                StartActivity(intent);
            }
            else if (type.Equals("0"))
            {
                var intent = new Intent(this, typeof(BookingActivity));
                StartActivity(intent);
            }
        }
Example #7
0
        public static void PostAsync(string url, string token, NameValueCollection nameValues, Action <string> callback, Action <Exception> errorback)
        {
            using (var client = new WebClient()
            {
                Encoding = Encoding.UTF8
            })
            {
                if (!string.IsNullOrEmpty(token))
                {
                    client.Headers.Add(HttpRequestHeader.Authorization, "bearer " + token);
                }

                client.UploadValuesCompleted += (sender, e) =>
                {
                    if (e.Error == null)
                    {
                        callback?.Invoke(Encoding.UTF8.GetString(e.Result));
                    }
                    else
                    {
                        errorback?.Invoke(e.Error);
                    }
                };
                client.UploadValuesAsync(new Uri(url), nameValues);
            }
        }
Example #8
0
        internal static void SendNotifications(IEnumerable <string> apiKeys, string application, string header, string message)
        {
            var data = new NameValueCollection();

            data["user"]     = "";
            data["priority"] = Priority;
            data["message"]  = message;
            data["title"]    = header;

            if (!Validate(data) || String.IsNullOrEmpty(application))
            {
                return;
            }

            foreach (var apiKey in apiKeys)
            {
                using (var client = new WebClient())
                {
                    data.Set("user", apiKey);

                    client.Headers[HttpRequestHeader.ContentType] = RequestContentType;
                    client.UploadValuesAsync(new Uri(RequestUrl + application), data);
                }
            }
        }
Example #9
0
        private ArrayAdapter <string> adapter; // notice adapter here

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Surveys);
            //add the action bar to the layout
            ActionBar.SetCustomView(Resource.Layout.action_bar);
            ActionBar.SetDisplayShowCustomEnabled(true);

            //action bar nav
            surveysBtn                = FindViewById <LinearLayout>(Resource.Id.SurveyLayout);
            surveysBtn.Click         += surveyBtn_Click;
            inboxBtn                  = FindViewById <LinearLayout>(Resource.Id.InboxLayout);
            inboxBtn.Click           += InboxBtn_Click;
            availabilityBtn           = FindViewById <LinearLayout>(Resource.Id.availabilityLayout);
            availabilityBtn.Click    += availabilityBtn_Click;
            dashboardBtn              = FindViewById <LinearLayout>(Resource.Id.dashboardLayout);
            dashboardBtn.Click       += dashboardBtn_Click;
            surveyListview            = FindViewById <ListView>(Resource.Id.surveyListView);
            surveyListview.ItemClick += SurveyListview_ItemClick;


            WebClient client = new WebClient();

            System.Uri          uri        = new System.Uri("http://dribl.com/api/getAllMySurveys");
            NameValueCollection parameters = new NameValueCollection();


            parameters.Add("token", GlobalVariables.token);

            client.UploadValuesAsync(uri, parameters);
            client.UploadValuesCompleted += client_UploadValuesCompleted;
        }
Example #10
0
        public override void OnActivate()
        {
            if (string.IsNullOrEmpty(_info))
            {
                _uIElement.Append(_loaderElement);
                _loading = true;
                _ready   = false;

                _cts = new CancellationTokenSource();

                Task.Factory.StartNew(() => {
                    try {
                        ServicePointManager.Expect100Continue = false;
                        const string url = "http://javid.ddns.net/tModLoader/moddescription.php";
                        var values       = new NameValueCollection {
                            { "modname", _modDisplayName }
                        };
                        using (WebClient client = new WebClient()) {
                            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, policyErrors) => policyErrors == SslPolicyErrors.None;
                            client.UploadValuesCompleted += ReceiveModInfo;
                            client.UploadValuesAsync(new Uri(url), "POST", values);
                        }
                    }
                    catch (Exception e) {
                        UIModBrowser.LogModBrowserException(e);
                    }
                }, _cts.Token);
            }
            else
            {
                _loading = false;
                _ready   = true;
            }
        }
Example #11
0
        public void POSTRequest()//NameValueCollection je kolekcija kljuceva i vrednosti formata "key" "value"
        {
            //Proverava dali je zauzeta sesija
            if (busy)
            {
                return;
            }
            else
            {
                busy = true;
            }
            //Inicijalizacija za slucaj ponovnog slanja istog requesta
            POSTcomplete = false;

            try
            {
                Uri uri = new Uri(url);
                client.UploadValuesCompleted += new UploadValuesCompletedEventHandler(POSTRequestCompleted);
                client.UploadValuesAsync(uri, POSTdata);
            }
            catch (ArgumentNullException ex)
            {
                Debug.Log(ex.Message);
            }
            catch (WebException ex)
            {
                Debug.Log(ex.Message);
            }
        }
Example #12
0
        /// <summary>
        /// Called whenever the Register button is clicked. Checks if there are errors in user
        /// input and if there are none attempts to add new student information to the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (btnGender.Checked)
            {
                gender = "Male";
            }
            else
            {
                gender = "Female";
            }

            birthday = year + "-" + month + "-" + day;

            errors = false;
            resetErrorText();
            validateForm();

            if (!errors)
            {
                WebClient client = new WebClient();

                setParameters();


                progressBar.Visibility        = ViewStates.Visible;
                client.UploadValuesCompleted += client_UploadValuesCompleted;
                client.UploadValuesAsync(uri, parameters);
                client.Dispose();
            }
        }
Example #13
0
        internal static void SendNotifications(IEnumerable <string> apiKeys, string application, string header, string message)
        {
            var data = new NameValueCollection();

            data["AuthorizationToken"] = "";
            data["Body"]        = message;
            data["IsImportant"] = IsImportant;
            data["IsSilent"]    = IsSilent;
            data["Source"]      = application;
            data["TimeToLive"]  = TimeToLive;
            data["Title"]       = header;
            if (!Validate(data))
            {
                return;
            }

            foreach (var apiKey in apiKeys)
            {
                using (var client = new WebClient())
                {
                    data.Set("AuthorizationToken", apiKey);

                    client.Headers[HttpRequestHeader.ContentType] = RequestContentType;
                    client.UploadValuesAsync(new Uri(RequestUrl), data);
                }
            }
        }
Example #14
0
        private static void SubmitBugReport(string email, Exception exc)
        {
            try {
                const string url = UpdateChecker.UpdateCheckHost + "tool/report_bug";
                WebClient    wc  = new WebClient();
                wc.Proxy = null;
                var data = new NameValueCollection();
                data.Set("program_version", typeof(Program).Assembly.GetName().Version.ToString());
                data.Set("exception", exc?.ToString() ?? "");
                if (ConfigManager.ActiveSkin != null)
                {
                    data.Set("skin_name", ConfigManager.ActiveSkin.Name);
                }
                data.Set("command_line", _cmdLine);
                data.Set("email", email);

                wc.UploadValuesCompleted += (o, args) => {
                    if (args.Cancelled || args.Error != null)
                    {
                        BugReportFailed();
                    }
                    else
                    {
                        MessageBox.Show("Bug report sent successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                };

                wc.UploadValuesAsync(new Uri(url), "POST", data);
            }
            catch {
                BugReportFailed();
            }
        }
Example #15
0
        //===========================================================================================================================================================
        //Add new address dialog fragment event
        private async void AddNewAddress_dialog_OnAddNewAddressComplete(object sender, OnAddNewAddress e)
        {
            //Event that is fired when they click the add new address button on the dialog fragment, add the new address to the list
            address.Add(new addressHolder()
            {
                addressLine = e.AddressLine, city = e.City, state = e.State, zipCode = e.ZipCode, desc = e.Desc, image = e.Image
            });
            adapter            = new myListViewAdapter(this, address);
            myListView.Adapter = adapter;
            WebClient           client     = new WebClient();
            Uri                 uri        = new Uri("http://192.168.1.22:80/christmaslightsPHP/createAddress.php");
            NameValueCollection parameters = new NameValueCollection();

            parameters.Add("date", DateTime.Now.ToString("MM-dd-yyyy"));
            parameters.Add("addressLine", e.AddressLine);
            parameters.Add("city", e.City);
            parameters.Add("state", e.State);
            parameters.Add("zipCode", e.ZipCode);
            parameters.Add("description", e.Desc);
            //Photo stuff
            MemoryStream memStream = new MemoryStream();

            e.Image.Compress(Bitmap.CompressFormat.Webp, 100, memStream);
            byte[] imageData = memStream.ToArray();
            parameters.Add("image", Convert.ToBase64String(imageData));
            client.UploadValuesAsync(uri, parameters);
        }
        public void ProductMessage(Product product, string emailFor = "Verification")
        {
            try
            {
                string body    = "";
                string subject = "";
                if (emailFor == "ApprovedProperty")
                {
                    body = string.Format(_configuration.GetValue <string>("ApprovedProductMessage"),
                                         _configuration.GetValue <string>("ServerUr1"), product.ProductCode);
                    subject = "Invalid Listing";
                }

                WebClient           client = new WebClient();
                NameValueCollection values = new NameValueCollection();
                values.Add("username", _configuration["Email:Email"]);
                values.Add("api_key", _configuration["Email:api_key"]);
                values.Add("from", _configuration["Email:Email"]);
                values.Add("subject", subject);
                values.Add("body_html", body);
                values.Add("to", product.UserProfile.FirstName);
                client.UploadValuesAsync(new Uri("https://api.elasticemail.com/mailer/send"), values);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
Example #17
0
        public static Boolean upload(Bitmap bmp)
        {
            try
            {
                var data = new NameValueCollection();

                var image = Global_Func.bmp_to_base64(bmp, Global_Func.ext_to_imageformat(Settings.upload_format));
                data.Add("image", image);

                web_client.Headers.Add("Authorization", "Client-ID " + Settings.imgur_client_id);
                web_client.UploadValuesAsync(
                    new Uri("https://api.imgur.com/3/image/"),
                    "POST",
                    data
                    );

                web_client.Headers.Remove("Authorization");
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Example #18
0
 public static void Post(string url, NameValueCollection data, Action <string, Exception> action)
 {
     try
     {
         using (var webClient = new WebClient())
         {
             Debug.Print($"Post {url}");
             webClient.Headers.Add("user-agent", Program.Name);
             webClient.UploadValuesCompleted += (sender, e) =>
             {
                 if (e.Error == null)
                 {
                     var response = Encoding.UTF8.GetString(e.Result);
                     Program.Schedule(() => action(response, null));
                 }
                 else
                 {
                     Program.Schedule(() => action(null, e.Error));
                 }
             };
             webClient.UploadValuesAsync(new Uri(url), "POST", data);
         }
     }
     catch (Exception e)
     {
         Program.Schedule(() => action(null, e));
     }
 }
Example #19
0
        static public void SendPersonToDatabase(Person cp, UploadValuesCompletedEventHandler callback)
        {
            var nvc = new System.Collections.Specialized.NameValueCollection();

            nvc.Add("name", cp.Name);
            nvc.Add("accuracy", cp.Accuracy.ToString());
            nvc.Add("time", cp.Time.ToString());
            nvc.Add("action", API_INSERT);
            nvc.Add("password", API_PASSWORD);
            nvc.Add("gender", cp.IsMale.ToString());
            nvc.Add("age", cp.Age.ToString());

            var wb = new WebClient();

            wb.Headers.Add("user-agent", "Nergiz Quiz Desktop Client");
            wb.Headers.Add("content-type", "application/x-www-form-urlencoded");
            string apiPath;

            if (IS_DEBUGGING)
            {
                apiPath = LOCALHOST_URL + API_URL;
            }
            else
            {
                apiPath = SITE_URL + API_URL;
            }

            wb.UploadValuesAsync(new Uri(apiPath), "POST", nvc);
            wb.UploadValuesCompleted += callback;
        }
Example #20
0
        /// <summary>
        /// 班组同步签名信息
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="fileName"></param>
        public void UpdateSign(string userid, string fileName, string path, string imgurl, string bzAppUrl)
        {
            WebClient wc = new WebClient();

            wc.Credentials = CredentialCache.DefaultCredentials;
            //发送请求到web api并获取返回值,默认为post方式
            try
            {
                System.Collections.Specialized.NameValueCollection nc = new System.Collections.Specialized.NameValueCollection();
                System.IO.File.AppendAllText(path + "\\" + fileName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":同步成功" + "\r\n");
                string json = Newtonsoft.Json.JsonConvert.SerializeObject(new
                {
                    userid   = userid,
                    filepath = imgurl + "/Resource/sign/" + fileName
                });
                nc.Add("json", json);
                wc.UploadValuesAsync(new Uri(bzAppUrl + "UpdateUrl"), nc);
            }
            catch (Exception ex)
            {
                //将同步结果写入日志文件
                fileName = DateTime.Now.ToString("yyyyMMdd") + ".log";
                System.IO.File.AppendAllText(new DataItemDetailBLL().GetItemValue("imgPath") + "~/logs/" + fileName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":数据失败" + ",异常信息:" + ex.Message + "\r\n");
            }
        }
        private void button_click(object sender, EventArgs e)
        {
            if (ValidateDate().Equals(true))
            {
                client = new WebClient();
                uri    = new Uri("http://" + ip + "/rescheduleBooking.php");
                NameValueCollection parameter = new NameValueCollection();
                string id = Intent.GetStringExtra("idBooking");
                Console.WriteLine("HERE");
                Console.WriteLine("Intent: " + Intent.GetStringExtra("idBooking"));
                Console.WriteLine("ID: " + id);

                parameter.Add("id", id);
                parameter.Add("adate", "2018/" + amonth + "/" + aday);
                parameter.Add("atime", ahour + ":" + amin);
                parameter.Add("service", aservice);

                client.UploadValuesCompleted += Client_UploadValuesCompleted;
                client.UploadValuesAsync(uri, parameter);
            }
            else
            {
                Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(this);
                alert.SetTitle("Date Past");
                alert.SetMessage("You cannot reschedule to a date that has past");
                alert.SetPositiveButton("OK", (senderAlert, args) =>
                {
                });
                Dialog dialog = alert.Create();
                dialog.Show();
            }
        }
Example #22
0
        async void OnDoneNewInvestmentClicked(object sender, EventArgs e)
        {
            WebClient client = new WebClient();
            Uri       uri    = new Uri("http://web.engr.oregonstate.edu/~jonesty/AddInvestment.php");

            newInvestment.tickersymbol   = App.currentInvestment.tickersymbol;
            newInvestment.pricepurchased = float.Parse(purchasepriceEntry.Text, CultureInfo.InvariantCulture.NumberFormat);
            newInvestment.numberofshares = float.Parse(numSharesEntry.Text, CultureInfo.InvariantCulture.NumberFormat);

            NameValueCollection parameters = new NameValueCollection();

            parameters.Add("portfolioname", App.currentPortfolio.Name);
            parameters.Add("tickersymbol", App.currentInvestment.tickersymbol);
            parameters.Add("numshares", numSharesEntry.Text);
            parameters.Add("pricepurchased", purchasepriceEntry.Text);

            client.UploadValuesAsync(uri, parameters);

            /*var rootPage = Navigation.NavigationStack.FirstOrDefault();
             * if (rootPage != null)
             * {
             *  Navigation.InsertPageBefore(new PortfolioDetails(App.currentPortfolio), Navigation.NavigationStack.First());
             *  await Navigation.PopToRootAsync();
             * }*/
            // await Navigation.PushAsync(new PortfolioDetails(App.currentPortfolio));
            await Navigation.PopAsync();
        }
        public static void Remove(string parent, string id, Action <bool> onFinished = null)
        {
            if (Application.Manifest == null || string.IsNullOrEmpty(Application.Manifest.DatabaseUrl))
            {
                return;
            }
            Remove remove = new Remove()
            {
                Auth   = Application.Integration.Auth,
                Id     = id,
                Parent = parent
            };
            NameValueCollection nameValueCollection = new NameValueCollection()
            {
                { "data", JsonConvert.SerializeObject(remove) }
            };
            Uri       uri       = new Uri(Application.Manifest.DatabaseUrl.Replace("{action}", "remove"));
            WebClient webClient = new WebClient()
            {
                Encoding = Encoding.UTF8
            };

            if (onFinished != null)
            {
                webClient.UploadValuesCompleted += new UploadValuesCompletedEventHandler((object s, UploadValuesCompletedEventArgs e) => {
                    BaseResponse baseResponse = JsonConvert.DeserializeObject <BaseResponse>(Encoding.UTF8.GetString(e.Result));
                    onFinished(baseResponse.Status == "ok");
                });
            }
            webClient.UploadValuesAsync(uri, "POST", nameValueCollection);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.schedule_activity);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            ISharedPreferences pref = Application.Context.GetSharedPreferences("UserInfor", FileCreationMode.Private);

            ip = pref.GetString("IP", String.Empty);

            DrawerLayout          drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);

            drawer.AddDrawerListener(toggle);
            toggle.SyncState();


            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.SetNavigationItemSelectedListener(this);

            listview            = FindViewById <ListView>(Resource.Id.listView1);
            listview.ItemClick += Listview_ItemClick;

            client = new WebClient();
            uri    = new Uri("http://" + ip + "/getSchedule.php");
            NameValueCollection parameter = new NameValueCollection();

            parameter.Add("username", pref.GetString("Username", String.Empty));

            client.UploadValuesCompleted += Client_UploadValuesCompleted;
            client.UploadValuesAsync(uri, parameter);
        }
Example #25
0
 internal static void OnlineImport(PaintToolsView paintToolsView)
 {
     if (waiting)
     {
         Main.NewText("Be patient");
         return;
     }
     if (CheatSheet.instance.paintToolsUI.view.slotList.Any(x => x.browserID > 0))
     {
         Main.NewText("You've already loaded the database");
         return;
     }
     waiting = true;
     try
     {
         using (WebClient client = new WebClient())
         {
             var    steamIDMethodInfo = typeof(Main).Assembly.GetType("Terraria.ModLoader.ModLoader").GetProperty("SteamID64", BindingFlags.Static | BindingFlags.NonPublic);
             string steamid64         = (string)steamIDMethodInfo.GetValue(null, null);
             var    values            = new NameValueCollection
             {
                 { "version", CheatSheet.instance.Version.ToString() },
                 { "steamid64", steamid64 },
             };
             client.UploadValuesCompleted += new UploadValuesCompletedEventHandler(GetSchematicsComplete);
             client.UploadValuesAsync(schematicsurl, "POST", values);
         }
     }
     catch
     {
         Main.NewText("Schematics Server problem 1");
         waiting = false;
     }
 }
Example #26
0
 //Met à jour toutes les données de la fiche
 private void button4_Click(object sender, EventArgs e)
 {
     if (textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "")
     {
         DialogResult dialogResult = MessageBox.Show("êtes vous sûre de vouloir modifier ces valeurs ? ", "Confirmation avant modification", MessageBoxButtons.YesNo);
         if (dialogResult == DialogResult.Yes)
         {
             NameValueCollection postValues = new NameValueCollection();
             postValues["action"] = "MAJ_Frais_Forfait";
             postValues["ETP"]    = textBox4.Text;
             postValues["KM"]     = textBox5.Text;
             postValues["NUI"]    = textBox3.Text;
             postValues["REP"]    = textBox2.Text;
             postValues["mois"]   = InverseTraitementDate(comboBox3.Text);
             postValues["id"]     = VisiteurSelected;
             WebClient webClient = new WebClient();
             webClient.Proxy = null;
             webClient.UploadValuesAsync(new Uri(IpAddr), "POST", postValues);
         }
     }
     else
     {
         MessageBox.Show("Toutes les cases doivent être remplies.", "Erreure de saisie");
     }
 }
Example #27
0
        private static void GetToken()
        {
            try
            {
                ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback;

                var acsEndpoint = CommonConfiguration.Instance.BackboneConfiguration.GetACSEndpoint();

                // Note that the realm used when requesting a token uses the HTTP scheme, even though
                // calls to the service are always issued over HTTPS
                var realm = CommonConfiguration.Instance.BackboneConfiguration.GetRealm();

                NameValueCollection values = new NameValueCollection();
                values.Add("wrap_name", CommonConfiguration.Instance.BackboneConfiguration.IssuerName);
                values.Add("wrap_password", CommonConfiguration.Instance.BackboneConfiguration.IssuerSecret);
                values.Add("wrap_scope", realm);

                using (WebClient webClient = new WebClient())
                {
                    webClient.UploadValuesCompleted += WebClient_UploadValuesCompleted;;
                    webClient.UploadValuesAsync(new Uri(acsEndpoint), values);
                }
            }
            catch (Exception)
            {
                // TODO: log exception
                _tokenRequested = false;
            }
        }
Example #28
0
        /// <summary>
        /// Called whenever the Update button is clicked. Checks if there are errors in user
        /// input and if there are none attempts to add updated student information to the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!waiting)
            {
                waiting = true;
                if (btnGender.Checked)
                {
                    gender = "Male";
                }
                else
                {
                    gender = "Female";
                }

                errors = false;
                resetErrorText();
                validateForm();

                if (!errors)
                {
                    WebClient client = new WebClient();

                    setParameters();


                    progressBar.Visibility        = ViewStates.Visible;
                    client.UploadValuesCompleted += client_UploadValuesCompleted;
                    client.UploadValuesAsync(uri, parameters);
                    client.Dispose();
                }
            }
        }
Example #29
0
        public void method_4(string string_2, string string_3)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            GClass95.Class83 class83 = new GClass95.Class83();
            // ISSUE: reference to a compiler-generated field
            class83.gclass95_0 = this;
            this.method_3();
            if (this.FileSaveLocation == null)
            {
                return;
            }
            WebClient webClient = new WebClient();

            if (new WebClient().UploadValues(new Uri(string.Format("{0}/saves/get_save.php", (object)Class67.String_1)), new NameValueCollection()
            {
                {
                    "username",
                    string_2
                },
                {
                    "password",
                    string_3
                },
                {
                    "titleid",
                    this.gclass30_0.TitleId.IdRaw
                },
                {
                    "hash",
                    "true"
                }
            }).Length == 0)
            {
                return;
            }
            // ISSUE: reference to a compiler-generated field
            class83.frmWait_0 = new FrmWait("USB Helper is downloading your save", true);
            // ISSUE: reference to a compiler-generated method
            webClient.UploadValuesCompleted += new UploadValuesCompletedEventHandler(class83.method_0);
            // ISSUE: reference to a compiler-generated method
            webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(class83.method_1);
            webClient.UploadValuesAsync(new Uri(string.Format("{0}/saves/get_save.php", (object)Class67.String_1)), new NameValueCollection()
            {
                {
                    "username",
                    string_2
                },
                {
                    "password",
                    string_3
                },
                {
                    "titleid",
                    this.gclass30_0.TitleId.IdRaw
                }
            });
            // ISSUE: reference to a compiler-generated field
            int num = (int)class83.frmWait_0.ShowDialog();
        }
Example #30
0
        public string Send(int timeoutSec = 10)
        {
            var wc = new WebClient();

            wc.UploadValuesCompleted += wc_UploadValuesCompleted;

            wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            wc.Headers.Add("Origin", "http://elpis.adamhaile.net");

            if (PRequest.Proxy != null)
            {
                wc.Proxy = PRequest.Proxy;
            }

            wc.UploadValuesAsync(new Uri(_url), "POST", _params);

            DateTime start = DateTime.Now;

            while (!_uploadComplete && ((DateTime.Now - start).TotalMilliseconds < (timeoutSec * 1000)))
            {
                Thread.Sleep(25);
            }

            if (_uploadComplete)
            {
                return(_uploadResult);
            }

            wc.CancelAsync();

            throw new Exception("Timeout waiting for POST to " + _url);
        }
Example #31
0
 public static async Task ConcurrentOperations_Throw()
 {
     await LoopbackServer.CreateServerAsync((server, url) =>
     {
         var wc = new WebClient();
         Task ignored = wc.DownloadDataTaskAsync(url); // won't complete
         Assert.Throws<NotSupportedException>(() => { wc.DownloadData(url); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadDataAsync(url); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadDataTaskAsync(url); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadString(url); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadStringAsync(url); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadStringTaskAsync(url); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadFile(url, "path"); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadFileAsync(url, "path"); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadFileTaskAsync(url, "path"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadData(url, new byte[42]); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadDataAsync(url, new byte[42]); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadDataTaskAsync(url, new byte[42]); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadString(url, "42"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadStringAsync(url, "42"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadStringTaskAsync(url, "42"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadFile(url, "path"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadFileAsync(url, "path"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadFileTaskAsync(url, "path"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadValues(url, new NameValueCollection()); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadValuesAsync(url, new NameValueCollection()); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadValuesTaskAsync(url, new NameValueCollection()); });
         return Task.CompletedTask;
     });
 }
Example #32
0
        public static void UploadValues_InvalidArguments_ThrowExceptions()
        {
            var wc = new WebClient();
            
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadValues((string)null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadValues((string)null, null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadValues((Uri)null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadValues((Uri)null, null, null); });

            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadValuesAsync((Uri)null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadValuesAsync((Uri)null, null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadValuesAsync((Uri)null, null, null, null); });

            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadValuesTaskAsync((string)null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadValuesTaskAsync((string)null, null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadValuesTaskAsync((Uri)null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadValuesTaskAsync((Uri)null, null, null); });

            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadValues("http://localhost", null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadValues("http://localhost", null, null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadValues(new Uri("http://localhost"), null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadValues(new Uri("http://localhost"), null, null); });

            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadValuesAsync(new Uri("http://localhost"), null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadValuesAsync(new Uri("http://localhost"), null, null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadValuesAsync(new Uri("http://localhost"), null, null, null); });

            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadValuesTaskAsync("http://localhost", null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadValuesTaskAsync("http://localhost", null, null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadValuesTaskAsync(new Uri("http://localhost"), null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadValuesTaskAsync(new Uri("http://localhost"), null, null); });
        }