* Aggiornamento alla versione 4.0.0 * Refactoring architetturale: introdotte partial classes e UserControls modulari per migliorare manutenibilità e leggibilità. * Aggiunti nuovi UserControls: `AuctionMonitorControl`, `BrowserControl`, `SettingsControl`, `StatisticsControl`. * Introdotto supporto per WebView2 per il browser integrato. * Migliorata gestione delle aste: aggiunta/rimozione tramite URL o ID, configurazione predefinita. * Nuove funzionalità di esportazione: supporto CSV, JSON, XML con opzioni configurabili. * Logging avanzato: codifica colore per severità e auto-scroll. * Tema scuro moderno e miglioramenti UI/UX: sidebar di navigazione, griglie virtualizzate, icone emoji. * Persistenza dati: salvataggio automatico di aste e impostazioni in file JSON. * Documentazione aggiornata: `README.md`, `CHANGELOG.md` e nuovi file di supporto. * Miglioramenti alla sicurezza: cookie di sessione salvati in modo sicuro con DPAPI. * Preparazione per future estensioni: placeholder per funzionalità avanzate e struttura modulare.
119 lines
3.6 KiB
C#
119 lines
3.6 KiB
C#
using System;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace AutoBidder
|
|
{
|
|
/// <summary>
|
|
/// URL parsing and validation utilities
|
|
/// </summary>
|
|
public partial class MainWindow
|
|
{
|
|
private bool IsValidAuctionUrl(string url)
|
|
{
|
|
try
|
|
{
|
|
var uri = new Uri(url);
|
|
var host = uri.Host.ToLowerInvariant();
|
|
|
|
// Valida dominio Bidoo
|
|
if (!host.Contains("bidoo.com") && !host.Contains("bidoo.it") &&
|
|
!host.Contains("bidoo.fr") && !host.Contains("bidoo.es") &&
|
|
!host.Contains("bidoo.de"))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// Valida path asta
|
|
return uri.AbsolutePath.Contains("/asta/") || uri.Query.Contains("a=");
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private string? ExtractAuctionId(string url)
|
|
{
|
|
try
|
|
{
|
|
var uri = new Uri(url);
|
|
|
|
// Formato nuovo: /asta/nome-prodotto-81204324
|
|
var match = Regex.Match(uri.AbsolutePath, @"/asta/[^/]*-(\d{8,})");
|
|
if (match.Success)
|
|
{
|
|
return match.Groups[1].Value;
|
|
}
|
|
|
|
// Formato vecchio: /asta/81204324
|
|
match = Regex.Match(uri.AbsolutePath, @"/asta/(\d{8,})");
|
|
if (match.Success)
|
|
{
|
|
return match.Groups[1].Value;
|
|
}
|
|
|
|
// Formato query: ?a=Galaxy_S25_Ultra_256GB_81204324
|
|
match = Regex.Match(uri.Query, @"[?&]a=([^&]+)");
|
|
if (match.Success)
|
|
{
|
|
var aValue = match.Groups[1].Value;
|
|
|
|
// Estrai ID numerico finale (8+ cifre)
|
|
var idMatch = Regex.Match(aValue, @"(\d{8,})");
|
|
if (idMatch.Success)
|
|
{
|
|
return idMatch.Groups[1].Value;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private string? ExtractProductName(string url)
|
|
{
|
|
try
|
|
{
|
|
var uri = new Uri(url);
|
|
|
|
// Formato query: ?a=Galaxy_S25_Ultra_256GB_81204324
|
|
var match = Regex.Match(uri.Query, @"[?&]a=([^&]+)");
|
|
if (match.Success)
|
|
{
|
|
var aValue = match.Groups[1].Value;
|
|
|
|
// Rimuovi l'ID finale e gli underscore
|
|
var nameMatch = Regex.Match(aValue, @"^(.+?)_(\d{8,})$");
|
|
if (nameMatch.Success)
|
|
{
|
|
var productName = nameMatch.Groups[1].Value;
|
|
productName = productName.Replace('_', ' ');
|
|
return productName;
|
|
}
|
|
}
|
|
|
|
// Formato path: /asta/galaxy-s25-ultra-256gb-81204324
|
|
match = Regex.Match(uri.AbsolutePath, @"/asta/(.+?)-(\d{8,})");
|
|
if (match.Success)
|
|
{
|
|
var productName = match.Groups[1].Value;
|
|
productName = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(
|
|
productName.Replace('-', ' ')
|
|
);
|
|
return productName;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|