Example #1
0
        internal static List<GPSRelation> GetAllGPSCodeAndVehicleCode()
        {

            DbConnection dbConnection = null;
            string strSQL = "select gpscode,vehiclecode from gps_installation_info where abolish=0";
            List<GPSRelation> relationList = new List<GPSRelation>();
            try
            {
                DataTable table = new DataTable();
                dbConnection = GetConnection(EnumDBOperationType.GlobalDB);
                if (dbConnection == null)
                    return relationList;
                if (dbConnection.State != ConnectionState.Open)
                    dbConnection.Open();
                DbCommand command = dbConnection.CreateCommand();
                command.CommandText = strSQL;
                DbDataAdapter adapter = new MySqlDataAdapter();
                adapter.SelectCommand = command;

                DataSet dataSet = new DataSet();
                adapter.Fill(dataSet, "installation_info");

                foreach (DataRow row in dataSet.Tables["installation_info"].Rows)
                {
                    GPSRelation entity = new GPSRelation();
                    entity.GPSCode = row["gpscode"].ToString();
                    entity.VehicleCode = TryParseGuid(row["vehiclecode"].ToString());
                    entity.IsMovoVehicle = false;
                    relationList.Add(entity);
                }
                dataSet.Dispose();
                adapter.Dispose();


                command = dbConnection.CreateCommand();
                command.CommandText = "select gpscode,vehiclecode from movo_vehicle";
                adapter = new MySqlDataAdapter();
                adapter.SelectCommand = command;
                dataSet = new DataSet();
                adapter.Fill(dataSet, "move_vehicle");

                foreach (DataRow row in dataSet.Tables["move_vehicle"].Rows)
                {
                    GPSRelation entity = new GPSRelation();
                    entity.GPSCode = row["gpscode"].ToString();
                    entity.VehicleCode = TryParseGuid(row["vehiclecode"].ToString());
                    entity.IsMovoVehicle = true;
                    relationList.Add(entity);
                }
                dataSet.Dispose();
                adapter.Dispose();
                return relationList;
            }
            catch (Exception ex)
            {
                Loggers.LogInfo("GPSDataHelper.GetAllGPSCodeAndVehicleCode:" + ex);
                return relationList;
            }
            finally
            {
                CloseDBConnection(dbConnection);
            }
        }
Example #2
0
 /// <summary>
 /// 刷新单个GPS实时位置数据到缓存。
 /// </summary>
 /// <param name="entity"></param>
 public static void RefreshGPSRelation(GPSRelation entity)
 {
     try
     {
         List<GPSRelation> entityList = new List<GPSRelation>();
         entityList.Add(entity);
         RefreshGPSRelation(entityList);
         entityList = null;
         entity = null;
     }
     catch (Exception ex)
     {
         Loggers.LogInfo("PES.GPS.GPSStorage.CacheUtility.RefreshGPSDynamicData(single):" + ex);
     }
 }