using FLY.OBJComponents.Common;
using FLY.OBJComponents.IService;
using FLY.OBJComponents.Server.Model;
using FObjBase;
using SQLite;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLY.OBJComponents.Server
{
    public class BufferError : BulkDbSQLite<FlyData_WarningHistory, Db_Error> 
    {
        public void Init(DBTable<Db_Error> dbTable)
        {
            base.Init(dbTable, mapLc2Db, mapDb2Lc);
        }
        static Db_Error mapLc2Db(FlyData_WarningHistory lc) 
        {
            return new Db_Error()
            {
                ID = lc.ID,
                Time = lc.Time,
                ErrCode = lc.ErrCode,
                Descrption = lc.Description,
                IsOn = lc.State == ERR_STATE.ON
            };
        }
        static FlyData_WarningHistory mapDb2Lc(Db_Error db)
        {
            return new FlyData_WarningHistory()
            {
                ID = db.ID,
                Time = db.Time,
                ErrCode = db.ErrCode,
                Description = db.Descrption,
                State = db.IsOn? ERR_STATE.ON: ERR_STATE.OFF
            };
        }
    }
}
