Example #1
0
        void GetBalanceThread()
        {
            while (ispd)
            {
                try
                {
                    if (accesstoken != "" && ((DateTime.Now - lastupdate).TotalSeconds > 10 || ForceUpdateStats))
                    {
                        lastupdate       = DateTime.Now;
                        ForceUpdateStats = false;
                        List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                        pairs.Add(new KeyValuePair <string, string>("c", "99999999"));
                        pairs.Add(new KeyValuePair <string, string>("g[]", "999999999"));
                        pairs.Add(new KeyValuePair <string, string>("k", "0"));
                        pairs.Add(new KeyValuePair <string, string>("m", "99999899"));
                        pairs.Add(new KeyValuePair <string, string>("u", "0"));
                        pairs.Add(new KeyValuePair <string, string>("self_only", "1"));

                        HttpResponseMessage resp1 = Client.GetAsync("").Result;
                        string s1 = "";
                        if (resp1.IsSuccessStatusCode)
                        {
                            s1 = resp1.Content.ReadAsStringAsync().Result;
                            //Parent.DumpLog("BE login 2.1", 7);
                        }
                        else
                        {
                            //Parent.DumpLog("BE login 2.2", 7);
                            if (resp1.StatusCode == HttpStatusCode.ServiceUnavailable)
                            {
                                s1 = resp1.Content.ReadAsStringAsync().Result;
                                //cflevel = 0;
                                System.Threading.Tasks.Task.Factory.StartNew(() =>
                                {
                                    System.Windows.Forms.MessageBox.Show("Bitvest.io has their cloudflare protection on HIGH\n\nThis will cause a slight delay in logging in. Please allow up to a minute.");
                                });
                                if (!Cloudflare.doCFThing(s1, Client, ClientHandlr, 0, "bitvest.io"))
                                {
                                    finishedlogin(false);
                                    return;
                                }
                            }
                            //Parent.DumpLog("BE login 2.3", 7);
                        }

                        FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                        string sEmitResponse          = Client.PostAsync("https://bitvest.io/update.php", Content).Result.Content.ReadAsStringAsync().Result;
                        sEmitResponse = sEmitResponse.Replace("r-", "r_").Replace("n-", "n_");

                        BivestGetBalanceRoot tmpbase = json.JsonDeserialize <BivestGetBalanceRoot>(sEmitResponse);
                        if (tmpbase != null)
                        {
                            if (tmpbase.data != null)
                            {
                                switch (Currency.ToLower())
                                {
                                case "bitcoins":
                                    balance = tmpbase.data.balance; break;

                                case "ethers":
                                    balance = tmpbase.data.ether_balance; break;

                                case "litecoins":
                                    balance = tmpbase.data.litecoin_balance; break;

                                case "dogecoins":
                                    balance = tmpbase.data.balance_dogecoin; break;

                                case "bcash":
                                    balance = tmpbase.data.balance_bcash; break;

                                default:
                                    balance = tmpbase.data.token_balance; break;
                                }

                                /*if (Currency.ToLower() == "bitcoins")
                                 * {
                                 *  balance = decimal.Parse(tmpbase.data.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                                 * }
                                 * else
                                 * {
                                 *  balance = decimal.Parse(tmpbase.data.token_balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                                 * }if (Currency.ToLower() == "bitcoins")
                                 * {
                                 * balance = decimal.Parse(tmplogin.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                                 * }
                                 * else if (Currency.ToLower() == "ethereum")
                                 * {
                                 * balance = decimal.Parse(tmplogin.token_balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                                 * }
                                 * else if (Currency.ToLower() == "litecoin")
                                 * {
                                 * balance = decimal.Parse(tmplogin.token_balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                                 * }
                                 * else
                                 * {
                                 * balance = decimal.Parse(tmplogin.token_balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                                 * }*/
                                Parent.updateBalance(balance);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Parent.DumpLog(e.ToString(), -1);
                }
                Thread.Sleep(1000);
            }
        }
Example #2
0
        void GetBalanceThread()
        {
            while (ispd)
            {
                try
                {
                    if (accesstoken != "" && ((DateTime.Now - lastupdate).TotalSeconds > 10 || ForceUpdateStats))
                    {
                        lastupdate       = DateTime.Now;
                        ForceUpdateStats = false;
                        List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                        pairs.Add(new KeyValuePair <string, string>("c", "99999999"));
                        pairs.Add(new KeyValuePair <string, string>("g[]", "999999999"));
                        pairs.Add(new KeyValuePair <string, string>("k", "0"));
                        pairs.Add(new KeyValuePair <string, string>("m", "99999899"));
                        pairs.Add(new KeyValuePair <string, string>("u", "0"));
                        pairs.Add(new KeyValuePair <string, string>("self_only", "1"));

                        FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                        string sEmitResponse          = Client.PostAsync("https://bitvest.io/update.php", Content).Result.Content.ReadAsStringAsync().Result;
                        sEmitResponse = sEmitResponse.Replace("r-", "r_").Replace("n-", "n_");

                        BivestGetBalanceRoot tmpbase = json.JsonDeserialize <BivestGetBalanceRoot>(sEmitResponse);
                        if (tmpbase != null)
                        {
                            if (tmpbase.data != null)
                            {
                                switch (Currency.ToLower())
                                {
                                case "bitcoins":
                                    balance = tmpbase.data.balance; break;

                                case "ethers":
                                    balance = tmpbase.data.ether_balance; break;

                                case "litecoins":
                                    balance = tmpbase.data.litecoin_balance; break;

                                default:
                                    balance = tmpbase.data.token_balance; break;
                                }

                                /*if (Currency.ToLower() == "bitcoins")
                                 * {
                                 *  balance = decimal.Parse(tmpbase.data.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                                 * }
                                 * else
                                 * {
                                 *  balance = decimal.Parse(tmpbase.data.token_balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                                 * }if (Currency.ToLower() == "bitcoins")
                                 * {
                                 * balance = decimal.Parse(tmplogin.balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                                 * }
                                 * else if (Currency.ToLower() == "ethereum")
                                 * {
                                 * balance = decimal.Parse(tmplogin.token_balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                                 * }
                                 * else if (Currency.ToLower() == "litecoin")
                                 * {
                                 * balance = decimal.Parse(tmplogin.token_balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                                 * }
                                 * else
                                 * {
                                 * balance = decimal.Parse(tmplogin.token_balance, System.Globalization.NumberFormatInfo.InvariantInfo);
                                 * }*/
                                Parent.updateBalance(balance);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Parent.DumpLog(e.ToString(), -1);
                }
                Thread.Sleep(1000);
            }
        }