using System;
using System.Collections.Generic;
using Haoliang.Models.Device;

namespace Haoliang.Models.DataCollection
{
public class CollectionTaskDetailed
    {
        public int Id { get; set; }
        public int DeviceId { get; set; }
        public string TaskName { get; set; }
        public string Status { get; set; } // Pending, Running, Completed, Failed
        public DateTime ScheduledTime { get; set; }
        public DateTime? StartTime { get; set; }
        public DateTime? EndTime { get; set; }
        public bool IsSuccess { get; set; }
        public string ErrorMessage { get; set; }
        public int RetryCount { get; set; }
        public DateTime CreatedAt { get; set; }
    }

    public class CollectionResultDetailed
    {
        public int Id { get; set; }
        public int DeviceId { get; set; }
        public bool IsSuccess { get; set; }
        public string RawJson { get; set; }
        public string ParsedData { get; set; }
        public DateTime CollectionTime { get; set; }
        public long? ResponseTime { get; set; }
        public int? DataSize { get; set; }
        public string ErrorMessage { get; set; }
        public DateTime CreatedAt { get; set; }
    }

    public class CollectionLogDetailed
    {
        public int Id { get; set; }
        public int DeviceId { get; set; }
        public LogLevel LogLevel { get; set; }
        public string LogCategory { get; set; }
        public string LogMessage { get; set; }
        public string LogData { get; set; }
        public DateTime LogTime { get; set; }
        public DateTime CreatedAt { get; set; }
    }

    public class PingResultDetailed
    {
        public bool IsSuccess { get; set; }
        public int PingTimeMs { get; set; }
        public string ErrorMessage { get; set; }
        public DateTime Timestamp { get; set; }
    }

    public class DeviceCurrentStatusDetailed
    {
        public int DeviceId { get; set; }
        public string DeviceCode { get; set; }
        public DeviceStatus Status { get; set; }
        public string NCProgram { get; set; }
        public int CumulativeCount { get; set; }
        public DateTime RecordTime { get; set; }
        public bool IsActive => Status == DeviceStatus.Online;
    }

    public class CollectionHealthDetailed
    {
        public int TotalDevices { get; set; }
        public int OnlineDevices { get; set; }
        public int ActiveCollections { get; set; }
        public double AverageResponseTime { get; set; }
        public double SuccessRate { get; set; }
        public Dictionary<string, int> StatusCounts { get; set; }
    }

    public class CollectionStatisticsDetailed
    {
        public DateTime Date { get; set; }
        public int TotalCollections { get; set; }
        public int SuccessfulCollections { get; set; }
        public int FailedCollections { get; set; }
        public double AverageResponseTime { get; set; }
        public Dictionary<string, int> ErrorCounts { get; set; }
    }

    public class CollectionConfigDetailed
    {
        public int Id { get; set; }
        public string ConfigKey { get; set; }
        public string ConfigValue { get; set; }
        public string Description { get; set; }
        public bool IsEnabled { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime UpdatedAt { get; set; }
    }

    public class CollectionFilterDetailed
    {
        public List<int> DeviceIds { get; set; }
        public DateTime? StartDate { get; set; }
        public DateTime? EndDate { get; set; }
        public bool? IsSuccess { get; set; }
        public string Status { get; set; }
        public int? RetryCount { get; set; }
        public string SearchKeyword { get; set; }
    }

    public class CollectionResult
    {
        public int Id { get; set; }
        public int DeviceId { get; set; }
        public bool IsSuccess { get; set; }
        public string RawJson { get; set; }
        public string ParsedData { get; set; }
        public DateTime CollectionTime { get; set; }
        public long? ResponseTime { get; set; }
        public int? DataSize { get; set; }
        public string ErrorMessage { get; set; }
        public DateTime CreatedAt { get; set; }
    }

    public class CollectionLog
    {
        public int Id { get; set; }
        public int DeviceId { get; set; }
        public LogLevel LogLevel { get; set; }
        public string LogCategory { get; set; }
        public string LogMessage { get; set; }
        public string LogData { get; set; }
        public DateTime LogTime { get; set; }
        public DateTime CreatedAt { get; set; }
    }

    public class PingResult
    {
        public bool IsSuccess { get; set; }
        public int PingTimeMs { get; set; }
        public string ErrorMessage { get; set; }
        public DateTime Timestamp { get; set; }
    }

    public class DeviceCurrentStatus
    {
        public int DeviceId { get; set; }
        public string DeviceCode { get; set; }
        public DeviceStatus Status { get; set; }
        public string NCProgram { get; set; }
        public int CumulativeCount { get; set; }
        public DateTime RecordTime { get; set; }
        public bool IsActive => Status == DeviceStatus.Online;
    }

// Duplicate definition removed - see CollectionHealthDetailed below

    public class DetailedCollectionHealth
    {
        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 double SuccessRate { get; set; }
        public double AverageResponseTime { get; set; }
        public long TotalCollectedData { get; set; }
        public DateTime LastSuccessfulCollection { get; set; }
        public DateTime LastFailedCollection { get; set; }
    }

// Duplicate definition removed - see CollectionStatisticsDetailed below

    public class DetailedCollectionStatistics
    {
        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 TimeSpan AverageResponseTime { get; set; }
        public int DeviceCount { get; set; }
        public int OnlineDeviceCount { get; set; }
        public long TotalDataSize { get; set; }
    }

    public class DeviceStatistics
    {
        public int DeviceId { get; set; }
        public string DeviceCode { get; set; }
        public int TotalRunTime { get; set; }
        public int TotalProductionCount { get; set; }
        public double EfficiencyRate { get; set; }
        public DateTime LastActiveTime { get; set; }
        public Dictionary<string, int> ProgramCounts { get; set; }
    }

    public class TagData
    {
        public string Id { get; set; }
        public string Description { get; set; }
        public int Quality { get; set; }
        public object Value { get; set; }
        public DateTime Time { get; set; }
    }

    public enum DataCollectionLogLevel
    {
        Debug = 0,
        Information = 1,
        Warning = 2,
        Error = 3,
        Critical = 4
    }

// Duplicate definition removed - see DetailedCollectionStatistics above

    // Duplicate definition removed - see CollectionFilterDetailed below

public class CollectionConfig
    {
        public int Id { get; set; }
        public string ConfigKey { get; set; }
        public string ConfigValue { get; set; }
        public string Description { get; set; }
        public bool IsEnabled { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime UpdatedAt { get; set; }
    }

    // Duplicate definition removed - see CollectionFilterDetailed in CollectionModels.cs

    // Duplicate definition removed - see CollectionFilterDetailed above

    // Duplicate definition removed - see CollectionHealthDetailed above

    // Duplicate definition removed - see CollectionFilterDetailed in CollectionModels.cs
}