Ejemplo n.º 1
0
        /// <summary>
        /// 进行数据库的适配
        /// </summary>
        /// <param name="dbType"></param>
        /// <returns></returns>
        private ICategroyService SwitchBasicDataSource(string dbType)
        {
            ICategroyService cs = null;

            //当前数据库
            switch (dbType)
            {
            case DBType.MySQL:
                break;

            case DBType.SQLite:
                cs = new CategorySQLiteService("TecentDA_Write");
                break;

            case DBType.SQLServer:
                cs = new CategoryDataService(new ConfigurationItems().TecentDA_Read);
                break;

            case DBType.Redis:
                cs = new RedisService(string.Format("IP={0};Port={1};Psw={2}", SystemConfig.RedisIp, SystemConfig.RedisPort, SystemConfig.RedisPsw));
                break;

            case DBType.IOFile:
                cs = new CategoryDataServiceInIOFile();
                break;
            }
            return(cs);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取城市数据
 /// </summary>
 /// <returns>城市数据列表【null情况出现则是数据库切换没有成功】</returns>
 public List <CategoryData> QueryCities()
 {
     try
     {
         ICategroyService cs  = SwitchBasicDataSource(SystemConfig.BasicDBType);
         string           key = "City";
         if (cs != null)
         {
             return(cs.QueryCityCategory(key).ToList());
         }
         return(null);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Ejemplo n.º 3
0
 public BaseDataController(IGenderService GenderService, ICategroyService CategoryService, IBrandService BrandService)
 {
     genderService = GenderService;
     categoryService = CategoryService;
     brandService = BrandService;
 }