Beispiel #1
0
        /// <summary>
        /// 获取GPS车辆存放数据数据的配置关系信息
        /// </summary>
        internal static List<HistoryStoreConfig> GetHistoryTableRelation(string vehicleCode)
        {
            DbConnection dbConnection = null;

            List<HistoryStoreConfig> configList = new List<HistoryStoreConfig>();
            string strSQL = @"select vehiclecode,t2.tableName,selectConnStr,addConnStr,t2.ReserverColumn from gps_historydatastoreconfig t1,";
            if (!string.IsNullOrEmpty(vehicleCode))
            {
                strSQL += "gps_historydatastoretables t2 where t1.storeTable=t2.recordID and t1.enable=1 and vehiclecode='" + vehicleCode + "'";
            }
            else
            {
                //string vehicleConditon = string.Join(",", GetAllVehicleCode().ToArray());
                strSQL += "gps_historydatastoretables t2 where t1.storeTable=t2.recordID and t1.enable=1";
            }

            try
            {
                dbConnection = GetConnection(EnumDBOperationType.GlobalDB);
                if (dbConnection == null)
                    return configList;
                if (dbConnection.State != ConnectionState.Open)
                    dbConnection.Open();
                Dictionary<string, string> GpsVehicleDict = GetAllVehicleAndGpsDict();
                DataTable table = new DataTable();
                DbCommand command = dbConnection.CreateCommand();
                command.CommandText = strSQL;
                DbDataAdapter adapter = new MySql.Data.MySqlClient.MySqlDataAdapter();
                adapter.SelectCommand = command;
                DataSet ds = new DataSet();
                adapter.Fill(ds);

                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    if (GpsVehicleDict.ContainsKey(row["vehiclecode"].ToString()))
                    {
                        HistoryStoreConfig entity = new HistoryStoreConfig();
                        entity.VehicleCode = row["vehiclecode"].ToString();
                        entity.GPSCode = GpsVehicleDict[entity.VehicleCode];
                        entity.TableName = row["tableName"].ToString();
                        entity.SelectConnStr = row["selectConnStr"].ToString();
                        entity.AddConStr = row["addConnStr"].ToString();
                        entity.ReserverColumn = TryParseUshort(row["ReserverColumn"].ToString());
                        configList.Add(entity);
                    }
                }
                ds.Dispose();
                adapter.Dispose();
                Logger.Warn("获取车辆存放表配置关系" + configList.Count + "条");
                return configList;
            }
            catch (Exception ex)
            {
                Logger.Warn("GPSDataHelper.GetHistoryTableRelation:" + strSQL);
                Logger.Warn("GPSDataHelper.GetHistoryTableRelation:" + ex.ToString());
                return configList;
            }
            finally
            {
                CloseDBConnection(dbConnection);
            }

        }
Beispiel #2
0
 /// <summary>
 /// 根据KEY从缓存中获取历史数据存储表配置
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static HistoryStoreConfig GetGPSHistoryStoreTable(string vehicleCode)
 {
     HistoryStoreConfig config = new HistoryStoreConfig();
     try
     {
         string key = string.Format("{0}{1}", HistoryPrefiexCacheKey, vehicleCode);
         object obj = CacheUtility.GetDataByKeyFromCache(key);
         if (null != obj)
         {
             config = obj as HistoryStoreConfig;
         }
         else
         {
             //config = GPSDataHelper2.GetSingleHistoryTableRelation(vehicleCode);
             //if (null != config)
             //{
             //    RefreshGPSHistoryStoreTable(config);
             //}
             //else
             //{
             //    return null;
             //}
         }
         return config;
     }
     catch (Exception ex)
     {
         Loggers.LogInfo("PES.GPS.GPSStorage.GPSDataHelper.GetVehicleHistoryStoreTableConfig:" + ex);
         return config;
     }
 }
Beispiel #3
0
 /// <summary>
 /// 刷新单个历史数据存储表配置到缓存。
 /// </summary>
 /// <param name="entity"></param>
 public static void RefreshGPSHistoryStoreTable(HistoryStoreConfig entity)
 {
     try
     {
         List<HistoryStoreConfig> entityList = new List<HistoryStoreConfig>();
         entityList.Add(entity);
         //MCacheSetThread.PushItem(entityList);
         //ProcessItem(entityList);
         RefreshHistoryConfigHT(entityList);
         entityList = null;
         entity = null;
     }
     catch (Exception ex)
     {
         Loggers.LogInfo("PES.GPS.GPSStorage.CacheUtility.RefreshGPSHistoryData:" + ex.Message);
     }
 }
Beispiel #4
0
        /// <summary>
        /// 获取MOVO历史关系对应表
        /// </summary>
        /// <param name="dicCodeAndGpsRelation"></param>
        /// <returns></returns>
        public IDictionary<string, HistoryStoreConfig> GetHistoryTableRelation(ref IDictionary<string, string> dicCodeAndGpsRelation)
        {
            //List<HistoryStoreConfig> configList = new List<HistoryStoreConfig>();
            dicCodeAndGpsRelation = new Dictionary<string, string>();
            IDictionary<string, HistoryStoreConfig> configList = new Dictionary<string, HistoryStoreConfig>();
            DbConnection dbConnection = null;

            string strSQL = @"SELECT t1.vehiclecode,t2.tableName,selectConnStr,addConnStr,t2.ReserverColumn,t3.GPSCode FROM"
                        + " gps_historydatastoreconfig t1,gps_historydatastoretables t2,movo_vehicle t3 WHERE t1.storeTable=t2.recordID AND t1.enable=1 AND t1.vehiclecode=t3.VehicleCode";

            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)
                    {
                        HistoryStoreConfig entity = new HistoryStoreConfig();
                        entity.VehicleCode = row["vehiclecode"].ToString().Trim();
                        entity.GPSCode = row["GPSCode"].ToString().Trim();
                        entity.TableName = row["tableName"].ToString();
                        entity.SelectConnStr = row["selectConnStr"].ToString();
                        entity.AddConStr = row["addConnStr"].ToString();
                        entity.ReserverColumn = TryParseUshort(row["ReserverColumn"].ToString());

                        if (configList.ContainsKey(entity.VehicleCode))
                            configList.Remove(entity.VehicleCode);
                        configList.Add(entity.VehicleCode, entity);

                        if (dicCodeAndGpsRelation.ContainsKey(entity.GPSCode))
                            dicCodeAndGpsRelation.Remove(entity.GPSCode);
                        dicCodeAndGpsRelation.Add(entity.GPSCode, entity.VehicleCode);
                    }
                }
            }

            catch (Exception ex)
            {
                Logger.Error(ex);
            }

            return configList;
        }
Beispiel #5
0
 private void btnWriteCache_Click(object sender, EventArgs e)
 {
     HistoryStoreConfig config=new HistoryStoreConfig();
     CacheProviderFactory cacheProviderFactory = CacheProviderFactory.Default;
     ICacheProvider cacheProvider = cacheProviderFactory.CreateCacheProvider();
     cacheProvider.Add("test", config);
     cacheProviderFactory.ClearUp();
     //CacheUtility.RefreshGPSHistoryStoreTable(config);
 }
Beispiel #6
0
 private void btnReadHistoryStoreTable_Click(object sender, EventArgs e)
 {
     HistoryStoreConfig Config = new HistoryStoreConfig();
     object obj = CacheUtility.GetDataByKeyFromCache(CacheUtility.HistoryPrefiexCacheKey + VehicleCode);
     if (obj != null)
     {
         Config = obj as HistoryStoreConfig;
         txtResult.Text += string.Format("车辆编号为{0}连接字符串为{1}的{2}表", Config.VehicleCode, Config.AddConStr, Config.TableName);
     }
 }