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

namespace Haoliang.Models.DataCollection
{
    public class CollectionTask
    {
        public int TaskId { 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 CollectionResultBasic
    {
        public int ResultId { get; set; }
        public int TaskId { get; set; }
        public int DeviceId { get; set; }
        public bool IsSuccess { get; set; }
        public string RawData { get; set; }
        public string ParsedData { get; set; }
        public DateTime CollectionTime { get; set; }
        public int ResponseTimeMs { get; set; }
        public string ErrorMessage { get; set; }
        public Dictionary<string, object> Metadata { get; set; }
    }

    public class CollectionLogBasic
    {
        public int LogId { get; set; }
        public int DeviceId { get; set; }
        public LogLevel LogLevel { get; set; }
        public string Message { get; set; }
        public string Exception { get; set; }
        public DateTime Timestamp { get; set; }
        public string Category { get; set; }
    }

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

    public class DeviceCurrentStatusBasic
    {
        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 CollectionHealthBasic
    {
        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 CollectionStatisticsBasic
    {
        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; }
    }

// Duplicate definition removed - see DetailedCollectionStatistics in AdditionalCollectionModels.cs

    // Duplicate definition removed - see DetailedCollectionStatistics above

    public class DeviceStatisticsBasic
    {
        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 TagDataBasic
    {
        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 LogLevel
    {
        Debug = 0,
        Information = 1,
        Warning = 2,
        Error = 3,
        Critical = 4
    }

    public class DetailedCollectionStatisticsBasic
    {
        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 CollectionConfigBasic
    {
        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 DetailedCollectionHealth in AdditionalCollectionModels.cs

    // Duplicate definition removed - see CollectionFilter in AdditionalCollectionModels.cs
}