示例#1
0
 internal static List<LEDParaEntity> GetAllLEDParam()
 {
     List<LEDParaEntity> paramList = new List<LEDParaEntity>();
     DbConnection dbConnection = null;
     string strSQL = "select GPSCode,Height,Width,ColorType from gps_LEDSetting";
     try
     {
         DataTable table = new DataTable();
         dbConnection = GetConnection(EnumDBOperationType.GlobalDB);
         if (dbConnection == null)
             return paramList;
         if (dbConnection.State != ConnectionState.Open)
             dbConnection.Open();
         DbCommand command = dbConnection.CreateCommand();
         command.CommandText = strSQL;
         DbDataReader reader = command.ExecuteReader();
         table.Load(reader);
         reader.Close();
         foreach (DataRow row in table.Rows)
         {
             LEDParaEntity entity = new LEDParaEntity();
             entity.GPSCode = row["GPSCode"].ToString();
             entity.Height = TryParseUshort(row["Height"].ToString());
             entity.Width = TryParseUshort(row["Width"].ToString());
             entity.ColorType = row["ColorType"].ToString() == "1" ? LEDColorType.Homochromy : LEDColorType.DualColour;
             paramList.Add(entity);
         }
         table.Dispose();
         reader.Dispose();
         return paramList;
     }
     catch (Exception ex)
     {
         Loggers.LogInfo("GPSDataHelper.GetAllLEDParam:" + ex);
         return paramList;
     }
     finally
     {
         CloseDBConnection(dbConnection);
     }
 }
示例#2
0
        /// <summary>
        /// 获取LED参数设置
        /// </summary>
        /// <returns></returns>
        public List<LEDParaEntity> GetAllLEDParam()
        {
            List<LEDParaEntity> paramList = new List<LEDParaEntity>();
            DbConnection dbConnection = null;
            string strSQL = "select GPSCode,Height,Width,ColorType from gps_LEDSetting";

            try
            {
                using (dbConnection = GetConnection(_DefaultConnectionString))
                {
                    DataTable table = new DataTable();
                    DbCommand command = dbConnection.CreateCommand();
                    command.CommandText = strSQL;
                    DbDataReader reader = command.ExecuteReader();
                    table.Load(reader);
                    reader.Close();
                    foreach (DataRow row in table.Rows)
                    {
                        LEDParaEntity entity = new LEDParaEntity();
                        entity.GPSCode = row["GPSCode"].ToString();
                        entity.Height = TryParseUshort(row["Height"].ToString());
                        entity.Width = TryParseUshort(row["Width"].ToString());
                        entity.ColorType = row["ColorType"].ToString() == "1" ? LEDColorType.Homochromy : LEDColorType.DualColour;
                        paramList.Add(entity);
                    }
                    table.Dispose();
                    reader.Dispose();
                }
            }
            catch (Exception ex)
            {
                Logger.Warn("GetAllLEDParam:" + ex.Message);
            }
            return paramList;

        }