You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LGMapBLL.cs 8.0 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. using Learun.Cache.Base;
  2. using Learun.Cache.Factory;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. namespace Learun.Application.Language
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架
  11. /// Copyright (c) 2013-2018 上海力软信息技术有限公司
  12. /// 创 建:超级管理员
  13. /// 日 期:2018-04-10 15:00
  14. /// 描 述:语言映照
  15. /// </summary>
  16. public class LGMapBLL : LGMapIBLL
  17. {
  18. private LGMapService lGMapService = new LGMapService();
  19. #region 缓存设置
  20. private ICache cache = CacheFactory.CaChe();
  21. private string cacheKey = "learun_adms_lg_"; // + 语言类型编码
  22. #endregion
  23. #region 获取数据
  24. /// <summary>
  25. /// 获取语言包映射关系数据集合
  26. /// <param name="Code">语言包编码</param>
  27. /// <param name="isMain">是否是主语言</param>
  28. /// <summary>
  29. /// <returns></returns>
  30. public Dictionary<string, string> GetMap(string Code,bool isMain)
  31. {
  32. try
  33. {
  34. Dictionary<string,string> list = cache.Read<Dictionary<string, string>>(cacheKey + Code, CacheId.language);
  35. if (list == null)
  36. {
  37. list = new Dictionary<string, string>();
  38. var _list = lGMapService.GetDataList(Code);
  39. if (isMain)
  40. {
  41. foreach (var item in _list)
  42. {
  43. if (!list.ContainsKey(item.name))
  44. {
  45. list.Add(item.name, item.id);
  46. }
  47. }
  48. }
  49. else {
  50. foreach (var item in _list)
  51. {
  52. if (!list.ContainsKey(item.id))
  53. {
  54. list.Add(item.id, item.name);
  55. }
  56. }
  57. }
  58. cache.Write<Dictionary<string, string>>(cacheKey + Code, list, CacheId.language);
  59. }
  60. return list;
  61. }
  62. catch (Exception ex)
  63. {
  64. if (ex is ExceptionEx)
  65. {
  66. throw;
  67. }
  68. else
  69. {
  70. throw ExceptionEx.ThrowBusinessException(ex);
  71. }
  72. }
  73. }
  74. /// <summary>
  75. /// 获取列表数据
  76. /// <param name="TypeCode">编码</param>
  77. /// <summary>
  78. /// <returns></returns>
  79. public IEnumerable<LGMapEntity> GetListByTypeCode(string TypeCode)
  80. {
  81. try
  82. {
  83. return lGMapService.GetListByTypeCode(TypeCode);
  84. }
  85. catch (Exception ex)
  86. {
  87. if (ex is ExceptionEx)
  88. {
  89. throw;
  90. }
  91. else
  92. {
  93. throw ExceptionEx.ThrowBusinessException(ex);
  94. }
  95. }
  96. }
  97. /// <summary>
  98. /// 获取列表数据
  99. /// <summary>
  100. /// <returns></returns>
  101. public IEnumerable<LGMapEntity> GetList(string queryJson)
  102. {
  103. try
  104. {
  105. return lGMapService.GetList(queryJson);
  106. }
  107. catch (Exception ex)
  108. {
  109. if (ex is ExceptionEx)
  110. {
  111. throw;
  112. }
  113. else
  114. {
  115. throw ExceptionEx.ThrowBusinessException(ex);
  116. }
  117. }
  118. }
  119. /// <summary>
  120. /// 获取列表分页数据
  121. /// <param name="pagination">分页参数</param>
  122. /// <param name="typeList">语言类型列表</param>
  123. /// <summary>
  124. /// <returns></returns>
  125. public DataTable GetPageList(Pagination pagination, string queryJson, string typeList)
  126. {
  127. try
  128. {
  129. return lGMapService.GetPageList(pagination, queryJson, typeList);
  130. }
  131. catch (Exception ex)
  132. {
  133. if (ex is ExceptionEx)
  134. {
  135. throw;
  136. }
  137. else
  138. {
  139. throw ExceptionEx.ThrowBusinessException(ex);
  140. }
  141. }
  142. }
  143. /// <summary>
  144. /// 获取实体数据
  145. /// <param name="keyValue">主键</param>
  146. /// <summary>
  147. /// <returns></returns>
  148. public LGMapEntity GetEntity(string keyValue)
  149. {
  150. try
  151. {
  152. return lGMapService.GetEntity(keyValue);
  153. }
  154. catch (Exception ex)
  155. {
  156. if (ex is ExceptionEx)
  157. {
  158. throw;
  159. }
  160. else
  161. {
  162. throw ExceptionEx.ThrowBusinessException(ex);
  163. }
  164. }
  165. }
  166. /// <summary>
  167. /// 根据名称获取列表
  168. /// <param name="keyValue">F_Name</param>
  169. /// <summary>
  170. /// <returns></returns>
  171. public IEnumerable<LGMapEntity> GetListByName(string keyValue)
  172. {
  173. try
  174. {
  175. return lGMapService.GetListByName(keyValue);
  176. }
  177. catch (Exception ex)
  178. {
  179. if (ex is ExceptionEx)
  180. {
  181. throw;
  182. }
  183. else
  184. {
  185. throw ExceptionEx.ThrowBusinessException(ex);
  186. }
  187. }
  188. }
  189. /// <summary>
  190. /// 根据名称与类型获取列表
  191. /// <param name="keyValue">F_Name</param>
  192. /// <param name="typeCode">typeCode</param>
  193. /// <summary>
  194. /// <returns></returns>
  195. public IEnumerable<LGMapEntity> GetListByNameAndType(string keyValue, string typeCode)
  196. {
  197. try
  198. {
  199. return lGMapService.GetListByNameAndType(keyValue, typeCode);
  200. }
  201. catch (Exception ex)
  202. {
  203. if (ex is ExceptionEx)
  204. {
  205. throw;
  206. }
  207. else
  208. {
  209. throw ExceptionEx.ThrowBusinessException(ex);
  210. }
  211. }
  212. }
  213. #endregion
  214. #region 提交数据
  215. /// <summary>
  216. /// 删除实体数据
  217. /// <param name="keyValue">主键</param>
  218. /// <summary>
  219. /// <returns></returns>
  220. public void DeleteEntity(string keyValue)
  221. {
  222. try
  223. {
  224. lGMapService.DeleteEntity(keyValue);
  225. cache.RemoveAll(CacheId.language);
  226. }
  227. catch (Exception ex)
  228. {
  229. if (ex is ExceptionEx)
  230. {
  231. throw;
  232. }
  233. else
  234. {
  235. throw ExceptionEx.ThrowBusinessException(ex);
  236. }
  237. }
  238. }
  239. /// <summary>
  240. /// 保存实体数据(新增、修改)
  241. /// <param name="nameList">原列表</param>
  242. /// <param name="newNameList">新列表</param>
  243. /// <param name="code">F_Code</param>
  244. /// <summary>
  245. /// <returns></returns>
  246. public void SaveEntity(string nameList, string newNameList, string code)
  247. {
  248. try
  249. {
  250. lGMapService.SaveEntity(nameList, newNameList, code);
  251. cache.RemoveAll(CacheId.language);
  252. }
  253. catch (Exception ex)
  254. {
  255. if (ex is ExceptionEx)
  256. {
  257. throw;
  258. }
  259. else
  260. {
  261. throw ExceptionEx.ThrowBusinessException(ex);
  262. }
  263. }
  264. }
  265. #endregion
  266. }
  267. }