Inheritance: UltimateTeam.Toolkit.Parameters.SearchParameters
Example #1
0
        private async void SearchMarket()
        {
            if (_i >= mgTable.Rows.Count - 1) //check if i needs a reset
                _i = 0;

                try
                   {
                
                    var searchParameters = new PlayerSearchParameters
                    {
                        Page = 1,
                        MaxBuy = uint.Parse(mgTable[2, _i].Value.ToString()),
                        ResourceId = uint.Parse(mgTable[8, _i].Value.ToString())

                    };

                    // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
                    uint.Parse(mgTable[3, _i].Value.ToString()); //check sell for null

                    var searchResponse = await _client.SearchAsync(searchParameters);
                    if (_debug)
                    {
                        tbLog.SelectionColor = Color.Blue;
                        tbLog.SelectedText = DateTime.Now.ToLongTimeString() + " Search for Player " +
                                             mgTable[1, _i].Value + Environment.NewLine;
                        tbLog.SelectionColor = Color.Blue;
                        tbLog.SelectedText = DateTime.Now.ToLongTimeString() + " " +
                                             searchResponse.AuctionInfo.Count + " Auctions found" +
                                             Environment.NewLine;
                    }
                    foreach (var auctionInfo in searchResponse.AuctionInfo)
                    {
                        // Handle auction data
                        if (searchResponse.AuctionInfo.Count < _maxplayersonrequest) //check for pricefix
                        {
                            await _client.PlaceBidAsync(auctionInfo, auctionInfo.BuyNowPrice);
                            //Buyout Item
                            await _client.SendItemToTradePileAsync(auctionInfo.ItemData);

                            //send Item to Tradepile
                            int counter = int.Parse(mgTable[4, _i].Value.ToString());
                            counter++;
                            mgTable[4, _i].Value = counter.ToString();
                            tbLog.SelectionColor = Color.Goldenrod;
                            tbLog.SelectedText = DateTime.Now.ToLongTimeString() +
                                                 " Buyout for " + mgTable[1, _i].Value + " for " + auctionInfo.BuyNowPrice + " Credits" + Environment.NewLine;
                            WriteLog.DoWrite("Buyout for " + mgTable[1, _i].Value + " for " + auctionInfo.BuyNowPrice + " Credits");
                            if (_playSound)
                                SystemSounds.Exclamation.Play();
                            GetCredits();
                        }
                    }
                  }
            
            catch (NotEnoughCreditException)
            {
                WriteLog.DoWrite("Not enough credits");
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText = DateTime.Now.ToLongTimeString() + " Not enough credits " +
                                     Environment.NewLine;
            }
            catch (CaptchaTriggeredException) //Captcha Triggered!
            {
                WriteLog.DoWrite("Captach triggered");
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText = DateTime.Now.ToLongTimeString() + " Captcha triggered " +
                                     Environment.NewLine;
                Stopbot();
            }
            catch (ExpiredSessionException) //Session Expired
            {
                WriteLog.DoWrite("Session Expired");
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText = DateTime.Now.ToLongTimeString() + " Session Expired " +
                                     Environment.NewLine;
                Stopbot();
                using (var x = new FormRelog(_account))
                {
                    x.ShowDialog();
                    this._client = x.Client;
                }
                Startbot();
            }
            catch (FormatException)
            {
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText = DateTime.Now.ToLongTimeString() + " Entry " + _i +
                                     " has an invalid Format or is null" +
                                     Environment.NewLine;
                Stopbot();
            }
            catch (NullReferenceException)
            {
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText = DateTime.Now.ToLongTimeString() + " Entry " + _i +
                                     " has an invalid Format or is null" +
                                     Environment.NewLine;
                Stopbot();
            }
            catch (Exception ex)
            {
                WriteLog.DoWrite("Error on search: " + ex.Message);
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText = DateTime.Now.ToLongTimeString() +
                                     " Error on search - Possible temp. ban. Check the market on the WebApp. " + ex.Message +
                                     Environment.NewLine;
            }
            finally
            {
                _i++;
            }
        }
Example #2
0
        private async void SetPrices(uint resId, int row, uint val)
        {
            uint price = val;
            
                try
                {

                var searchParameters2 = new DevelopmentSearchParameters
                {
                    Page = 1,
                    Level = Level.Gold,
                    DevelopmentType = DevelopmentType.Contract,
                };

                var searchParameters = new PlayerSearchParameters
                    {
                        Page = 1,
                        MaxBuy = price,
                        ResourceId = resId,
                        PageSize = 49
                    };

                    var searchResponse = await _client.SearchAsync(searchParameters);

                    foreach (var auctionInfo in searchResponse.AuctionInfo)
                    {
                        if (price > auctionInfo.BuyNowPrice)
                            price = auctionInfo.BuyNowPrice;
                    }

                    await Task.Delay(1000);

                    if (price < val)
                        SetPrices(resId, row, price);
                    else
                    {
                        mgTable[2, row].Value = RoundPrices.RoundToFinal((uint) (price*_buyperc));
                        mgTable[3, row].Value = RoundPrices.RoundToFinal((uint) (price*_sellperc));
                    }
                }
                catch (ExpiredSessionException) //Session Expired
                {
                    WriteLog.DoWrite("Session Expired");
                    tbLog.SelectionColor = Color.Red;
                    tbLog.SelectedText = DateTime.Now.ToLongTimeString() + " Session Expired " +
                                         Environment.NewLine;
                }

            // ReSharper disable once EmptyGeneralCatchClause
            catch
                {
                }
            
        }