Aggiunta opzione "Ricorda Stato" per le aste salvate
È stata introdotta l'opzione "Ricorda Stato" che consente di ripristinare lo stato esatto (attiva, in pausa, ferma) di ogni asta salvata al caricamento. - Aggiunto il `RadioButton` "Ricorda Stato" in `SettingsControl.xaml`. - Gestita la nuova opzione in `MainWindow.EventHandlers.Settings.cs`. - Aggiornata la logica di caricamento in `AuctionManagement.cs` per supportare "Ricorda Stato". - Introdotto il salvataggio automatico dello stato delle aste in `ButtonHandlers.cs` e `Commands.cs`. - Migliorati i log per riflettere il comportamento del sistema. - Aggiunta la proprietà `RememberAuctionStates` in `SettingsManager` con valore predefinito `false`. - Migliorata la leggibilità e manutenibilità del codice. Queste modifiche migliorano la flessibilità e l'esperienza utente, garantendo coerenza dei dati e maggiore chiarezza nei log.
This commit is contained in:
@@ -256,11 +256,10 @@ namespace AutoBidder
|
||||
{
|
||||
try
|
||||
{
|
||||
// ? Carica impostazioni per determinare lo stato iniziale delle aste
|
||||
// ? Carica impostazioni
|
||||
var settings = Utilities.SettingsManager.Load();
|
||||
var loadState = settings.DefaultStartAuctionsOnLoad; // "Active", "Paused", "Stopped"
|
||||
|
||||
// Ottieni username corrente dalla sessione per riprist inare IsMyBid
|
||||
// Ottieni username corrente dalla sessione per ripristinare IsMyBid
|
||||
var session = _auctionMonitor.GetSession();
|
||||
var currentUsername = session?.Username ?? string.Empty;
|
||||
|
||||
@@ -273,7 +272,7 @@ namespace AutoBidder
|
||||
// Decode HTML entities
|
||||
try { auction.Name = System.Net.WebUtility.HtmlDecode(auction.Name ?? string.Empty); } catch { }
|
||||
|
||||
// ? NUOVO: Ripristina IsMyBid per tutte le puntate in RecentBids
|
||||
// ? Ripristina IsMyBid per tutte le puntate in RecentBids
|
||||
if (auction.RecentBids != null && auction.RecentBids.Count > 0 && !string.IsNullOrEmpty(currentUsername))
|
||||
{
|
||||
foreach (var bid in auction.RecentBids)
|
||||
@@ -282,22 +281,32 @@ namespace AutoBidder
|
||||
}
|
||||
}
|
||||
|
||||
// ? Applica stato iniziale configurato dall'utente
|
||||
switch (loadState)
|
||||
// ? NUOVO: Gestione stato in base a RememberAuctionStates
|
||||
if (settings.RememberAuctionStates)
|
||||
{
|
||||
case "Active":
|
||||
auction.IsActive = true;
|
||||
auction.IsPaused = false;
|
||||
break;
|
||||
case "Paused":
|
||||
auction.IsActive = true;
|
||||
auction.IsPaused = true;
|
||||
break;
|
||||
case "Stopped":
|
||||
default:
|
||||
auction.IsActive = false;
|
||||
auction.IsPaused = false;
|
||||
break;
|
||||
// MODO 1: Ripristina lo stato salvato di ogni asta (IsActive e IsPaused vengono dal file salvato)
|
||||
// Non serve fare nulla, lo stato è già quello salvato nel file
|
||||
}
|
||||
else
|
||||
{
|
||||
// MODO 2: Applica DefaultStartAuctionsOnLoad a tutte le aste
|
||||
var loadState = settings.DefaultStartAuctionsOnLoad;
|
||||
switch (loadState)
|
||||
{
|
||||
case "Active":
|
||||
auction.IsActive = true;
|
||||
auction.IsPaused = false;
|
||||
break;
|
||||
case "Paused":
|
||||
auction.IsActive = true;
|
||||
auction.IsPaused = true;
|
||||
break;
|
||||
case "Stopped":
|
||||
default:
|
||||
auction.IsActive = false;
|
||||
auction.IsPaused = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_auctionMonitor.AddAuction(auction);
|
||||
@@ -305,8 +314,7 @@ namespace AutoBidder
|
||||
_auctionViewModels.Add(vm);
|
||||
}
|
||||
|
||||
// ? FIX: Avvia monitoraggio se ci sono aste in stato Active O Paused
|
||||
// (Paused = IsActive=true ma IsPaused=true, quindi vanno monitorate)
|
||||
// ? Avvia monitoraggio se ci sono aste in stato Active O Paused
|
||||
bool hasActiveOrPausedAuctions = auctions.Any(a => a.IsActive);
|
||||
|
||||
if (hasActiveOrPausedAuctions && auctions.Count > 0)
|
||||
@@ -314,13 +322,23 @@ namespace AutoBidder
|
||||
_auctionMonitor.Start();
|
||||
_isAutomationActive = true;
|
||||
|
||||
if (loadState == "Active")
|
||||
if (settings.RememberAuctionStates)
|
||||
{
|
||||
Log($"[AUTO-START] Monitoraggio avviato automaticamente per {auctions.Count} aste caricate in stato attivo", LogLevel.Info);
|
||||
var activeCount = auctions.Count(a => a.IsActive && !a.IsPaused);
|
||||
var pausedCount = auctions.Count(a => a.IsActive && a.IsPaused);
|
||||
Log($"[AUTO-START] Monitoraggio avviato: {activeCount} attive, {pausedCount} in pausa (stati ripristinati)", LogLevel.Info);
|
||||
}
|
||||
else if (loadState == "Paused")
|
||||
else
|
||||
{
|
||||
Log($"[AUTO-START] Monitoraggio avviato automaticamente per {auctions.Count} aste caricate in pausa", LogLevel.Info);
|
||||
var loadState = settings.DefaultStartAuctionsOnLoad;
|
||||
if (loadState == "Active")
|
||||
{
|
||||
Log($"[AUTO-START] Monitoraggio avviato automaticamente per {auctions.Count} aste caricate in stato attivo", LogLevel.Info);
|
||||
}
|
||||
else if (loadState == "Paused")
|
||||
{
|
||||
Log($"[AUTO-START] Monitoraggio avviato automaticamente per {auctions.Count} aste caricate in pausa", LogLevel.Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +348,14 @@ namespace AutoBidder
|
||||
// Log sempre mostrato (anche con 0 aste)
|
||||
if (auctions.Count > 0)
|
||||
{
|
||||
Log($"[LOAD] {auctions.Count} aste caricate con stato iniziale: {loadState}", LogLevel.Info);
|
||||
if (settings.RememberAuctionStates)
|
||||
{
|
||||
Log($"[LOAD] {auctions.Count} aste caricate con stati individuali ripristinati", LogLevel.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log($"[LOAD] {auctions.Count} aste caricate con stato iniziale: {settings.DefaultStartAuctionsOnLoad}", LogLevel.Info);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user