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
103 lines
3.6 KiB
C#
103 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq.Expressions;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DataConnection.Interfaces;
|
|
|
|
/// <summary>
|
|
/// Interfaccia per la gestione di database preesistenti tramite EF Core
|
|
/// </summary>
|
|
public interface IDatabaseManager : IDisposable
|
|
{
|
|
/// <summary>
|
|
/// Verifica la connessione al database
|
|
/// </summary>
|
|
Task<bool> TestConnectionAsync();
|
|
|
|
/// <summary>
|
|
/// Ottiene entità dal database in base ai criteri specificati
|
|
/// </summary>
|
|
/// <typeparam name="T">Tipo di entità</typeparam>
|
|
/// <param name="filter">Espressione di filtro</param>
|
|
/// <param name="orderBy">Espressione di ordinamento</param>
|
|
/// <param name="includeProperties">Proprietà di navigazione da includere</param>
|
|
/// <param name="skip">Numero di elementi da saltare</param>
|
|
/// <param name="take">Numero di elementi da prendere</param>
|
|
Task<IEnumerable<T>> GetAsync<T>(
|
|
Expression<Func<T, bool>>? filter = null,
|
|
Func<IQueryable<T>, IOrderedQueryable<T>>? orderBy = null,
|
|
string includeProperties = "",
|
|
int? skip = null,
|
|
int? take = null) where T : class;
|
|
|
|
/// <summary>
|
|
/// Ottiene un'entità singola in base alla chiave primaria
|
|
/// </summary>
|
|
Task<T?> GetByIdAsync<T>(object id) where T : class;
|
|
|
|
/// <summary>
|
|
/// Esegue una query SQL raw
|
|
/// </summary>
|
|
Task<IEnumerable<T>> ExecuteQueryAsync<T>(string sql, params object[] parameters) where T : class;
|
|
|
|
/// <summary>
|
|
/// Esegue una query SQL raw e restituisce i risultati come dictionary
|
|
/// </summary>
|
|
Task<List<Dictionary<string, object>>> ExecuteRawQueryAsync(string sql, string databaseName = "", params object[] parameters);
|
|
|
|
/// <summary>
|
|
/// Esegue un comando SQL che non restituisce risultati
|
|
/// </summary>
|
|
Task<int> ExecuteCommandAsync(string sql, params object[] parameters);
|
|
|
|
/// <summary>
|
|
/// Ottiene l'elenco dei database disponibili sul server
|
|
/// </summary>
|
|
Task<List<string>> GetAvailableDatabasesAsync();
|
|
|
|
/// <summary>
|
|
/// Cambia il database corrente per la connessione
|
|
/// </summary>
|
|
Task ChangeDatabaseAsync(string databaseName);
|
|
/// <summary>
|
|
/// Ottiene i metadati delle tabelle nel database
|
|
/// </summary>
|
|
Task<IDictionary<string, IEnumerable<DbColumnInfo>>> GetDatabaseSchemaAsync();
|
|
|
|
/// <summary>
|
|
/// Ottiene solo la lista dei nomi delle tabelle disponibili (senza dettagli delle colonne)
|
|
/// </summary>
|
|
Task<IEnumerable<string>> GetTableNamesAsync();
|
|
|
|
/// <summary>
|
|
/// Ottiene i dettagli delle colonne per una specifica tabella
|
|
/// </summary>
|
|
/// <param name="tableName">Nome della tabella (con schema se necessario)</param>
|
|
Task<IEnumerable<DbColumnInfo>> GetTableSchemaAsync(string tableName);
|
|
|
|
/// <summary>
|
|
/// Ottiene tutti i record da una tabella specifica come dizionari chiave-valore
|
|
/// </summary>
|
|
Task<IEnumerable<Dictionary<string, object>>> GetAllRecordsAsync(string tableName);
|
|
|
|
/// <summary>
|
|
/// Ottiene il nome del campo Primary Key di una tabella specifica
|
|
/// </summary>
|
|
Task<string?> GetPrimaryKeyFieldAsync(string tableName);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Informazioni su una colonna del database
|
|
/// </summary>
|
|
public class DbColumnInfo
|
|
{
|
|
public string Name { get; set; } = string.Empty;
|
|
public string DataType { get; set; } = string.Empty;
|
|
public bool IsNullable { get; set; }
|
|
public bool IsPrimaryKey { get; set; }
|
|
public bool IsForeignKey { get; set; }
|
|
public string? ReferencedTable { get; set; }
|
|
public string? ReferencedColumn { get; set; }
|
|
}
|