using System.Collections.Generic;

namespace NavisworksTransport.PathPlanning
{
    /// <summary>
    /// 自动路径规划验证结果
    /// </summary>
    public class AutoPathPlanningValidationResult
    {
        /// <summary>
        /// 是否验证通过
        /// </summary>
        public bool IsValid { get; set; }

        /// <summary>
        /// 验证消息
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 错误列表
        /// </summary>
        public List<string> Errors { get; set; }

        /// <summary>
        /// 警告列表
        /// </summary>
        public List<string> Warnings { get; set; }

        /// <summary>
        /// 预估计算时间（秒）
        /// </summary>
        public double EstimatedCalculationTime { get; set; }

        /// <summary>
        /// 预估内存使用（MB）
        /// </summary>
        public double EstimatedMemoryUsage { get; set; }

        /// <summary>
        /// 网格分辨率
        /// </summary>
        public double GridResolution { get; set; }

        /// <summary>
        /// 搜索区域大小（平方米）
        /// </summary>
        public double SearchAreaSize { get; set; }

        /// <summary>
        /// 性能建议
        /// </summary>
        public List<string> PerformanceSuggestions { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public AutoPathPlanningValidationResult()
        {
            IsValid = false;
            Message = "";
            Errors = new List<string>();
            Warnings = new List<string>();
            PerformanceSuggestions = new List<string>();
            EstimatedCalculationTime = 0;
            EstimatedMemoryUsage = 0;
            GridResolution = 0.0;
            SearchAreaSize = 0;
        }

        /// <summary>
        /// 添加错误信息
        /// </summary>
        public void AddError(string error)
        {
            Errors.Add(error);
            IsValid = false;
        }

        /// <summary>
        /// 添加警告信息
        /// </summary>
        public void AddWarning(string warning)
        {
            Warnings.Add(warning);
        }

        /// <summary>
        /// 添加性能建议
        /// </summary>
        public void AddPerformanceSuggestion(string suggestion)
        {
            PerformanceSuggestions.Add(suggestion);
        }

        /// <summary>
        /// 获取完整的验证摘要
        /// </summary>
        public string GetValidationSummary()
        {
            var summary = new System.Text.StringBuilder();
            
            summary.AppendLine($"验证结果: {(IsValid ? "通过" : "失败")}");
            
            if (!string.IsNullOrEmpty(Message))
            {
                summary.AppendLine($"消息: {Message}");
            }
            
            if (Errors.Count > 0)
            {
                summary.AppendLine($"错误 ({Errors.Count}):");
                foreach (var error in Errors)
                {
                    summary.AppendLine($"  - {error}");
                }
            }
            
            if (Warnings.Count > 0)
            {
                summary.AppendLine($"警告 ({Warnings.Count}):");
                foreach (var warning in Warnings)
                {
                    summary.AppendLine($"  - {warning}");
                }
            }
            
            if (PerformanceSuggestions.Count > 0)
            {
                summary.AppendLine($"性能建议 ({PerformanceSuggestions.Count}):");
                foreach (var suggestion in PerformanceSuggestions)
                {
                    summary.AppendLine($"  - {suggestion}");
                }
            }
            
            if (IsValid)
            {
                summary.AppendLine($"预估计算时间: {EstimatedCalculationTime:F1} 秒");
                summary.AppendLine($"预估内存使用: {EstimatedMemoryUsage:F1} MB");
                summary.AppendLine($"网格分辨率: {GridResolution:F2} 米");
                summary.AppendLine($"搜索区域: {SearchAreaSize:F0} 平方米");
            }
            
            return summary.ToString();
        }
    }
}