d042863a56
- Aggiunto supporto schedulazione con intervalli flessibili (secondi/minuti/ore/giorni/settimane/mesi) - Esteso modello ProfileSchedule con campi IntervalValue e IntervalUnit - Ottimizzato ScheduledJobService per controlli ogni 30s con esecuzione parallela - Implementata interfaccia UI completa con anteprima real-time in italiano - Aggiunta migrazione database AddIntervalSchedulingFields - Implementati metodi calcolo NextExecutionTime per intervalli - Aggiunta gestione tracking anti-duplicati e cleanup automatico - Creata documentazione completa (6 file, 2500+ righe) Modifiche tecniche: - ProfileSchedule.cs: Nuovi campi e metodi CalculateNextInterval/GetScheduleDescription - ScheduledJobService.cs: Ridotto check interval a 30s, aggiunto parallel processing - ProfileScheduleService.cs: Supporto calcolo intervalli in UpdateNextExecutionTimeAsync - Scheduling.razor: Aggiunta sezione UI per configurazione intervalli - Scheduling.razor.cs: Implementato GetIntervalPreview() e gestione stato campi
101 lines
2.8 KiB
C#
101 lines
2.8 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace CredentialManager.Models;
|
|
|
|
/// <summary>
|
|
/// Modello per lo storico delle esecuzioni delle schedulazioni
|
|
/// </summary>
|
|
public class ScheduleExecutionHistory
|
|
{
|
|
[Key]
|
|
public int Id { get; set; }
|
|
|
|
// Relazione con la schedulazione
|
|
[Required]
|
|
public int ScheduleId { get; set; }
|
|
|
|
[ForeignKey(nameof(ScheduleId))]
|
|
public virtual ProfileSchedule Schedule { get; set; } = null!;
|
|
|
|
// Relazione con il profilo (denormalizzato per storico)
|
|
[Required]
|
|
public int ProfileId { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(200)]
|
|
public string ProfileName { get; set; } = string.Empty;
|
|
|
|
// Informazioni dell'esecuzione
|
|
[Required]
|
|
public DateTime StartTime { get; set; }
|
|
|
|
public DateTime? EndTime { get; set; }
|
|
|
|
public TimeSpan? Duration => EndTime - StartTime;
|
|
|
|
[Required]
|
|
[MaxLength(20)]
|
|
public string Status { get; set; } = string.Empty; // "success", "failed", "running", "cancelled"
|
|
|
|
[MaxLength(2000)]
|
|
public string? Message { get; set; }
|
|
|
|
public int RecordsProcessed { get; set; } = 0;
|
|
|
|
public int? RecordsWithErrors { get; set; }
|
|
|
|
// Dettagli dell'errore se presente
|
|
[MaxLength(5000)]
|
|
public string? ErrorDetails { get; set; }
|
|
|
|
// Informazioni sul trigger
|
|
[Required]
|
|
[MaxLength(20)]
|
|
public string TriggerType { get; set; } = string.Empty; // "manual", "automatic"
|
|
|
|
[MaxLength(100)]
|
|
public string? TriggeredBy { get; set; }
|
|
|
|
// Configurazioni al momento dell'esecuzione (per storico)
|
|
[MaxLength(50)]
|
|
public string? SourceType { get; set; }
|
|
|
|
[MaxLength(50)]
|
|
public string? DestinationType { get; set; }
|
|
|
|
[MaxLength(500)]
|
|
public string? SourceInfo { get; set; } // Informazioni aggiuntive sulla sorgente utilizzata
|
|
|
|
[MaxLength(500)]
|
|
public string? DestinationInfo { get; set; } // Informazioni aggiuntive sulla destinazione utilizzata
|
|
|
|
// Metadati
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
[MaxLength(2000)]
|
|
public string? AdditionalInfo { get; set; } // JSON per informazioni aggiuntive
|
|
|
|
// Helper methods
|
|
public bool IsCompleted => Status == "success" || Status == "failed" || Status == "cancelled";
|
|
|
|
public bool IsSuccessful => Status == "success";
|
|
|
|
public string GetStatusDisplayText() => Status switch
|
|
{
|
|
"success" => "Completato con successo",
|
|
"failed" => "Fallito",
|
|
"running" => "In esecuzione",
|
|
"cancelled" => "Cancellato",
|
|
_ => "Sconosciuto"
|
|
};
|
|
|
|
public string GetStatusColorClass() => Status switch
|
|
{
|
|
"success" => "text-success",
|
|
"failed" => "text-danger",
|
|
"running" => "text-primary",
|
|
"cancelled" => "text-warning",
|
|
_ => "text-muted"
|
|
};
|
|
} |