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

namespace MeterVision.model
{
    public class PatchFindModel
    {
        public PatchFindType PatchFindType { get; set; }
        public int PageNumber { get; set; }

        public int PageSize { get; set; }

        public string PatchId { get; set; }

        public string StationId { get; set; }

        //以上三个为必要条件
        //以下为相应Flag=1时，才作为SQL语句的条件

        //RunFlag >=0 时，作为where条件
        public int RunFlag { get; set; }

        //EqualFlag >=0 时，作为where 条件
        public int EqualFlag { get; set; }

        ////StandValueFlag>=0时，stand_value='',
        //public int StandValueFlag { get; set; }

        public PatchFindModel(int pageNumber,int pageSize, string patchId, string stationId, PatchFindType patchFindType)
        {
            PatchFindType = patchFindType;
            PageNumber = pageNumber;
            PageSize = pageSize;
            PatchId = patchId;
            //if(stationId)
            StationId = stationId;

            if(patchFindType == PatchFindType.ALL)
            {
                RunFlag = -1;
                EqualFlag = -1;
            }
            else if(patchFindType == PatchFindType.RUN_YES)
            {
                RunFlag = 1;
                EqualFlag = -1;
            }
            else if(patchFindType == PatchFindType.RUN_NO)
            {
                RunFlag = 0;
                EqualFlag = -1;
            }
            else if(patchFindType == PatchFindType.RESULT_OK)
            {
                RunFlag = 1;
                EqualFlag = 1;
            }
            else if(patchFindType == PatchFindType.RESULT_ERROR)
            {
                RunFlag = 1;
                EqualFlag = 0;
            }
            else if(patchFindType == PatchFindType.RESULT_INVLIAD)
            {
                RunFlag = 1;
                EqualFlag = 2;
            }
            else if(patchFindType == PatchFindType.ALL_NO_STAND_VALUE)
            {
                RunFlag = -1;
                EqualFlag = 3;
            }
            else if (patchFindType == PatchFindType.RUN_YES_NO_STAND_VALUE)
            {
                RunFlag = 1;
                EqualFlag = 3;
            }
            else if (patchFindType == PatchFindType.RUN_NO_NO_STAND_VALUE)
            {
                RunFlag = 0;
                EqualFlag = 3;
            }
            else if (patchFindType == PatchFindType.HAVE_MEMO)
            {
                RunFlag = -1;
                EqualFlag = -1;
            }
        }
    //-----------------------------------------------------
    }
}
