using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MeterVision.db
{
    public class VPatch
    {
        public string PatchId { get; set; }        // PATCH_ID
        public string CreateTime { get; set; }     // CREATE_TIME
        public string PatchName { get; set; }      // PATCH_NAME
        public string StandId { get; set; }
        public string StandName { get; set; }
        public int DetailCount { get; set; }        // 总的 patch_detail 条目数
        public int RunCount { get; set; }        // 计算 run_flag = 1 的条目数

        public int EqualCount { get; set; }

        public int InvalidCount { get; set; }       //无效识别数量
        public int ErrorCount { get; set; }         //错误识别数量

        public VPatch()
        {
            PatchId = string.Empty;
            CreateTime = string.Empty;
            PatchName = string.Empty;
            StandId = string.Empty;
            StandName = string.Empty;
            DetailCount = 0;
            RunCount = 0;
            EqualCount = 0;
            InvalidCount = 0;
            ErrorCount = 0;
        }

        public string PatchNameAndTime
        {
            //get => PatchName + " - " + ThisApp.ConvertDateFormat(CreateTime);
            get => ThisApp.ConvertDateFormat(CreateTime) + " - " + PatchName;
        }

        // 重写 ToString 方法，方便输出
        public override string ToString()
        {
            return $"{PatchId}, {PatchName}, {CreateTime:yyyy-MM-dd HH:mm:ss}, " +
                   $"Total Count: {DetailCount}, Check Count: {RunCount}";
        }


        public string TimeName
        {
            get => ThisApp.ConvertDateFormat(CreateTime);
        }

        public string PatchName2
        {
            get => $"{PatchName}\n{ThisApp.ConvertDateFormat(CreateTime)}\n模板:{StandName}";
        }

        public string EqualRate
        {
            get
            {
                float equalRate = (float)EqualCount*100 / DetailCount;
                string sEquealRate = equalRate.ToString("F1");

                sEquealRate = $"{EqualCount}/{DetailCount}\n{sEquealRate}%";
                return sEquealRate;
            }
        }

    }
}
