Exemplo n.º 1
0
 public static void ProcessTooManyListingsPendingConfirmation(
     UiSteamManager steamManager,
     WorkingProcessDataContext wp)
 {
     wp.AppendLog("Seems market listings stacked. Forsering two factor confirmation");
     ConfirmMarketTransactionsWorkingProcess(steamManager.Guard, wp);
     CancelMarketPendingListings(steamManager, wp);
 }
Exemplo n.º 2
0
        public static void RetryMarketSell(
            int retryCount,
            int delaySeconds,
            MarketSellProcessModel marketSellModel,
            FullRgItem item,
            UiSteamManager uiSteamManager,
            WorkingProcessDataContext wp)
        {
            var currencySymbol = SteamCurrencies.Currencies[uiSteamManager.Currency.ToString()];

            wp.AppendLog(
                retryCount < int.MaxValue
                    ? $"Retrying to sell {marketSellModel.ItemName} {retryCount} more times."
                    : $"Retrying to sell {marketSellModel.ItemName} until success.");

            for (var index = 1; index <= retryCount; index++)
            {
                if (marketSellModel.SellPrice == null)
                {
                    wp.AppendLog(
                        $"Selling price for {marketSellModel.ItemName} not found. Aborting sell retrying process");
                    break;
                }

                if (wp.CancellationToken.IsCancellationRequested)
                {
                    wp.AppendLog("Retrying to sell was force stopped");
                    break;
                }

                try
                {
                    wp.AppendLog(
                        $"Selling - '{marketSellModel.ItemName}' for {marketSellModel.SellPrice} {currencySymbol}");
                    uiSteamManager.SellOnMarket(item, marketSellModel.SellPrice.Value);
                    break;
                }
                catch (Exception e)
                {
                    wp.AppendLog($"Retry {index} failed with error - {e.Message}");
                    if (e.Message.Contains("You already have a listing for this item pending confirmation") ||
                        e.Message.Contains("The item specified is no longer in your inventory"))
                    {
                        return;
                    }
                    Thread.Sleep(TimeSpan.FromSeconds(delaySeconds));
                }
            }
        }
Exemplo n.º 3
0
 public static void ProcessErrorOnMarketSell(
     MarketSellProcessModel marketSellModel,
     FullRgItem item,
     UiSteamManager uiSteamManager,
     string exMessage,
     WorkingProcessDataContext wp)
 {
     if (exMessage.Contains("There was a problem listing your item. Refresh the page and try again.") ||
         exMessage.Contains("A connection that was expected to be kept alive was closed by the server"))
     {
         RetryMarketSell(3, 0, marketSellModel, item, uiSteamManager, wp);
     }
     else if (exMessage.Contains("We were unable to contact the game's item server."))
     {
         RetryMarketSell(10, 2, marketSellModel, item, uiSteamManager, wp);
     }
     else if (exMessage.Contains("You have too many listings pending confirmation"))
     {
         ProcessTooManyListingsPendingConfirmation(uiSteamManager, wp);
     }
     else if (exMessage.Contains("The item specified is no longer in your inventory"))
     {
     }
     else if (exMessage.Contains("You already have a listing for this item pending confirmation"))
     {
     }
     else if (exMessage.Contains("You cannot sell any items until your previous action completes"))
     {
         RetryMarketSell(int.MaxValue, 5, marketSellModel, item, uiSteamManager, wp);
     }
     else
     {
         wp.AppendLog($"Unknown error on market sell - {exMessage}");
         Logger.Log.Error($"Unknown error on market sell - {exMessage}");
     }
 }
Exemplo n.º 4
0
        public static void CancelMarketPendingListings(UiSteamManager steamManager, WorkingProcessDataContext wp)
        {
            MyListingsSalesItem[] myListings;

            try
            {
                myListings = steamManager.MarketClient.MyListings(steamManager.Currency.ToString())?.ConfirmationSales
                             ?.ToArray();
            }
            catch (Exception e)
            {
                wp.AppendLog($"Error on fetching market listings - {e.Message}");
                return;
            }

            if (myListings == null || myListings.Length <= 0)
            {
                wp.AppendLog("No market listing found. Nothing to cancel");
                return;
            }

            wp.AppendLog(
                $"Seems there are {myListings.Length} market listings that do not have two factor confirmation request. Trying to cancel them");

            var semaphore = new Semaphore(
                SettingsProvider.GetInstance().RelistThreadsCount,
                SettingsProvider.GetInstance().RelistThreadsCount);

            var index = 1;

            foreach (var listing in myListings)
            {
                if (wp.CancellationToken.IsCancellationRequested)
                {
                    return;
                }

                if (listing == null)
                {
                    continue;
                }

                try
                {
                    semaphore.WaitOne();
                    var realListing = listing;
                    var realIndex   = index++;
                    Task.Run(
                        () =>
                    {
                        try
                        {
                            var tryCount = 0;
                            while (true)
                            {
                                if (wp.CancellationToken.IsCancellationRequested)
                                {
                                    wp.AppendLog(
                                        $"Cancel market {realListing.Name} pending listings process was force stopped");
                                    break;
                                }

                                wp.AppendLog($"[{realIndex}/{myListings.Length}] Removing {realListing.Name}");
                                var result = steamManager.MarketClient.CancelSellOrder(realListing.SaleId);
                                if (result != ECancelSellOrderStatus.Canceled)
                                {
                                    wp.AppendLog($"ERROR on removing {realListing.Name}");
                                    if (tryCount++ > 10)
                                    {
                                        break;
                                    }
                                    Thread.Sleep(1000);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            wp.AppendLog($"ERROR on removing {realListing.Name} - {e.Message}");
                            Logger.Log.Error($"ERROR on removing {realListing.Name} - {e.Message}", e);
                        }
                        finally
                        {
                            semaphore.Release();
                        }
                    });
                }
                catch (Exception e)
                {
                    wp.AppendLog($"ERROR on removing {listing.Name} - {e.Message}");
                    Logger.Log.Error($"ERROR on removing {listing.Name} - {e.Message}", e);
                }
            }
        }
 public WorkingProcessDataContext(string title, UiSteamManager manager)
 {
     this.Title        = title;
     this.SteamManager = manager;
 }