namespace Haoliang.Models.System
{
    public enum LogLevel
    {
        Trace = 0,
        Debug = 1,
        Information = 2,
        Warning = 3,
        Error = 4,
        Critical = 5,
        None = 6
    }

    public enum AlarmType
    {
        DeviceOffline = 1,
        DeviceError = 2,
        ProductionError = 3,
        SystemError = 4,
        NetworkError = 5,
        Maintenance = 6
    }

    public enum AlarmStatus
    {
        Active = 1,
        Acknowledged = 2,
        Resolved = 3,
        Suppressed = 4
    }

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

    public enum NotificationType
    {
        Email = 1,
        SMS = 2,
        WeChat = 3,
        System = 4
    }

    public enum NotificationStatus
    {
        Pending = 1,
        Sent = 2,
        Failed = 3,
        Delivered = 4
    }

    public class AlarmDetailed
    {
        public int AlarmId { get; set; }
        public int DeviceId { get; set; }
        public string DeviceCode { get; set; }
        public AlarmType AlarmType { get; set; }
        public AlarmSeverity Severity { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public AlarmStatus AlarmStatus { get; set; }
        public DateTime CreateTime { get; set; }
        public DateTime? AcknowledgedTime { get; set; }
        public DateTime? ResolvedTime { get; set; }
        public string AcknowledgeNote { get; set; }
        public string ResolutionNote { get; set; }
        public bool IsActive => AlarmStatus == AlarmStatus.Active;
    }

    public class AlarmRuleDetailed
    {
        public int RuleId { get; set; }
        public string RuleName { get; set; }
        public int DeviceId { get; set; }
        public AlarmType AlarmType { get; set; }
        public string Condition { get; set; }
        public string Threshold { get; set; }
        public bool IsActive { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime? UpdatedAt { get; set; }
    }

    public class AlarmNotificationDetailed
    {
        public int NotificationId { get; set; }
        public int AlarmId { get; set; }
        public NotificationType NotificationType { get; set; }
        public string Recipient { get; set; }
        public string Message { get; set; }
        public NotificationStatus Status { get; set; }
        public DateTime SendTime { get; set; }
        public string ErrorMessage { get; set; }
        public DateTime? RetryTime { get; set; }
    }

    public class AlarmStatisticsDetailed
    {
        public int TotalAlarms { get; set; }
        public int ActiveAlarms { get; set; }
        public int CriticalAlarms { get; set; }
        public int ResolvedAlarms { get; set; }
        public Dictionary<AlarmType, int> AlarmsByType { get; set; }
        public Dictionary<AlarmSeverity, int> AlarmsBySeverity { get; set; }
    }

    public class LogEntryDetailed
    {
        public int LogId { get; set; }
        public LogLevel LogLevel { get; set; }
        public string Category { get; set; }
        public string Message { get; set; }
        public string ExceptionMessage { get; set; }
        public string StackTrace { get; set; }
        public Dictionary<string, object> Properties { get; set; }
        public DateTime Timestamp { get; set; }
    }
}