Exemplo n.º 1
0
        void GetBalanceThread()
        {
            while (IsBitsler)
            {
                if ((DateTime.Now - lastupdate).TotalSeconds > 60 || ForceUpdateStats)
                {
                    lastupdate = DateTime.Now;
                    try
                    {
                        List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                        pairs.Add(new KeyValuePair <string, string>("access_token", accesstoken));
                        FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                        string      sEmitResponse     = Client.PostAsync("getuserstats", Content).Result.Content.ReadAsStringAsync().Result;
                        bsStatsBase bsstatsbase       = JsonConvert.DeserializeObject <bsStatsBase>(sEmitResponse.Replace("\"return\":", "\"_return\":"));
                        if (bsstatsbase != null)
                        {
                            if (bsstatsbase._return != null)
                            {
                                if (bsstatsbase._return.success == "true")
                                {
                                    switch (Currency.ToLower())
                                    {
                                    case "btc":
                                        balance = bsstatsbase._return.btc_balance;
                                        profit  = bsstatsbase._return.btc_profit;
                                        wagered = bsstatsbase._return.btc_wagered; break;

                                    case "ltc":
                                        balance = bsstatsbase._return.ltc_balance;
                                        profit  = bsstatsbase._return.ltc_profit;
                                        wagered = bsstatsbase._return.ltc_wagered; break;

                                    case "doge":
                                        balance = bsstatsbase._return.doge_balance;
                                        profit  = bsstatsbase._return.doge_profit;
                                        wagered = bsstatsbase._return.doge_wagered; break;

                                    case "eth":
                                        balance = bsstatsbase._return.eth_balance;
                                        profit  = bsstatsbase._return.eth_profit;
                                        wagered = bsstatsbase._return.eth_wagered; break;

                                    case "burst":
                                        balance = bsstatsbase._return.burst_balance;
                                        profit  = bsstatsbase._return.burst_profit;
                                        wagered = bsstatsbase._return.burst_wagered; break;
                                    }
                                    bets   = int.Parse(bsstatsbase._return.bets);
                                    wins   = int.Parse(bsstatsbase._return.wins);
                                    losses = int.Parse(bsstatsbase._return.losses);

                                    MessagingCenter.Send(this, "updateBalance", balance);
                                    MessagingCenter.Send(this, "updateBets", bets);
                                    MessagingCenter.Send(this, "updateLosses", losses);
                                    MessagingCenter.Send(this, "updateProfit", profit);
                                    MessagingCenter.Send(this, "updateWagered", wagered);
                                    MessagingCenter.Send(this, "updateWins", wins);
                                }
                                else
                                {
                                    if (bsstatsbase._return.value != null)
                                    {
                                        MessagingCenter.Send(this, "updateStatus", bsstatsbase._return.value);
                                    }
                                }
                            }
                        }
                    }
                    catch { }
                }
                Thread.Sleep(1000);
            }
        }
Exemplo n.º 2
0
        public override async Task <bool> Login(string User, string Password, string twofa)
        {
            bool result = false;

            ClientHandlr = new HttpClientHandler {
                UseCookies             = true,
                AutomaticDecompression = DecompressionMethods.Deflate |
                                         DecompressionMethods.GZip,
                Proxy = this.Prox, UseProxy = Prox != null
            };

            Client = new HttpClient(ClientHandlr)
            {
                BaseAddress = new Uri("https://www.bitsler.com/api/")
            };

            Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("gzip"));
            Client.DefaultRequestHeaders.AcceptEncoding.Add(new System.Net.Http.Headers.StringWithQualityHeaderValue("deflate"));

            try
            {
                List <KeyValuePair <string, string> > pairs = new List <KeyValuePair <string, string> >();
                pairs.Add(new KeyValuePair <string, string>("username", User));
                pairs.Add(new KeyValuePair <string, string>("password", Password));
                pairs.Add(new KeyValuePair <string, string>("api_key", "0b2edbfe44e98df79665e52896c22987445683e78"));
                //if (!string.IsNullOrWhiteSpace(twofa))
                {
                    pairs.Add(new KeyValuePair <string, string>("twofactor", twofa));
                }

                FormUrlEncodedContent Content = new FormUrlEncodedContent(pairs);
                string sEmitResponse          = await(await Client.PostAsync("login", Content)).Content.ReadAsStringAsync();

                //getuserstats
                bsloginbase bsbase = JsonConvert.DeserializeObject <bsloginbase>(sEmitResponse.Replace("\"return\":", "\"_return\":"));

                if (bsbase != null)
                {
                    if (bsbase._return != null)
                    {
                        if (bsbase._return.success == "true")
                        {
                            accesstoken = bsbase._return.access_token;
                            IsBitsler   = true;
                            lastupdate  = DateTime.Now;

                            pairs = new List <KeyValuePair <string, string> >();
                            pairs.Add(new KeyValuePair <string, string>("access_token", accesstoken));
                            Content       = new FormUrlEncodedContent(pairs);
                            sEmitResponse = await(await Client.PostAsync("getuserstats", Content)).Content.ReadAsStringAsync();
                            bsStatsBase bsstatsbase = JsonConvert.DeserializeObject <bsStatsBase>(sEmitResponse.Replace("\"return\":", "\"_return\":"));
                            if (bsstatsbase != null)
                            {
                                if (bsstatsbase._return != null)
                                {
                                    if (bsstatsbase._return.success == "true")
                                    {
                                        switch (Currency.ToLower())
                                        {
                                        case "btc":
                                            balance = bsstatsbase._return.btc_balance;
                                            profit  = bsstatsbase._return.btc_profit;
                                            wagered = bsstatsbase._return.btc_wagered; break;

                                        case "ltc":
                                            balance = bsstatsbase._return.ltc_balance;
                                            profit  = bsstatsbase._return.ltc_profit;
                                            wagered = bsstatsbase._return.ltc_wagered; break;

                                        case "doge":
                                            balance = bsstatsbase._return.doge_balance;
                                            profit  = bsstatsbase._return.doge_profit;
                                            wagered = bsstatsbase._return.doge_wagered; break;

                                        case "eth":
                                            balance = bsstatsbase._return.eth_balance;
                                            profit  = bsstatsbase._return.eth_profit;
                                            wagered = bsstatsbase._return.eth_wagered; break;

                                        case "burst":
                                            balance = bsstatsbase._return.burst_balance;
                                            profit  = bsstatsbase._return.burst_profit;
                                            wagered = bsstatsbase._return.burst_wagered; break;
                                        }
                                        bets   = int.Parse(bsstatsbase._return.bets);
                                        wins   = int.Parse(bsstatsbase._return.wins);
                                        losses = int.Parse(bsstatsbase._return.losses);

                                        MessagingCenter.Send(this, "updateBalance", balance);
                                        MessagingCenter.Send(this, "updateBets", bets);
                                        MessagingCenter.Send(this, "updateLosses", losses);
                                        MessagingCenter.Send(this, "updateProfit", profit);
                                        MessagingCenter.Send(this, "updateWagered", wagered);
                                        MessagingCenter.Send(this, "updateWins", wins);

                                        this.username = User;
                                        result        = true;
                                    }
                                    else
                                    {
                                        if (bsstatsbase._return.value != null)
                                        {
                                            MessagingCenter.Send(this, "updateStatus", bsstatsbase._return.value);
                                        }
                                    }
                                }
                            }


                            IsBitsler = true;
                            var t = new Thread(GetBalanceThread);
                            t.Start();
                            finishedlogin(true);
                            return(result);
                        }
                        else
                        {
                            if (bsbase._return.value != null)
                            {
                                MessagingCenter.Send(this, "updateStatus", bsbase._return.value);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }