using System;
using System.Collections.Generic;

namespace Haoliang.Models.System
{
    public class SystemConfig
    {
        public int Id { get; set; }
        public string ConfigKey { get; set; }
        public string ConfigValue { get; set; }
        public string Description { get; set; }
        public string Category { get; set; }
        public bool IsActive { get; set; }
        public bool IsDefault { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? UpdatedAt { get; set; }
    }

    public class ScheduledTask
    {
        public string TaskId { get; set; }
        public string TaskName { get; set; }
        public string CronExpression { get; set; }
        public string Description { get; set; }
        public TaskStatus TaskStatus { get; set; }
        public bool IsActive { get; set; }
        public DateTime? LastRunAt { get; set; }
        public DateTime? NextRunTime { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? CompletedAt { get; set; }
        public string ErrorMessage { get; set; }
    }

    public class TaskExecutionResult
    {
        public int ExecutionId { get; set; }
        public string TaskId { get; set; }
        public TaskStatus Status { get; set; }
        public DateTime ExecutionTime { get; set; }
        public TimeSpan? ExecutionDurationMs { get; set; }
        public string ErrorMessage { get; set; }
        public Dictionary<string, object> ResultData { get; set; }
    }

    public class TaskExecutionSummary
    {
        public DateTime Date { get; set; }
        public int TotalExecutions { get; set; }
        public int SuccessfulExecutions { get; set; }
        public int FailedExecutions { get; set; }
        public int RunningExecutions { get; set; }
        public Dictionary<string, TaskExecutionDetail> ExecutionDetails { get; set; }
    }

    public class TaskExecutionDetail
    {
        public string TaskName { get; set; }
        public int TotalExecutions { get; set; }
        public int SuccessfulExecutions { get; set; }
        public int FailedExecutions { get; set; }
        public double AverageExecutionTime { get; set; }
    }

    public class LogStatistics
    {
        public DateTime Date { get; set; }
        public int TotalLogs { get; set; }
        public int ErrorLogs { get; set; }
        public int WarningLogs { get; set; }
        public int InfoLogs { get; set; }
        public int DebugLogs { get; set; }
        public Dictionary<string, int> LogSources { get; set; }
    }

    public enum TaskStatus
    {
        Pending = 0,
        Running = 1,
        Completed = 2,
        Failed = 3,
        Disabled = 4
    }

    public enum AlarmPriority
    {
        Low = 1,
        Medium = 2,
        High = 3,
        Critical = 4
    }

    public class DeviceStatistics
    {
        public int DeviceId { get; set; }
        public string DeviceName { get; set; }
        public int TotalCollections { get; set; }
        public int SuccessfulCollections { get; set; }
        public int FailedCollections { get; set; }
        public double SuccessRate { get; set; }
        public TimeSpan AverageResponseTime { get; set; }
        public DateTime LastCollectionTime { get; set; }
    }

    public class CollectionTaskStatistics
    {
        public DateTime Date { get; set; }
        public int TotalTasks { get; set; }
        public int PendingTasks { get; set; }
        public int RunningTasks { get; set; }
        public int CompletedTasks { get; set; }
        public int FailedTasks { get; set; }
        public Dictionary<int, int> DeviceTasks { get; set; }
    }

    public class CollectionHealth
    {
        public DateTime CheckTime { get; set; }
        public int TotalDevices { get; set; }
        public int OnlineDevices { get; set; }
        public int ActiveCollectionTasks { get; set; }
        public int FailedTasks { get; set; }
        public decimal SuccessRate { get; set; }
        public TimeSpan AverageResponseTime { get; set; }
        public long TotalCollectedData { get; set; }
        public DateTime LastSuccessfulCollection { get; set; }
        public DateTime LastFailedCollection { get; set; }
    }

    public class CollectionStatistics
    {
        public DateTime Date { get; set; }
        public int TotalAttempts { get; set; }
        public int SuccessCount { get; set; }
        public int FailedCount { get; set; }
        public decimal SuccessRate { get; set; }
        public int DeviceCount { get; set; }
        public int OnlineDeviceCount { get; set; }
        public long TotalDataSize { get; set; }
        public TimeSpan? AverageResponseTime { get; set; }
    }

    public class AverageResponseTime
    {
        public int DeviceId { get; set; }
        public DateTime Date { get; set; }
        public TimeSpan AverageTime { get; set; }
        public int SampleCount { get; set; }
    }

    public class CollectionLogStatistics
    {
        public DateTime Date { get; set; }
        public int TotalLogs { get; set; }
        public int ErrorLogs { get; set; }
        public int WarningLogs { get; set; }
        public int InfoLogs { get; set; }
        public int DebugLogs { get; set; }
        public Dictionary<int, int> DeviceLogs { get; set; }
        public Dictionary<string, int> LogCategories { get; set; }
    }
}