private void SteamSaleDataGridViewCellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } this.allItemsListGridUtils.UpdateItemDescription( this.AllSteamItemsGridView.CurrentCell.RowIndex, this.ItemDescriptionTextBox, this.ItemImageBox, this.ItemNameLable); switch (e.ColumnIndex) { case 5: this.allItemsListGridUtils.GridComboBoxClick(e.RowIndex); break; case 6: this.allItemsListGridUtils.GridAddButtonClick(e.RowIndex, this.ItemsToSaleGridView); PriceLoader.StartPriceLoading(ETableToLoad.ItemsToSaleTable); break; } } catch (Exception ex) { Logger.Critical(@"Error on 'Market sell' - 'All items grid' cell click", ex); } }
private void LoadListingButtonClick(object sender, EventArgs e) { try { if (CurrentSession.SteamManager == null) { MessageBox.Show( @"You should login first", @"Error market listing loading", MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.Error("Error on market listing loading. No signed in account found."); return; } this.AllSteamItemsGridView.Rows.Clear(); MyListings.Clear(); this.LoadListingButton.Enabled = false; Task.Run( () => { Program.LoadingForm.InitMyListingsLoadingProcess(); var listings = Program.LoadingForm.GetMyListings(); Program.LoadingForm.DeactivateForm(); var groupedListings = listings?.Sales?.GroupBy(x => new { x.HashName, x.Price }); if (groupedListings == null) { return; } foreach (var group in groupedListings) { var item = group.FirstOrDefault(); if (item == null) { return; } MyListings.Add(item.HashName + item.Price, group.ToList()); this.AddListing( item.Name, group.Count(), SteamItemsUtils.GetClearType(item.Game), item.Date, item.Price, item.HashName); } PriceLoader.StartPriceLoading(ETableToLoad.RelistTable); }); this.LoadListingButton.Enabled = true; } catch (Exception ex) { Logger.Critical("Error on loading listed market items", ex); } }
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); } }
private void ForcePricesReloadButtonClick(object sender, EventArgs e) { try { PriceLoader.StartPriceLoading(ETableToLoad.ItemsToSaleTable, true); } catch (Exception ex) { Logger.Critical(ex); } }
private void button1_Click(object sender, EventArgs e) { try { PriceLoader loader = new PriceLoader(); loader.LoadPrices(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public MarketRelistControl() { try { this.InitializeComponent(); this.AddHeaderCheckBox(); PriceLoader.Init(this.AllSteamItemsGridView, ETableToLoad.RelistTable); } catch (Exception ex) { Logger.Critical(ex); } }
private void reloadPricesButton_Click(object sender, EventArgs e) { try { PriceLoader loader = new PriceLoader(); loader.LoadPrices(); RefreshTable(); RefreshProjectsList(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
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}"); } } }
public SaleControl() { try { this.InitializeComponent(); this.allItemsListGridUtils = new AllItemsListGridUtils(this.AllSteamItemsGridView); PriceLoader.Init(this.AllSteamItemsGridView, ETableToLoad.AllItemsTable); PriceLoader.Init(this.ItemsToSaleGridView, ETableToLoad.ItemsToSaleTable); this.InventoryAppIdComboBox.Text = SavedSettings.Get().MarketInventoryAppId; this.InventoryContextIdComboBox.Text = SavedSettings.Get().MarketInventoryContexId; } catch (Exception ex) { Logger.Critical(ex); } }
private void AddAllButtonClick(object sender, EventArgs e) { try { this.AllSteamItemsGridView.CurrentCellChanged -= this.AllSteamItemsGridViewCurrentCellChanged; this.ItemsToSaleGridView.CurrentCellChanged -= this.ItemsToSaleGridViewCurrentCellChanged; this.allItemsListGridUtils.AddCellListToSale( this.ItemsToSaleGridView, this.AllSteamItemsGridView.SelectedRows.Cast<DataGridViewRow>().ToArray()); this.AllSteamItemsGridView.CurrentCellChanged += this.AllSteamItemsGridViewCurrentCellChanged; this.ItemsToSaleGridView.CurrentCellChanged += this.ItemsToSaleGridViewCurrentCellChanged; Logger.Debug("All selected items was added to sale list"); PriceLoader.StartPriceLoading(ETableToLoad.ItemsToSaleTable); } catch (Exception ex) { Logger.Critical("Error on 'Market Sell' - 'Add all' button click", ex); } }
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); } }
public void SellOnMarket(ToSaleObject items) { PriceLoader.WaitForLoadFinish(); var maxErrorsCount = SavedSettings.Get().ErrorsOnSellToSkip; var currentItemIndex = 1; var itemsToConfirmCount = SavedSettings.Get().Settings2FaItemsToConfirm; var totalItemsCount = items.ItemsForSaleList.Sum(x => x.Items.Count()); var timeTracker = new SellTimeTracker(itemsToConfirmCount); foreach (var package in items.ItemsForSaleList) { var itemName = package.Items.First().Description.Name; if (!package.Price.HasValue) { try { var task = Task.Run(async() => await items.GetPrice(package.Items.First(), this)); Program.WorkingProcessForm.AppendWorkingProcessInfo($"Processing price for '{itemName}'"); task.Wait(); var price = task.Result; if (price != null) { package.Price = price; } } catch (Exception ex) { if (ex is ThreadAbortException) { return; } Logger.Error("Error on market price parse", ex); Program.WorkingProcessForm.AppendWorkingProcessInfo( $"ERROR on selling '{itemName}' - {ex.Message}{ex.InnerException?.Message}"); totalItemsCount -= package.Items.Sum(e => int.Parse(e.Asset.Amount)); continue; } } var packageElementIndex = 1; var packageTotalItemsCount = package.Items.Count(); var errorsCount = 0; foreach (var item in package.Items) { try { Program.WorkingProcessForm.AppendWorkingProcessInfo( $"[{currentItemIndex}/{totalItemsCount}] Selling - [{packageElementIndex++}/{packageTotalItemsCount}] - '{itemName}' for {package.Price}"); if (package.Price.HasValue) { this.SellOnMarket(item, package.Price.Value); } else { Program.WorkingProcessForm.AppendWorkingProcessInfo( $"ERROR on selling '{itemName}' - Price is not loaded. Skipping item."); currentItemIndex += package.Items.Count(); break; } if (currentItemIndex % itemsToConfirmCount == 0) { Task.Run(this.ConfirmMarketTransactions); timeTracker.TrackTime(totalItemsCount - currentItemIndex); } } catch (Exception ex) { if (ex is ThreadAbortException) { return; } Logger.Error("Error on market sell", ex); Program.WorkingProcessForm.AppendWorkingProcessInfo( $"ERROR on selling '{itemName}' - {ex.Message}{ex.InnerException?.Message}"); if (++errorsCount == maxErrorsCount) { Program.WorkingProcessForm.AppendWorkingProcessInfo( $"{maxErrorsCount} fails limit on sell {itemName} reached. Skipping item."); totalItemsCount -= packageTotalItemsCount - packageElementIndex; break; } } currentItemIndex++; } } Task.Run(this.ConfirmMarketTransactions); }