Beispiel #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++;
            }
        }
Beispiel #2
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.Black;
                        tbLog.SelectedText   = DateTime.Now.ToLongTimeString() +
                                               " Buyout for Player " +
                                               mgTable[1, _i].Value + Environment.NewLine;
                        WriteLog.DoWrite("Buyout for Player " + mgTable[1, _i].Value);
                        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);
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText   = DateTime.Now.ToLongTimeString() +
                                       " Error on search- Please be sure that your transfermarket is not locked" +
                                       Environment.NewLine;
            }
            finally
            {
                _i++;
            }
        }