/// <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); }
/// <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); } }
public BaseDataController(IGenderService GenderService, ICategroyService CategoryService, IBrandService BrandService) { genderService = GenderService; categoryService = CategoryService; brandService = BrandService; }