Aggiunta infrastruttura avanzata per gestione aste

- Introdotta la classe `BidooApiClient` per interagire con le API Bidoo.
- Aggiunto `SessionManager` per la gestione sicura delle sessioni.
- Creato `TestBidooApi` per test manuali delle API.
- Implementato `CsvExporter` per esportare dati e statistiche in CSV.
- Aggiunto `PersistenceManager` per salvare e caricare aste in JSON.
- Introdotto `AuctionViewModel` per supportare il pattern MVVM.
- Migliorata l'interfaccia utente con layout moderno e stili dinamici.
- Aggiornata la documentazione in `README.md` per riflettere le nuove funzionalità.
- Aggiunte classi per rappresentare informazioni, stato e storico delle aste.
- Ottimizzate le richieste HTTP per simulare un browser reale.
This commit is contained in:
Alberto Balbo
2025-10-23 23:10:46 +02:00
parent db1d99d424
commit 4e16f50aeb
26 changed files with 4522 additions and 2576 deletions

View File

@@ -0,0 +1,247 @@
using System.Windows;
using System.Windows.Controls;
namespace AutoBidder
{
/// <summary>
/// Dialog per inizializzare sessione Bidoo
/// Richiede: Auth Token + Username
/// </summary>
public class SessionDialog : Window
{
private readonly TextBox _tokenTextBox;
private readonly TextBox _usernameTextBox;
public string AuthToken => _tokenTextBox.Text.Trim();
public string Username => _usernameTextBox.Text.Trim();
public SessionDialog(string existingToken = "", string existingUsername = "")
{
Title = "Configura Sessione Bidoo";
Width = 680;
Height = 420;
WindowStartupLocation = WindowStartupLocation.CenterOwner;
ResizeMode = ResizeMode.NoResize;
Background = System.Windows.Media.Brushes.Black;
Foreground = System.Windows.Media.Brushes.White;
var grid = new Grid { Margin = new Thickness(20) };
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(10) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(140) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(15) });
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(10) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(40) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20) });
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
var label1 = new TextBlock
{
Text = "Cookie __stattrb (F12 > Application > Cookies > __stattrb):",
FontWeight = FontWeights.SemiBold,
Foreground = System.Windows.Media.Brushes.White,
TextWrapping = TextWrapping.Wrap
};
Grid.SetRow(label1, 0);
_tokenTextBox = new TextBox
{
Text = existingToken,
Padding = new Thickness(10),
TextWrapping = TextWrapping.Wrap,
AcceptsReturn = false,
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
VerticalContentAlignment = VerticalAlignment.Top,
Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(15, 15, 15)),
Foreground = System.Windows.Media.Brushes.LightGray,
FontFamily = new System.Windows.Media.FontFamily("Consolas"),
FontSize = 11,
ToolTip = "Esempio: eyJVU0VSSUQiOiI2NzA3NjY0Ii..."
};
Grid.SetRow(_tokenTextBox, 2);
var label2 = new TextBlock
{
Text = "Username Bidoo:",
FontWeight = FontWeights.SemiBold,
Foreground = System.Windows.Media.Brushes.White
};
Grid.SetRow(label2, 4);
_usernameTextBox = new TextBox
{
Text = existingUsername,
Padding = new Thickness(10),
FontSize = 14,
VerticalContentAlignment = VerticalAlignment.Center,
Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(15, 15, 15)),
Foreground = System.Windows.Media.Brushes.LightGray
};
Grid.SetRow(_usernameTextBox, 6);
var buttonPanel = new StackPanel
{
Orientation = Orientation.Horizontal,
HorizontalAlignment = HorizontalAlignment.Right
};
Grid.SetRow(buttonPanel, 8);
var okButton = new Button
{
Content = "Conferma",
Width = 120,
Height = 40,
Margin = new Thickness(0, 0, 10, 0),
Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 204, 102)),
Foreground = System.Windows.Media.Brushes.White,
FontWeight = FontWeights.Bold,
FontSize = 14
};
var cancelButton = new Button
{
Content = "Annulla",
Width = 120,
Height = 40,
Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(204, 0, 0)),
Foreground = System.Windows.Media.Brushes.White,
FontWeight = FontWeights.Bold,
FontSize = 14
};
okButton.Click += (s, e) =>
{
if (string.IsNullOrWhiteSpace(AuthToken) || string.IsNullOrWhiteSpace(Username))
{
MessageBox.Show("Inserisci Token e Username!", "Errore", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
DialogResult = true;
Close();
};
cancelButton.Click += (s, e) => { DialogResult = false; Close(); };
buttonPanel.Children.Add(okButton);
buttonPanel.Children.Add(cancelButton);
grid.Children.Add(label1);
grid.Children.Add(_tokenTextBox);
grid.Children.Add(label2);
grid.Children.Add(_usernameTextBox);
grid.Children.Add(buttonPanel);
Content = grid;
Loaded += (s, e) => _tokenTextBox.Focus();
}
}
/// <summary>
/// Dialog semplificato per aggiungere asta (ID o URL completo)
/// </summary>
public class AddAuctionSimpleDialog : Window
{
private readonly TextBox _auctionIdTextBox;
public string AuctionId => _auctionIdTextBox.Text.Trim();
public AddAuctionSimpleDialog()
{
Title = "Aggiungi Asta";
Width = 680;
Height = 280;
WindowStartupLocation = WindowStartupLocation.CenterOwner;
ResizeMode = ResizeMode.NoResize;
Background = System.Windows.Media.Brushes.Black;
Foreground = System.Windows.Media.Brushes.White;
var grid = new Grid { Margin = new Thickness(20) };
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(10) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(50) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(10) });
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(50) });
var label = new TextBlock
{
Text = "URL Asta o ID:",
FontWeight = FontWeights.SemiBold,
Foreground = System.Windows.Media.Brushes.White
};
Grid.SetRow(label, 0);
_auctionIdTextBox = new TextBox
{
Text = "",
Padding = new Thickness(10),
FontSize = 13,
Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(15, 15, 15)),
Foreground = System.Windows.Media.Brushes.LightGray,
VerticalContentAlignment = VerticalAlignment.Center
};
Grid.SetRow(_auctionIdTextBox, 2);
var hintLabel = new TextBlock
{
Text = "Esempio: https://it.bidoo.com/auction.php?a=Galaxy_S25_Ultra_256GB_81204324\nOppure: 81204324",
FontSize = 11,
Foreground = System.Windows.Media.Brushes.Gray,
TextWrapping = TextWrapping.Wrap
};
Grid.SetRow(hintLabel, 4);
var buttonPanel = new StackPanel
{
Orientation = Orientation.Horizontal,
HorizontalAlignment = HorizontalAlignment.Right
};
Grid.SetRow(buttonPanel, 6);
var okButton = new Button
{
Content = "Aggiungi",
Width = 120,
Height = 40,
Margin = new Thickness(0, 0, 10, 0),
Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 204, 102)),
Foreground = System.Windows.Media.Brushes.White,
FontWeight = FontWeights.Bold,
FontSize = 14
};
var cancelButton = new Button
{
Content = "Annulla",
Width = 120,
Height = 40,
Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(204, 0, 0)),
Foreground = System.Windows.Media.Brushes.White,
FontWeight = FontWeights.Bold,
FontSize = 14
};
okButton.Click += (s, e) => { DialogResult = true; Close(); };
cancelButton.Click += (s, e) => { DialogResult = false; Close(); };
_auctionIdTextBox.KeyDown += (s, e) =>
{
if (e.Key == System.Windows.Input.Key.Enter)
{
DialogResult = true;
Close();
}
};
buttonPanel.Children.Add(okButton);
buttonPanel.Children.Add(cancelButton);
grid.Children.Add(label);
grid.Children.Add(_auctionIdTextBox);
grid.Children.Add(hintLabel);
grid.Children.Add(buttonPanel);
Content = grid;
Loaded += (s, e) => _auctionIdTextBox.Focus();
}
}
}