public async Task <string> GetTextLang(string text) { string key = ECacheKey.LanguageInfo.ToString(); var cachedData = _distributedCache.GetString(key); var lsAllLanguage = new List <LanguageInfo>(); if (cachedData != null && cachedData != "null") { lsAllLanguage = JsonConvert.DeserializeObject <List <LanguageInfo> >(cachedData); } else { lsAllLanguage = await _moduleService.GetAllTextLanguage(); RedisUtils.SetCacheData(_distributedCache, _Configuration, lsAllLanguage, key); } if (lsAllLanguage != null && lsAllLanguage.Any()) { var lang = lsAllLanguage.Where(x => x.LanguageName == "DEFERROR$" + text); if (lang != null && lang.Any()) { return(lang.First().LanguageValue); } } return(text); }
public async Task <string> GetErrText(int error) { string key = ECacheKey.ErrorInfo.ToString(); var cachedData = _distributedCache.GetString(key); var lstAllError = new List <ErrorInfo>(); if (cachedData != null && cachedData != "null") { lstAllError = JsonConvert.DeserializeObject <List <ErrorInfo> >(cachedData); } else { lstAllError = await _moduleService.GetAllError(); RedisUtils.SetCacheData(_distributedCache, _Configuration, lstAllError, key); } if (lstAllError != null && lstAllError.Any()) { var err = lstAllError.Where(x => x.ErrorCode == error); if (err != null && err.Any()) { return(err.First().ErrorName); } } return("Không tìm thấy lỗi"); }
public async Task <MaintainModuleInfo> LoadMaintainModuleInfo(string modId) { string key = ECacheKey.MaintainModuleInfo.ToString() + modId; var cachedData = _distributedCache.GetString(key); if (cachedData != null && cachedData != "null") { var exec = JsonConvert.DeserializeObject <List <MaintainModuleInfo> >(cachedData); return(exec.First()); } else { var exec = await _moduleService.LoadMaintainModuleInfo(modId); RedisUtils.SetCacheData(_distributedCache, _Configuration, exec, key); return(exec.First()); } }
public async Task LoadBtnLanguage() { try { string key = ECacheKey.BtnLanguageInfo.ToString(); var cachedData = _distributedCache.GetString(key); if (cachedData != null && cachedData != "null") { var module = JsonConvert.DeserializeObject <List <LanguageInfo> >(cachedData); } else { var model = await _moduleService.GetAllBtnLanguageText(); RedisUtils.SetCacheData(_distributedCache, _Configuration, model, key); } } catch (Exception e) { } }
/// <summary> /// Load Tất cả defTask vào cache /// </summary> /// <returns></returns> public async Task <List <ModTreeView> > GetAllModTreeview() { try { string key = ECacheKey.ModTreeview.ToString(); var cachedData = _distributedCache.GetString(key); if (cachedData != null && cachedData != "null") { var modTreeview = JsonConvert.DeserializeObject <List <ModTreeView> >(cachedData); return(modTreeview); } else { var modTreeview = await _moduleService.GetAllModTreeView(); RedisUtils.SetCacheData(_distributedCache, _Configuration, modTreeview, key); return(modTreeview); } } catch (Exception e) { return(null); } }
/// <summary> /// Load Tất cả defTask vào cache /// </summary> /// <returns></returns> public async Task <List <DefTasks> > LoadAllDefTasks() { try { string key = ECacheKey.DefTasks.ToString(); var cachedData = _distributedCache.GetString(key); if (cachedData != null && cachedData != "null") { var defTasks = JsonConvert.DeserializeObject <List <DefTasks> >(cachedData); return(defTasks); } else { var defTasks = await _moduleService.GetAllDefTasks(); RedisUtils.SetCacheData(_distributedCache, _Configuration, defTasks, key); return(defTasks); } } catch (Exception e) { return(null); } }
public async Task <ModuleInfoViewModel> GetModule(string modId) { try { string key = ECacheKey.ModuleInfo.ToString() + modId; var cachedData = _distributedCache.GetString(key); if (cachedData != null && cachedData != "null") { var module = JsonConvert.DeserializeObject <ModuleInfoViewModel>(cachedData); return(module); } else { var model = await _moduleService.GetModule(modId); RedisUtils.SetCacheData(_distributedCache, _Configuration, model, key); return(model); } } catch (Exception e) { return(null); } }
public async Task <SearchModuleInfo> LoadModSearchByModId(string modId) { try { string key = ECacheKey.ModuleSearchInfo.ToString() + modId; var cachedData = _distributedCache.GetString(key); if (cachedData != null && cachedData != "null") { var module = JsonConvert.DeserializeObject <List <SearchModuleInfo> >(cachedData); return(module.FirstOrDefault()); } else { var modSearchs = await _moduleService.LoadModSearchByModId(modId); RedisUtils.SetCacheData(_distributedCache, _Configuration, modSearchs, key); return(modSearchs.FirstOrDefault()); } } catch (Exception e) { return(null); } }
public async Task <List <CodeInfo> > LoadAllDefCode(List <string> codes) { try { string key = ECacheKey.DefCode.ToString(); var cachedData = _distributedCache.GetString(key); var defcodes = new List <CodeInfo>(); if (cachedData != null && cachedData != "null") { defcodes = JsonConvert.DeserializeObject <List <CodeInfo> >(cachedData); } else { defcodes = await _moduleService.GetAllDefCode(); RedisUtils.SetCacheData(_distributedCache, _Configuration, defcodes, key); } return(defcodes.Where(x => codes.Contains(x.CodeName)).ToList()); } catch (Exception e) { return(null); } }