using Sugar.Enties;
using System;
using System.Collections.Generic;
using System.Text;


public class fdc_pm_CarInOrOutManager : DbContext<fdc_pm_CarInOrOut>
{
    private NLog.Logger logger;

    public fdc_pm_CarInOrOutManager()
    {
        logger = NLog.LogManager.GetCurrentClassLogger();
    }

    /// <summary>
    /// 添加推送信息
    /// </summary>
    /// <param name="dto">需要插入的数据</param>
    /// <returns></returns>
    public string InsertAlarmInfoPlateLog(string request_msg)
    {
        Db.BeginTran();
        try
        {

            string sql = $"insert into AlarmInfoPlateLog values ('{request_msg}',getdate())";
            var row = Db.Ado.ExecuteCommand(sql);
            if (row <= 0)
            {
                Db.RollbackTran();
                return "保存AlarmInfoPlateLog失败";
            }


            Db.CommitTran();
            return "success";
        }
        catch (Exception ex)
        {
            Db.RollbackTran();
            //logger.Error(ex);
            throw;
        }
    }
    /// <summary>
    /// 摄像设备是否是进口
    /// </summary>
    /// <param name="serialno"></param>
    /// <returns></returns>
    public dynamic Getfdc_pm_cameradevicestatus(string serialno)
    {

        string sql = $" SELECT autoid  FROM fdc_pm_cameradevice where status='0' and cdserialno='{serialno}'";


        var model = Db.SqlQueryable<dynamic>(sql).First();
        return model;
    }

    /// <summary>
    /// 车辆是否属于白名单
    /// </summary>
    /// <param name="vcarcode"></param>
    /// <returns></returns>
    public dynamic Getfdc_pm_vehicleWhiteListByvcarcode(string vcarcode)
    {

        string sql = $" SELECT vehicleid FROM fdc_pm_vehicle WHERE vcarcode='{vcarcode}' and  iswhitelist=1";


        var model = Db.SqlQueryable<dynamic>(sql).First();
        return model;
    }


}

