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)); } } }
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}"); } }