Ejemplo n.º 1
0
        private async void Checktradepile()
        {
            int tradepilecount = 0;
            try
            {
                var tradePileResponse = await _client.GetTradePileAsync();
                foreach (var response in tradePileResponse.AuctionInfo)
                {
                    await Task.Delay(2000);
                    for (var i = 0; i < mgTable.Rows.Count - 1; i++)

                        if (response.ItemData != null &&
                            mgTable[8, i].Value.ToString().Contains(response.ItemData.AssetId.ToString()))
                        {

                            if ((response.TradeState == null || response.TradeState.Contains("expired")) &&
                                response.ItemData != null) //Player to list
                            {
                                var buynowprice = uint.Parse(mgTable[3, i].Value.ToString());
                                buynowprice = RoundPrices.RoundToFinal(buynowprice);
                                var bidprice = RoundPrices.DoCalcBidprice(buynowprice);

                                if (buynowprice == 0) //if price = 0 do not sell
                                    continue;
                                else
                                {
                                    var auctionDetails = new AuctionDetails(response.ItemData.Id,
                                         AuctionDuration.OneHour,
                                         bidprice, buynowprice); //bidprice, buynow price
                                    await _client.ListAuctionAsync(auctionDetails);
                                    
                                    WriteLog.DoWrite("Listing " + mgTable[1, i].Value + " for " + auctionDetails.BuyNowPrice);
                                    tbLog.SelectionColor = Color.Black;
                                    tbLog.SelectedText =
                                        (DateTime.Now.ToLongTimeString() + " Listing " + mgTable[1, i].Value + " for " + auctionDetails.BuyNowPrice + " Credits" +
                                        Environment.NewLine);
                                    continue;
                                }
                            }
                            if (response.TradeState != null && response.ItemData != null &&
                                (response.TradeState.Contains("closed"))) //Player sold
                            {
                                await _client.RemoveFromTradePileAsync(response);
                                WriteLog.DoWrite(mgTable[1, i].Value + " sold for " + response.BuyNowPrice + " Credits");
                                tbLog.SelectionColor = Color.Goldenrod;
                                tbLog.SelectedText =
                                    (DateTime.Now.ToLongTimeString() + " " + mgTable[1, i].Value +
                                     " sold for " +
                                     response.BuyNowPrice + " Credits") +
                                    Environment.NewLine;
                                if (_playSound)
                                    SystemSounds.Exclamation.Play();
                                continue;
                            }

                            if (response.TradeState != null && response.ItemData != null) //Player on tradepile
                            {
                                tradepilecount++;
                            }
                                
                        }
                }
            }
            catch (ExpiredSessionException) //Session Expired
            {
                WriteLog.DoWrite("Session Expired");
                tbLog.SelectionColor = Color.Red;
                tbLog.SelectedText = DateTime.Now.ToLongTimeString() + " Session Expired " +
                                     Environment.NewLine;
            }
            catch (Exception ex)
            {
                tbLog.SelectionColor = Color.Red;
                WriteLog.DoWrite("Tradepile Error: " +ex);
                tbLog.SelectedText = DateTime.Now.ToLongTimeString() + " Tradepile Error: " +ex.Message + Environment.NewLine;
            }
            finally
            {
                GetCredits();
                lblTradepile.Text = "Items on Tradepile: " + tradepilecount;
            }
            
        }
        public Task<ListAuctionResponse> ListAuctionAsync(AuctionDetails auctionDetails)
        {
            auctionDetails.ThrowIfNullArgument();

            return _requestFactories.ListAuctionFactory(auctionDetails).PerformRequestAsync();
        }
        public async Task<ListAuctionResponse> ListAuctionAsync(AuctionDetails auctionDetails)
        {
            auctionDetails.ThrowIfNullArgument();

            try
            {
                return await _requestFactories.ListAuctionFactory(auctionDetails).PerformRequestAsync();
            }
            catch (Exception e)
            {
                throw new FutException("List auction failed", e);
            }
        }