private void StartSteamSellButtonClick(object sender, EventArgs e) { try { if (CurrentSession.SteamManager == null) { MessageBox.Show( @"You should log in first", @"Error sending trade offer", MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.Error("Error on inventory loading. No logged in accounts found."); return; } double changeValue = 0, changePercentValue = 0; EMarketSaleType marketSaleType; if (this.ManualPriceRadioButton.Checked) { marketSaleType = EMarketSaleType.Manual; } else if (this.RecomendedPriceRadioButton.Checked) { marketSaleType = EMarketSaleType.Recommended; } else if (this.AveregeMinusPriceRadioButton.Checked) { marketSaleType = EMarketSaleType.LowerThanAverage; changeValue = (double)this.AveragePriceNumericUpDown.Value; changePercentValue = (double)this.AveragePricePercentNumericUpDown.Value; } else if (this.CurrentMinusPriceRadioButton.Checked) { marketSaleType = EMarketSaleType.LowerThanCurrent; changeValue = (double)this.CurrentPriceNumericUpDown.Value; changePercentValue = (double)this.CurrentPricePercentNumericUpDown.Value; } else { throw new InvalidOperationException("Not implemented market sale type"); } PriceLoader.StopAll(); var itemsToSale = new PriceShaper( this.ItemsToSaleGridView, marketSaleType, changeValue, changePercentValue).GetItemsForSales(); WorkingProcessForm.InitProcess(() => CurrentSession.SteamManager.SellOnMarket(itemsToSale)); } catch (Exception ex) { Logger.Critical("Error on 'Market sell' - 'Start items sell' button click", ex); } }
public void CancelSellOrder(List <MyListingsSalesItem> itemsToCancel) { var index = 1; const int ThreadsCount = 2; var semaphore = new Semaphore(ThreadsCount, ThreadsCount); var timeTrackCount = SavedSettings.Get().Settings2FaItemsToConfirm; var timeTracker = new SellTimeTracker(timeTrackCount); PriceLoader.StopAll(); PriceLoader.WaitForLoadFinish(); foreach (var item in itemsToCancel) { try { Program.WorkingProcessForm.AppendWorkingProcessInfo( $"[{index++}/{itemsToCancel.Count}] Canceling - '{item.Name}'"); var realIndex = index; semaphore.WaitOne(); Task.Run( () => { var response = this.MarketClient.CancelSellOrder(item.SaleId); if (response == ECancelSellOrderStatus.Fail) { Program.WorkingProcessForm.AppendWorkingProcessInfo( $"[{realIndex}/{itemsToCancel.Count}] Error on market cancel item"); } if (realIndex % timeTrackCount == 0) { timeTracker.TrackTime(itemsToCancel.Count - realIndex); } semaphore.Release(); }); } catch (Exception e) { Program.WorkingProcessForm.AppendWorkingProcessInfo( $"[{index++}/{itemsToCancel.Count}] Error on cancel market item - {e.Message}"); } } }
private void LoadInventoryButtonClick(object sender, EventArgs e) { try { if (CurrentSession.SteamManager == null) { MessageBox.Show( @"You should login first", @"Error inventory loading", MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.Error("Error on inventory loading. No signed in account found."); return; } if (string.IsNullOrEmpty(this.InventoryAppIdComboBox.Text) || string.IsNullOrEmpty(this.InventoryContextIdComboBox.Text)) { MessageBox.Show( @"You should chose inventory type first", @"Error inventory loading", MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.Error("Error on inventory loading. No inventory type chosed."); return; } this.LoadInventoryButton.Enabled = false; string appid; switch (this.InventoryAppIdComboBox.Text) { case "STEAM": appid = "753"; break; case "TF": appid = "440"; break; case "CS:GO": appid = "730"; break; case "PUBG": appid = "578080"; break; case "DOTA": appid = "570"; break; default: appid = this.InventoryAppIdComboBox.Text; break; } var contextId = this.InventoryContextIdComboBox.Text; CurrentSession.CurrentInventoryAppId = appid; CurrentSession.CurrentInventoryContextId = contextId; PriceLoader.StopAll(); Logger.Debug($"Inventory {appid} - {contextId} loading started"); Task.Run( () => { this.LoadInventory( CurrentSession.SteamManager.Guard.Session.SteamID.ToString(), appid, contextId); Logger.Info($"Inventory {appid} - {contextId} loading finished"); Dispatcher.AsMainForm(() => { this.LoadInventoryButton.Enabled = true; }); PriceLoader.StartPriceLoading(ETableToLoad.AllItemsTable); }); } catch (Exception ex) { Logger.Critical("Error on 'Market sell' - 'Load inventory' button click", ex); } }