* Aggiunto `BooleanToOpacityConverter` per gestire opacità dinamica. * Introdotto nuovo sistema di timing con `BidBeforeDeadlineMs`. * Aggiunta opzione `CheckAuctionOpenBeforeBid` per maggiore sicurezza. * Implementato polling adattivo (10ms-1000ms) e cooldown di 800ms. * Migliorata gestione pulsanti globali con supporto `AUTO-START`/`AUTO-STOP`. * Fix per il tasto `Canc` e focus automatico sul `DataGrid`. * Fix per avvio singola asta senza necessità di "Avvia Tutti". * Aggiornati formati CSV/JSON/XML con nuovi campi. * Migliorata gestione cookie con endpoint unico `buy_bids.php`. * Miglioramenti UI/UX: tooltip, formattazione prezzi, feedback visivo. * Aggiornata documentazione e changelog per la versione 4.0.0.
131 lines
5.4 KiB
C#
131 lines
5.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using AutoBidder.Models;
|
|
|
|
namespace AutoBidder.Utilities
|
|
{
|
|
/// <summary>
|
|
/// Esporta statistiche aste in formato CSV
|
|
/// </summary>
|
|
public static class CsvExporter
|
|
{
|
|
/// <summary>
|
|
/// Esporta cronologia completa di un'asta in CSV
|
|
/// </summary>
|
|
public static void ExportAuctionHistory(AuctionInfo auction, string filePath)
|
|
{
|
|
var csv = new StringBuilder();
|
|
|
|
// Header
|
|
csv.AppendLine("Timestamp,Event Type,Bidder,Price,Timer,Latency (ms),Success,Notes");
|
|
|
|
// Data
|
|
foreach (var entry in auction.BidHistory.OrderBy(h => h.Timestamp))
|
|
{
|
|
csv.AppendLine($"{entry.Timestamp:yyyy-MM-dd HH:mm:ss.fff}," +
|
|
$"{entry.EventType}," +
|
|
$"\"{entry.Bidder}\"," +
|
|
$"{entry.Price:F2}," +
|
|
$"{entry.Timer:F2}," +
|
|
$"{entry.LatencyMs}," +
|
|
$"{entry.Success}," +
|
|
$"\"{entry.Notes}\"");
|
|
}
|
|
|
|
File.WriteAllText(filePath, csv.ToString(), Encoding.UTF8);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Esporta statistiche aggregate di un'asta in CSV
|
|
/// </summary>
|
|
public static void ExportAuctionStatistics(AuctionInfo auction, string filePath)
|
|
{
|
|
var stats = AuctionStatistics.Calculate(auction);
|
|
var csv = new StringBuilder();
|
|
|
|
// Informazioni asta
|
|
csv.AppendLine("=== AUCTION INFO ===");
|
|
csv.AppendLine($"Auction ID,{stats.AuctionId}");
|
|
csv.AppendLine($"Name,\"{stats.Name}\"");
|
|
csv.AppendLine($"Monitoring Started,{stats.MonitoringStarted:yyyy-MM-dd HH:mm:ss}");
|
|
csv.AppendLine($"Monitoring Duration,{stats.MonitoringDuration}");
|
|
csv.AppendLine();
|
|
|
|
// Contatori
|
|
csv.AppendLine("=== COUNTERS ===");
|
|
csv.AppendLine($"Total Bids,{stats.TotalBids}");
|
|
csv.AppendLine($"My Bids,{stats.MyBids}");
|
|
csv.AppendLine($"Opponent Bids,{stats.OpponentBids}");
|
|
csv.AppendLine($"Resets,{stats.Resets}");
|
|
csv.AppendLine($"Unique Bidders,{stats.UniqueBidders}");
|
|
csv.AppendLine();
|
|
|
|
// Prezzi
|
|
csv.AppendLine("=== PRICES ===");
|
|
csv.AppendLine($"Start Price,{stats.StartPrice:F2}");
|
|
csv.AppendLine($"Current Price,{stats.CurrentPrice:F2}");
|
|
csv.AppendLine($"Min Price,{stats.MinPrice:F2}");
|
|
csv.AppendLine($"Max Price,{stats.MaxPrice:F2}");
|
|
csv.AppendLine($"Avg Price,{stats.AvgPrice:F2}");
|
|
csv.AppendLine();
|
|
|
|
// Performance
|
|
csv.AppendLine("=== PERFORMANCE ===");
|
|
csv.AppendLine($"Avg Click Latency (ms),{stats.AvgClickLatencyMs}");
|
|
csv.AppendLine($"Min Click Latency (ms),{stats.MinClickLatencyMs}");
|
|
csv.AppendLine($"Max Click Latency (ms),{stats.MaxClickLatencyMs}");
|
|
csv.AppendLine($"Bids Per Minute,{stats.BidsPerMinute:F2}");
|
|
csv.AppendLine($"Resets Per Hour,{stats.ResetsPerHour:F2}");
|
|
csv.AppendLine($"My Bid Success Rate,{stats.MyBidSuccessRate:F1}%");
|
|
csv.AppendLine();
|
|
|
|
// Competitor ranking
|
|
csv.AppendLine("=== BIDDER RANKING ===");
|
|
csv.AppendLine("Bidder,Bids Count");
|
|
foreach (var bidder in stats.BidderRanking.OrderByDescending(b => b.Value))
|
|
{
|
|
csv.AppendLine($"\"{bidder.Key}\",{bidder.Value}");
|
|
}
|
|
|
|
File.WriteAllText(filePath, csv.ToString(), Encoding.UTF8);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Esporta tutte le aste in un unico CSV
|
|
/// </summary>
|
|
public static void ExportAllAuctions(IEnumerable<AuctionInfo> auctions, string filePath)
|
|
{
|
|
var csv = new StringBuilder();
|
|
|
|
// Header AGGIORNATO
|
|
csv.AppendLine("Auction ID,Name,Bid Before Deadline (ms),Check Before Bid,Min Price,Max Price,My Bids,Resets,Total Bidders,Active,Paused,Added At,Last Click At");
|
|
|
|
// Data
|
|
foreach (var auction in auctions)
|
|
{
|
|
var totalBidders = auction.BidderStats?.Count ?? 0;
|
|
var myBids = auction.BidHistory.Count(h => h.EventType == BidEventType.MyBid);
|
|
|
|
csv.AppendLine($"{auction.AuctionId}," +
|
|
$"\"{auction.Name}\"," +
|
|
$"{auction.BidBeforeDeadlineMs}," +
|
|
$"{auction.CheckAuctionOpenBeforeBid}," +
|
|
$"{auction.MinPrice:F2}," +
|
|
$"{auction.MaxPrice:F2}," +
|
|
$"{myBids}," +
|
|
$"{auction.ResetCount}," +
|
|
$"{totalBidders}," +
|
|
$"{auction.IsActive}," +
|
|
$"{auction.IsPaused}," +
|
|
$"{auction.AddedAt:yyyy-MM-dd HH:mm:ss}," +
|
|
$"{(auction.LastClickAt?.ToString("yyyy-MM-dd HH:mm:ss") ?? "")}");
|
|
}
|
|
|
|
File.WriteAllText(filePath, csv.ToString(), Encoding.UTF8);
|
|
}
|
|
}
|
|
}
|