示例#1
0
 /// <summary>
 /// 删除VCU配置信息
 /// </summary>
 /// <param name="item"></param>
 public void DeleteVCUconfig(VCUconfig item)
 {
     try
     {
         string sql    = string.Format("delete from \"GAC_New_VCU\".\"T_VCUConfig\" where id = {0}", item.Id);
         int    result = PostgresHelper.ExecuteNonQuery(this.connectionString, CommandType.Text, sql);
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message + "***" + ex.StackTrace);
     }
 }
示例#2
0
 /// <summary>
 /// 修改VCU相关信息
 /// </summary>
 /// <param name="item"></param>
 public void UpdateVCUconfig(VCUconfig item)
 {
     try
     {
         string sql    = string.Format("Update \"GAC_New_VCU\".\"T_VCUConfig\"  set mtoc = '{0}' ,drivername= '{1}',driverpath= '{2}',binname= '{3}',binpath= '{4}',calname= '{5}',calpath= '{6}',softwareversion= '{7}',\"elementNum\"= '{8}',\"hardwarecode\"= '{9}' ,\"HW\"= '{10}',\"SW\"= '{11}' where id = {12};", item.MTOC, item.DriverName, item.DriverPath, item.BinName, item.BinPath, item.CalName, item.CalPath, item.SoftWareVersion, item.ElementNum, item.HardWareCode, item.HW, item.SW, item.Id);
         int    result = PostgresHelper.ExecuteNonQuery(this.connectionString, CommandType.Text, sql);
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message + "***" + ex.StackTrace);
     }
 }
示例#3
0
        /// <summary>
        /// 获取MTOC码和对应写入的bin文件
        /// </summary>
        /// <param name="element"></param>
        public async static Task <string> GetMTOC(string element, string vincode, VCUconfig config)
        {
            string msg = string.Empty;

            try
            {
                var mtocentity = await _sqlSugar.Queryable <T_MTOC>().Where(t => t.vin == vincode).FirstAsync();

                if (mtocentity != null)
                {
                    // 修改对应零件号以及写入状态为0(开始写入)
                    await _sqlSugar.Updateable(new T_MTOC { element = element, state = 0 }).UpdateColumns(t => new { t.element, t.state })
                    .Where(t => t.vin == mtocentity.vin).ExecuteCommandAsync();

                    Log.Info(vincode + "更新零件号" + element + "成功,对应mtoc码为:" + mtocentity.mtoc);

                    // 查找MTOC码对应的bin文件以及软、硬件版本号等信息
                    var configentity = await _sqlSugar.Queryable <T_VCUConfig>().Where(t => t.mtoc == mtocentity.mtoc).FirstAsync();

                    if (configentity != null)
                    {
                        config.DriverName      = configentity.drivername;
                        config.DriverPath      = configentity.driverpath;
                        config.BinName         = configentity.binname;
                        config.BinPath         = configentity.binpath;
                        config.CalName         = configentity.calname;
                        config.CalPath         = configentity.calpath;
                        config.SoftWareVersion = configentity.softwareversion;
                        config.HardWareCode    = configentity.hardwarecode;
                        config.SW         = configentity.SW;
                        config.HW         = configentity.HW;
                        config.ElementNum = configentity.elementNum;
                        Log.Info("下载MTOC码为" + mtocentity.mtoc + "对应相关信息成功!");
                    }
                    else
                    {
                        Log.Info("不存在MTOC码为" + mtocentity.mtoc + "对应的相关信息!");
                        msg = "不存在MTOC码为" + mtocentity.mtoc + "对应的相关信息!";
                    }
                }
                else
                {
                    Log.Info("不存在未写入的VCU");
                    msg = "不存在未写入的VCU";
                }
            }
            catch (Exception ex)
            {
                Log.Error($"查询记录失败!\r\n element={element},vincode={vincode},config={config}", ex);
                msg = "异常";
            }
            return(msg);
        }
示例#4
0
 /// <summary>
 /// 保存VCU相关信息
 /// </summary>
 /// <param name="item"></param>
 public void SaveVCUconfig(VCUconfig item)
 {
     try
     {
         string sql = string.Format("INSERT INTO  \"GAC_New_VCU\".\"T_VCUConfig\"(mtoc,drivername,driverpath,binname,binpath,calname,calpath,softwareversion,hardwarecode,\"elementNum\",\"HW\",\"SW\",\"sign\") VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}');",
                                    item.MTOC, item.DriverName, item.DriverPath, item.BinName, item.BinPath, item.CalName, item.CalPath, item.SoftWareVersion, item.HardWareCode, item.ElementNum, item.HW, item.SW, item.Sign);
         int result = PostgresHelper.ExecuteNonQuery(this.connectionString, CommandType.Text, sql);
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message + "***" + ex.StackTrace);
     }
 }
示例#5
0
        /// <summary>
        /// 查找重复VCU信息
        /// </summary>
        /// <param name="item"></param>
        public int RepeatVCUconfig(VCUconfig item)
        {
            int result = 0;

            try
            {
                string sql = string.Format("select count(*) from \"GAC_New_VCU\".\"T_VCUConfig\" where mtoc = '{0}' ", item.MTOC);
                result = Convert.ToInt32(PostgresHelper.ExecuteScalar(this.connectionString, CommandType.Text, sql));
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message + "***" + ex.StackTrace);
            }
            return(result);
        }
示例#6
0
        /// <summary>
        /// 获取MTOC码和对应写入的bin文件
        /// </summary>
        /// <param name="element"></param>
        public string GetMTOC(string element, string vincode, VCUconfig config)
        {
            OdbcConnection conn = PostgresHelper.GetOdbcConnection(this.connectionString);
            string         res  = string.Empty;

            try
            {
                this.vin = vincode;
                PostgresHelper.CheckConnection(conn);
                //先查找第一个写入状态为-1的件,插入零件号并获取MTOC码和id
                string mtoc   = string.Empty;
                int    result = -1;
                string sql    = string.Empty;
                sql = string.Format("select * from \"GAC_New_VCU\".\"T_MTOC\" where \"vin\"='" + vincode + "'");
                DataTable dtExist = PostgresHelper.ExecuteDataTable(conn, CommandType.Text, sql);
                if (dtExist.Rows.Count != 0)
                {
                    mtoc = dtExist.Rows[0]["mtoc"].ToString();
                    id   = int.Parse(dtExist.Rows[0]["id"].ToString());
                    vin  = dtExist.Rows[0]["vin"].ToString();
                    //修改对应零件号以及写入状态为0(开始写入)
                    sql    = string.Format("update \"GAC_New_VCU\".\"T_MTOC\" set \"element\"='" + element + "',\"state\"='0' where \"vin\"='" + vin + "'");
                    result = PostgresHelper.ExecuteNonQuery(conn, CommandType.Text, sql);
                    logger.Info(vin + "更新零件号" + element + "成功,对应mtoc码为:" + mtoc);
                    //查找MTOC码对应的bin文件以及软、硬件版本号等信息
                    sql = string.Format("select * from \"GAC_New_VCU\".\"T_VCUConfig\" where \"mtoc\"='" + mtoc + "' ");
                    DataTable Exist = PostgresHelper.ExecuteDataTable(conn, CommandType.Text, sql);
                    if (Exist.Rows.Count != 0)
                    {
                        config.DriverName      = Exist.Rows[0]["drivername"] + "";
                        config.DriverPath      = Exist.Rows[0]["driverpath"] + "";
                        config.BinName         = Exist.Rows[0]["binname"] + "";
                        config.BinPath         = Exist.Rows[0]["binpath"] + "";
                        config.CalName         = Exist.Rows[0]["calname"] + "";
                        config.CalPath         = Exist.Rows[0]["calpath"] + "";
                        config.SoftWareVersion = Exist.Rows[0]["softwareversion"] + "";
                        config.HardWareCode    = Exist.Rows[0]["hardwarecode"] + "";
                        config.SW         = Exist.Rows[0]["SW"] + "";
                        config.HW         = Exist.Rows[0]["HW"] + "";
                        config.ElementNum = Exist.Rows[0]["elementNum"] + "";
                        logger.Info("下载MTOC码为" + mtoc + "对应相关信息成功!");
                    }
                    else
                    {
                        logger.Info("不存在MTOC码为" + mtoc + "对应的相关信息!");
                        res = "不存在MTOC码为" + mtoc + "对应的相关信息!";
                    }
                }
                else
                {
                    logger.Info("不存在未写入的VCU");
                    res = "不存在未写入的VCU";
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                res = ex.Message;
            }
            finally
            {
                PostgresHelper.CheckCloseConneciton(conn);
            }
            return(res);
        }