Exemplo n.º 1
0
        public async Task <IEnumerable <BasketPositionModel> > GetCustomerBasket(long customerId)
        {
            GraphQLRequest request = new GraphQLRequest
            {
                Query     = @"
                    query BasketQuery($customerId: Int!) {
                        basket(customerId: $customerId) {
                            id
                            customerId
                            productId
                            productName
                            productDescription
                            quantity
                            price
                        }
                    }",
                Variables = new { customerId = customerId }
            };

            GraphQLResponse response = await this.graphQLClient.PostAsync(request);

            if (response.Errors != null && response.Errors.Any())
            {
                throw new HttpRequestException(response.Errors[0].Message);
            }

            return(response.GetDataFieldAs <List <BasketPositionModel> >("basket"));
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <ProductModel> > GetAllProducts()
        {
            GraphQLRequest request = new GraphQLRequest
            {
                Query = @"
                    query ProductsQuery {
                        products {
                            id
                            name
                            description
                            price
                            count
                        }
                    }"
            };

            GraphQLResponse response = await this.graphQLClient.PostAsync(request);

            if (response.Errors != null && response.Errors.Any())
            {
                throw new HttpRequestException(response.Errors[0].Message);
            }

            return(response.GetDataFieldAs <List <ProductModel> >("products"));
        }
Exemplo n.º 3
0
        public async Task <CustomerModel> Get(long customerId)
        {
            GraphQLRequest request = new GraphQLRequest
            {
                Query     = @"
                    query CustomerQuery($customerId: ID!) {
                        customer(id: $customerId) {
                            id
                            firstName
                            surname
                            address
                            email
                        }
                    }",
                Variables = new { customerId = customerId }
            };

            GraphQLResponse response = await this.graphQLClient.PostAsync(request);

            if (response.Errors != null && response.Errors.Any())
            {
                throw new HttpRequestException(response.Errors[0]?.Message);
            }

            return(response.GetDataFieldAs <CustomerModel>("customer"));
        }
Exemplo n.º 4
0
        public UserData GetMyInfo()
        {
            if (!_account.IsAuthenticated)
            {
                _account.RaiseError("Authentication is required to use this query. Set the Dlive.AuthorizationToken property with your user token to authenticate");
                return(new UserData());
            }

            if (!Dlive.CanExecuteQuery())
            {
                Task.Delay((Dlive.NextIntervalReset - DateTime.Now).Milliseconds).Wait();
            }
            Dlive.IncreaseQueryCounter();

            GraphQLResponse response = _account.Client.SendQueryAsync(GraphqlHelper.GetQueryString(QueryType.ME)).Result;

            if (response.Data.me == null)
            {
                throw new AccountException($"User data was not received, this could be caused by an expired user token!");
            }

            RawUserData userData = response.GetDataFieldAs <RawUserData>("me");

            return(userData.ToUserData());
        }
Exemplo n.º 5
0
        public async Task <ProductModel> GetProductById(long productId)
        {
            GraphQLRequest request = new GraphQLRequest
            {
                Query     = @"
                    query ProductQuery($productId: ID!) {
                        product(id: $productId) {
                            id
                            name
                            description
                            price
                            count
                        }
                    }",
                Variables = new { productId = productId }
            };

            using (GraphQLClient graphQLClient = new GraphQLClient(this.options))
            {
                GraphQLResponse response = await graphQLClient.PostAsync(request);

                if (response.Errors != null && response.Errors.Any())
                {
                    throw new HttpRequestException(response.Errors[0].Message);
                }

                return(response.GetDataFieldAs <ProductModel>("product"));
            }
        }
Exemplo n.º 6
0
 public override void ResetSeed()
 {
     try
     {
         GraphQLRequest LoginReq = new GraphQLRequest
         {
             Query = "mutation{rotateServerSeed{ seed seedHash nonce } changeClientSeed(seed:\"" + R.Next(0, int.MaxValue).ToString() + "\"){seed}}"
         };
         GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
         if (Resp.Data != null)
         {
             pdSeed user = Resp.GetDataFieldAs <pdSeed>("rotateServerSeed");
         }
         else if (Resp.Errors != null && Resp.Errors.Length > 0)
         {
             foreach (var x in Resp.Errors)
             {
                 Parent.DumpLog("GRAPHQL ERROR PD RESETSEED: " + x.Message, 1);
             }
         }
     }
     catch (Exception e)
     {
         Parent.updateStatus("Failed to reset seed.");
     }
 }
Exemplo n.º 7
0
        public async Task <IEnumerable <CustomerModel> > GetAllCustomers()
        {
            GraphQLRequest request = new GraphQLRequest
            {
                Query = @"
                    query CustomersQuery {
                        customers {
                            id
                            firstName
                            surname
                            address
                            email
                        }
                    }"
            };

            GraphQLResponse response = await this.graphQLClient.PostAsync(request);

            if (response.Errors != null && response.Errors.Any())
            {
                throw new HttpRequestException(response.Errors[0].Message);
            }

            return(response.GetDataFieldAs <List <CustomerModel> >("customers"));
        }
Exemplo n.º 8
0
 public override void ResetSeed()
 {
     GraphQLRequest LoginReq = new GraphQLRequest
     {
         Query = "mutation{rotateSeed(clientSeed:\":" + R.Next().ToString() + "\" ){ clientSeed serverSeedHash nonce }}"
     };
     GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
     pdSeed          user = Resp.GetDataFieldAs <pdSeed>("rotateSeed");
 }
Exemplo n.º 9
0
        public override void Login(string Username, string Password, string otp)
        {
            try
            {
                GraphQLRequest LoginReq = new GraphQLRequest
                {
                    Query = "mutation{loginUser(name:\"" + Username + "\", password:\"" + Password + "\"" + (string.IsNullOrWhiteSpace(otp) ? "" : ",tfaToken:\"" + otp + "\"") + ") {activeSeed { serverSeedHash clientSeed nonce} id balances{available{currency amount value}} throttles{key value ttl type refType refId} statistic {bets wins losses amount profit currency value}}}"
                };
                GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                pdUser          user = Resp.GetDataFieldAs <pdUser>("loginUser");
                userid = user.id;
                if (string.IsNullOrWhiteSpace(userid))
                {
                    finishedlogin(false);
                }
                else
                {
                    foreach (Statistic x in user.statistic)
                    {
                        if (x.currency.ToLower() == Currency.ToLower())
                        {
                            this.bets    = (int)x.bets;
                            this.wins    = (int)x.wins;
                            this.losses  = (int)x.losses;
                            this.profit  = (decimal)x.profit;
                            this.wagered = (decimal)x.amount;
                            break;
                        }
                    }
                    foreach (Balance x in user.balances)
                    {
                        if (x.available.currency.ToLower() == Currency.ToLower())
                        {
                            balance = (decimal)x.available.amount;
                            break;
                        }
                    }

                    finishedlogin(true);
                    return;
                }
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                }
                finishedlogin(false);
            }
            catch (Exception e)
            {
                finishedlogin(false);
            }
        }
        public void GetDataFieldAsFact()
        {
            var graphQLResponse1 = new GraphQLResponse {
                Data = new {
                    hero = new Person {
                        Name = "R2-D2"
                    }
                },
            };

            Assert.Equal("R2-D2", graphQLResponse1.GetDataFieldAs <Person>("hero").Name);
        }
Exemplo n.º 11
0
 void GetBalanceThread()
 {
     try
     {
         while (ispd)
         {
             if (userid != null && ((DateTime.Now - lastupdate).TotalSeconds >= 30 || ForceUpdateStats))
             {
                 ForceUpdateStats = false;
                 lastupdate       = DateTime.Now;
                 GraphQLRequest LoginReq = new GraphQLRequest
                 {
                     Query = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}"
                 };
                 GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                 pdUser          user = Resp.GetDataFieldAs <pdUser>("user");
                 foreach (Statistic x in user.statistic)
                 {
                     if (x.currency.ToLower() == Currency.ToLower() && x.game == StatGameName)
                     {
                         this.bets    = (int)x.bets;
                         this.wins    = (int)x.wins;
                         this.losses  = (int)x.losses;
                         this.profit  = (decimal)x.profit;
                         this.wagered = (decimal)x.betAmount;
                         break;
                     }
                 }
                 foreach (Balance x in user.balances)
                 {
                     if (x.available.currency.ToLower() == Currency.ToLower())
                     {
                         balance = (decimal)x.available.amount;
                         break;
                     }
                 }
                 Parent.updateBalance(balance);
                 Parent.updateWagered(wagered);
                 Parent.updateProfit(profit);
                 Parent.updateBets(bets);
                 Parent.updateWins(wins);
                 Parent.updateLosses(losses);
             }
             Thread.Sleep(1000);
         }
     }
     catch (Exception e)
     {
         Parent.DumpLog(e.ToString(), -1);
     }
 }
Exemplo n.º 12
0
 void GetBalanceThread()
 {
     try
     {
         while (ispd)
         {
             if (userid != null)
             {
                 GraphQLRequest LoginReq = new GraphQLRequest
                 {
                     Query = "query{user {activeSeed { serverSeedHash clientSeed nonce} id balances{available{currency amount value}} throttles{key value ttl type refType refId} statistic {bets wins losses amount profit currency value}}}"
                 };
                 GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                 pdUser          user = Resp.GetDataFieldAs <pdUser>("user");
                 foreach (Statistic x in user.statistic)
                 {
                     if (x.currency.ToLower() == Currency.ToLower())
                     {
                         this.bets    = (int)x.bets;
                         this.wins    = (int)x.wins;
                         this.losses  = (int)x.losses;
                         this.profit  = (decimal)x.profit;
                         this.wagered = (decimal)x.amount;
                         break;
                     }
                 }
                 foreach (Balance x in user.balances)
                 {
                     if (x.available.currency.ToLower() == Currency.ToLower())
                     {
                         balance = (decimal)x.available.amount;
                         break;
                     }
                 }
                 Parent.updateBalance(balance);
                 Parent.updateWagered(wagered);
                 Parent.updateProfit(profit);
                 Parent.updateBets(bets);
                 Parent.updateWins(wins);
                 Parent.updateLosses(losses);
             }
             Thread.Sleep(1000);
         }
     }
     catch (Exception e)
     {
         Parent.DumpLog(e.ToString(), -1);
     }
 }
Exemplo n.º 13
0
        public async IAsyncEnumerable <PackageVersion> GetPackageVersions(string owner, string repository, string package, int maxCount = 100)
        {
            string query = $@"query {{ repository(owner: ""{owner}"", name:""{repository}"") {{
                        packages (names: ""{package}"", first: 1) {{
                            nodes {{
                                versions(last: {maxCount}) {{ nodes {{ version, id }}
                                }} }} }} }} }}";

            GraphQLResponse resp = await this._client.PostAsync(new GraphQLRequest { Query = query });

            if (resp.Errors?.Any() ?? false)
            {
                throw new InvalidOperationException(resp.Errors.First().Message);
            }

            Repository repo = resp.GetDataFieldAs <Repository>("repository");

            foreach (PackageVersion version in repo?.packages?.nodes?.FirstOrDefault()?.versions?.nodes)
            {
                yield return(version);
            }
        }
Exemplo n.º 14
0
        public async Task <OrderModel> GetOrderById(long orderId)
        {
            GraphQLRequest request = new GraphQLRequest
            {
                Query     = @"
                    query OrderQuery($orderId: ID!) {
                        order(id: $orderId) {
                            id
                            customerId
                            firstName
                            surname
                            dateCreated
                            status
                            orderPositions {
                                id
                                orderId
                                productId
                                productName
                                productDescription
                                count
                                price
                            }
                        }
                    }",
                Variables = new { orderId = orderId }
            };

            using (GraphQLClient graphQLClient = new GraphQLClient(this.graphQLClientOptions))
            {
                GraphQLResponse response = await graphQLClient.PostAsync(request);

                if (response.Errors != null && response.Errors.Any())
                {
                    throw new HttpRequestException(response.Errors[0].Message);
                }

                return(response.GetDataFieldAs <OrderModel>("order"));
            }
        }
Exemplo n.º 15
0
        public static PublicUserData GetPublicInfo(string username)
        {
            if (!Dlive.CanExecuteQuery())
            {
                Task.Delay((Dlive.NextIntervalReset - DateTime.Now).Milliseconds).Wait();
            }
            Dlive.IncreaseQueryCounter();

            GraphQLResponse response = _publicClient.SendQueryAsync(GraphqlHelper.GetQueryString(QueryType.USER, new string[] { username })).Result;

            PublicUserData userData;

            if (response.Data.user != null)
            {
                userData = response.GetDataFieldAs <RawUserData>("user").ToPublicUserData();
            }
            else
            {
                userData = new PublicUserData("invalid user", "Invalid User", PartnerStatus.NONE, false, "", null, true, null, null, 0, 0, 0, 0);
            }

            return(userData);
        }
Exemplo n.º 16
0
        public override void Login(string Username, string Password, string otp)
        {
            try
            {
                GQLClient = new GraphQL.Client.GraphQLClient(URL);
                GraphQLRequest LoginReq = new GraphQLRequest
                {
                    Query = "mutation{loginUser(name:\"" + Username + "\", password:\"" + Password + "\"" + (string.IsNullOrWhiteSpace(otp) ? "" : ",tfaToken:\"" + otp + "\"") + ") {activeServerSeed { seedHash seed nonce} activeClientSeed {seed} id statistic {bets wins losses amount profit currency} balances{available{currency amount}} }}"
                };
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

                GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                if (Resp.Errors != null)
                {
                    if (Resp.Errors.Length > 0)
                    {
                        Parent.DumpLog(Resp.Errors[0].Message, -1);
                        Parent.updateStatus(Resp.Errors[0].Message);
                        finishedlogin(false);
                        return;
                    }
                }
                pdUser user = Resp.GetDataFieldAs <pdUser>("loginUser");
                userid = user.id;
                if (string.IsNullOrWhiteSpace(userid))
                {
                    finishedlogin(false);
                }
                else
                {
                    foreach (Statistic x in user.statistic)
                    {
                        if (x.currency.ToLower() == Currency.ToLower())
                        {
                            this.bets    = (int)x.bets;
                            this.wins    = (int)x.wins;
                            this.losses  = (int)x.losses;
                            this.profit  = (decimal)x.profit;
                            this.wagered = (decimal)x.amount;
                            break;
                        }
                    }
                    foreach (Balance x in user.balances)
                    {
                        if (x.available.currency.ToLower() == Currency.ToLower())
                        {
                            balance = (decimal)x.available.amount;
                            break;
                        }
                    }

                    finishedlogin(true);
                    ispd = true;
                    Thread t = new Thread(GetBalanceThread);
                    t.Start();
                    return;
                }
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                }
                finishedlogin(false);
            }
            catch (Exception e)
            {
                Parent.DumpLog(e.ToString(), -1);
                finishedlogin(false);
            }
        }
Exemplo n.º 17
0
        void placebetthread(object bet)
        {
            try
            {
                PlaceBetObj tmp5   = bet as PlaceBetObj;
                decimal     amount = tmp5.Amount;
                decimal     chance = tmp5.Chance;
                bool        High   = tmp5.High;

                decimal tmpchance = High ? maxRoll - chance : chance;

                GraphQLResponse betresult = GQLClient.PostAsync(new GraphQLRequest {
                    Query = "mutation{" + RolName + "(amount:" + amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo) + ", target:" + tmpchance.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo) + ",condition:" + (High ? "above" : "below") + ",currency:" + Currency.ToLower() + ") { id nonce currency amount payout state { ... on " + GameName + " { result target condition } } createdAt serverSeed{seedHash seed nonce} clientSeed{seed} user{balances{available{amount currency}} statistic{game bets wins losses betAmount profit currency}}}}"
                }).Result;
                if (betresult.Errors != null)
                {
                    if (betresult.Errors.Length > 0)
                    {
                        Parent.updateStatus(betresult.Errors[0].Message);
                    }
                }
                if (betresult.Data != null)
                {
                    RollDice tmp = betresult.GetDataFieldAs <RollDice>(RolName);


                    Lastbet = DateTime.Now;
                    try
                    {
                        lastupdate = DateTime.Now;
                        foreach (Statistic x in tmp.user.statistic)
                        {
                            if (x.currency.ToLower() == Currency.ToLower() && x.game == StatGameName)
                            {
                                this.bets    = (int)x.bets;
                                this.wins    = (int)x.wins;
                                this.losses  = (int)x.losses;
                                this.profit  = (decimal)x.profit;
                                this.wagered = (decimal)x.betAmount;
                                break;
                            }
                        }
                        foreach (Balance x in tmp.user.balances)
                        {
                            if (x.available.currency.ToLower() == Currency.ToLower())
                            {
                                balance = (decimal)x.available.amount;
                                break;
                            }
                        }
                        Bet tmpbet = tmp.ToBet(maxRoll);

                        if (getid)
                        {
                            GraphQLResponse betresult2 = GQLClient.PostAsync(new GraphQLRequest {
                                Query = " query{bet(betId:\"" + tmpbet.Id + "\"){iid}}"
                            }).Result;

                            if (betresult2.Data != null)
                            {
                                //RollDice tmp2 = betresult2.GetDataFieldAs<RollDice>(RolName);

                                //tmpbet.Id = tmp2.iid;
                                tmpbet.Id = betresult2.Data.bet.iid;
                                if (tmpbet.Id.Contains("house:"))
                                {
                                    tmpbet.Id = tmpbet.Id.Substring("house:".Length);
                                }
                            }
                        }

                        tmpbet.Guid = tmp5.Guid;
                        FinishedBet(tmpbet);
                        retrycount = 0;
                    }
                    catch (Exception e)
                    {
                        Parent.DumpLog(e.ToString(), -1);
                        Parent.updateStatus("Some kind of error happened. I don't really know graphql, so your guess as to what went wrong is as good as mine.");
                    }
                }
            }
            catch (AggregateException e)
            {
                if (retrycount++ < 3)
                {
                    Thread.Sleep(500);
                    placebetthread(new PlaceBetObj(High, amount, chance, (bet as PlaceBetObj).Guid));
                    return;
                }
                if (e.InnerException.Message.Contains("429") || e.InnerException.Message.Contains("502"))
                {
                    Thread.Sleep(500);
                    placebetthread(new PlaceBetObj(High, amount, chance, (bet as PlaceBetObj).Guid));
                }
            }
            catch (Exception e2)
            {
                Parent.updateStatus("Error occured while trying to bet, retrying in 30 seconds. Probably.");
                Parent.DumpLog(e2.ToString(), -1);
            }
        }
Exemplo n.º 18
0
        public override void Login(string Username, string Password, string otp)
        {
            try
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                //RequireCaptchaEventArgs Captchaval = new RequireCaptchaEventArgs { PublicKey = CaptchaKey, Domain=this.URL };
                //RequireCaptcha(Captchaval);
                GQLClient = new GraphQL.Client.GraphQLClient(URL);

                /*GraphQLRequest LoginReq = new GraphQLRequest
                 * {
                 *  Query = "mutation{loginUser(captcha:\""+Captchaval.ResponseValue+ "\" name:\"" + Username + "\", password:\"" + Password + "\"" + (string.IsNullOrWhiteSpace(otp) ? "" : ",tfaToken:\"" + otp + "\"") + ") {activeServerSeed { seedHash seed nonce} activeClientSeed {seed} id statistic {bets wins losses amount profit currency} balances{available{currency amount}} }}"
                 * };
                 *
                 * GQLClient
                 * GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                 * if (Resp.Errors != null)
                 * {
                 *  if (Resp.Errors.Length > 0)
                 *  {
                 *      Parent.DumpLog(Resp.Errors[0].Message, -1);
                 *      Parent.updateStatus(Resp.Errors[0].Message);
                 *      finishedlogin(false);
                 *      return;
                 *  }
                 * }
                 * pdUser user = Resp.GetDataFieldAs<pdUser>("loginUser");*/
                GQLClient.DefaultRequestHeaders.Add("x-access-token", Password);

                /*
                 * var subscriptionResult = GQLClient.SendSubscribeAsync(@"subscription { chatMessages(chatId: "14939265 - 52a4 - 404e-8a0c - 6e3e10d915b4") { id chat { id name isPublic } createdAt user { id name roles { name } } data { ... on ChatMessageDataBot { message } ... on ChatMessageDataText { message } ... on ChatMessageDataTip { tip { id amount currency sender: sendBy { id name } receiver: user { id name } } } } } } ").Result;
                 * subscriptionResult.OnReceive += (res) => { Console.WriteLine(res.Data.messageAdded.content); };
                 */


                GraphQLRequest LoginReq = new GraphQLRequest
                {
                    Query = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}"
                };
                GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                pdUser          user = Resp.GetDataFieldAs <pdUser>("user");

                userid = user.id;
                if (string.IsNullOrWhiteSpace(userid))
                {
                    finishedlogin(false);
                }
                else
                {
                    foreach (Statistic x in user.statistic)
                    {
                        if (x.currency.ToLower() == Currency.ToLower() && x.game == StatGameName)
                        {
                            this.bets    = (int)x.bets;
                            this.wins    = (int)x.wins;
                            this.losses  = (int)x.losses;
                            this.profit  = (decimal)x.profit;
                            this.wagered = (decimal)x.betAmount;
                            break;
                        }
                    }
                    foreach (Balance x in user.balances)
                    {
                        if (x.available.currency.ToLower() == Currency.ToLower())
                        {
                            balance = (decimal)x.available.amount;
                            break;
                        }
                    }

                    finishedlogin(true);
                    ispd = true;
                    Thread t = new Thread(GetBalanceThread);
                    t.Start();
                    return;
                }
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                }
                finishedlogin(false);
            }
            catch (Exception e)
            {
                Parent.DumpLog(e.ToString(), -1);
                finishedlogin(false);
            }
        }
Exemplo n.º 19
0
 protected override RandomDTO ParseResponse(GraphQLResponse response)
 => response.GetDataFieldAs <RandomDTO>("random");
Exemplo n.º 20
0
        void placebetthread(object bet)
        {
            try
            {
                PlaceBetObj tmp5   = bet as PlaceBetObj;
                decimal     amount = tmp5.Amount;
                decimal     chance = tmp5.Chance;
                bool        High   = tmp5.High;

                /*if (amount < 10000 && (DateTime.Now - Lastbet).TotalMilliseconds < 500)
                 * {
                 *  Thread.Sleep((int)(500.0 - (DateTime.Now - Lastbet).TotalMilliseconds));
                 * }*/
                decimal tmpchance = High ? 99.99m - chance : chance;

                GraphQLResponse betresult = GQLClient.PostAsync(new GraphQLRequest {
                    Query = "mutation{rollDice(amount:" + amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo) + ", target:" + tmpchance.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo) + ",condition:" + (High ? "above" : "below") + ",currency:btc) { id iid nonce currency amount value payout result target condition createdAt seed{serverSeedHash serverSeed clientSeed nonce} user{balances{available{amount currency}} statistic{bets wins losses amount profit currency}}}}"
                }).Result;
                RollDice tmp = betresult.GetDataFieldAs <RollDice>("rollDice");


                Lastbet = DateTime.Now;
                try
                {
                    lastupdate = DateTime.Now;
                    foreach (Statistic x in tmp.user.statistic)
                    {
                        if (x.currency.ToLower() == Currency.ToLower())
                        {
                            this.bets    = (int)x.bets;
                            this.wins    = (int)x.wins;
                            this.losses  = (int)x.losses;
                            this.profit  = (decimal)x.profit;
                            this.wagered = (decimal)x.amount;
                            break;
                        }
                    }
                    foreach (Balance x in tmp.user.balances)
                    {
                        if (x.available.currency.ToLower() == Currency.ToLower())
                        {
                            balance = (decimal)x.available.amount;
                            break;
                        }
                    }
                    Bet tmpbet = tmp.ToBet();
                    tmpbet.Guid = tmp5.Guid;
                    FinishedBet(tmpbet);
                    retrycount = 0;
                }
                catch
                {
                    Parent.updateStatus("Some kind of error happened. I don't really know graphql, so your guess as to what went wrong is as good as mine.");
                }
            }
            catch (AggregateException e)
            {
                if (retrycount++ < 3)
                {
                    Thread.Sleep(500);
                    placebetthread(new PlaceBetObj(High, amount, chance, (bet as PlaceBetObj).Guid));
                    return;
                }
                if (e.InnerException.Message.Contains("429") || e.InnerException.Message.Contains("502"))
                {
                    Thread.Sleep(500);
                    placebetthread(new PlaceBetObj(High, amount, chance, (bet as PlaceBetObj).Guid));
                }
            }
            catch (Exception e2)
            {
                Parent.updateStatus("Error occured while trying to bet, retrying in 30 seconds. Probably.");
                Parent.DumpLog(e2.ToString(), -1);
            }
        }
Exemplo n.º 21
0
        public override void Login(string Username, string Password, string otp)
        {
            try
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                //RequireCaptchaEventArgs Captchaval = new RequireCaptchaEventArgs { PublicKey = CaptchaKey, Domain=this.URL };
                //RequireCaptcha(Captchaval);
                GQLClient = new GraphQL.Client.GraphQLClient(URL);

                /*GraphQLRequest LoginReq = new GraphQLRequest
                 * {
                 *  Query = "mutation{loginUser(captcha:\""+Captchaval.ResponseValue+ "\" name:\"" + Username + "\", password:\"" + Password + "\"" + (string.IsNullOrWhiteSpace(otp) ? "" : ",tfaToken:\"" + otp + "\"") + ") {activeServerSeed { seedHash seed nonce} activeClientSeed {seed} id statistic {bets wins losses amount profit currency} balances{available{currency amount}} }}"
                 * };
                 *
                 * GQLClient
                 * GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                 * if (Resp.Errors != null)
                 * {
                 *  if (Resp.Errors.Length > 0)
                 *  {
                 *      Parent.DumpLog(Resp.Errors[0].Message, -1);
                 *      Parent.updateStatus(Resp.Errors[0].Message);
                 *      finishedlogin(false);
                 *      return;
                 *  }
                 * }
                 * pdUser user = Resp.GetDataFieldAs<pdUser>("loginUser");*/
                GQLClient.DefaultRequestHeaders.Add("x-access-token", Password);
                GraphQLRequest LoginReq = new GraphQLRequest
                {
                    Query = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {bets wins losses amount profit currency}}}"
                };
                GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                pdUser          user = Resp.GetDataFieldAs <pdUser>("user");

                userid = user.id;
                if (string.IsNullOrWhiteSpace(userid))
                {
                    finishedlogin(false);
                }
                else
                {
                    foreach (Statistic x in user.statistic)
                    {
                        if (x.currency.ToLower() == Currency.ToLower())
                        {
                            this.bets    = (int)x.bets;
                            this.wins    = (int)x.wins;
                            this.losses  = (int)x.losses;
                            this.profit  = (decimal)x.profit;
                            this.wagered = (decimal)x.amount;
                            break;
                        }
                    }
                    foreach (Balance x in user.balances)
                    {
                        if (x.available.currency.ToLower() == Currency.ToLower())
                        {
                            balance = (decimal)x.available.amount;
                            break;
                        }
                    }

                    finishedlogin(true);
                    ispd = true;
                    Thread t = new Thread(GetBalanceThread);
                    t.Start();
                    return;
                }
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                }
                finishedlogin(false);
            }
            catch (Exception e)
            {
                Parent.DumpLog(e.ToString(), -1);
                finishedlogin(false);
            }
        }