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.

ModuleBLL.cs 25 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. using Learun.Application.Base.AuthorizeModule;
  2. using Learun.Cache.Base;
  3. using Learun.Cache.Factory;
  4. using Learun.Util;
  5. using System;
  6. using System.Collections.Generic;
  7. namespace Learun.Application.Base.SystemModule
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  11. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  12. /// 创建人:陈彬彬
  13. /// 日 期:2017.03.08
  14. /// 描 述:功能模块(缓存在0号库)
  15. /// 功能模块缓存结构
  16. /// </summary>
  17. public class ModuleBLL : ModuleIBLL
  18. {
  19. #region 属性
  20. private ModuleService moduleService = new ModuleService();
  21. private AuthorizeIBLL authorizeIBLL = new AuthorizeBLL();
  22. #endregion
  23. #region 缓存定义
  24. private ICache cache = CacheFactory.CaChe();
  25. private string cacheKey = "learun_adms_modules";
  26. private string cacheKeyBtn = "learun_adms_modules_Btn_"; // + 模块主键
  27. private string cacheKeyColumn = "learun_adms_modules_Column_";// + 模块主键
  28. private string cacheKeyForm = "learun_adms_modules_Form_";// + 模块主键
  29. #endregion
  30. #region 功能模块
  31. /// <summary>
  32. /// 功能列表
  33. /// </summary>
  34. /// <returns></returns>
  35. public List<ModuleEntity> GetModuleList()
  36. {
  37. try
  38. {
  39. List<ModuleEntity> list = cache.Read<List<ModuleEntity>>(cacheKey, CacheId.module);
  40. if (list == null)
  41. {
  42. list = (List<ModuleEntity>)moduleService.GetList();
  43. cache.Write<List<ModuleEntity>>(cacheKey, list, CacheId.module);
  44. }
  45. UserInfo userInfo = LoginUserInfo.Get();
  46. /*关联权限*/
  47. if (!userInfo.isSystem)
  48. {
  49. string objectIds = userInfo.userId + (string.IsNullOrEmpty(userInfo.roleIds) ? "" : ("," + userInfo.roleIds));
  50. List<string> itemIdList = authorizeIBLL.GetItemIdListByobjectIds(objectIds, 1);
  51. list = list.FindAll(t => itemIdList.IndexOf(t.F_ModuleId) >= 0);
  52. }
  53. return list;
  54. }
  55. catch (Exception ex)
  56. {
  57. if (ex is ExceptionEx)
  58. {
  59. throw;
  60. }
  61. else
  62. {
  63. throw ExceptionEx.ThrowBusinessException(ex);
  64. }
  65. }
  66. }
  67. /// <summary>
  68. /// 功能列表
  69. /// </summary>
  70. /// <returns></returns>
  71. public ModuleEntity GetModuleByUrl(string url)
  72. {
  73. try
  74. {
  75. if (url.Contains("?"))
  76. {
  77. url=url.Substring(0, url.IndexOf('?'));
  78. }
  79. List<ModuleEntity> list = GetModuleList();
  80. return list.Find(t => t.F_UrlAddress == url);
  81. }
  82. catch (Exception ex)
  83. {
  84. if (ex is ExceptionEx)
  85. {
  86. throw;
  87. }
  88. else
  89. {
  90. throw ExceptionEx.ThrowBusinessException(ex);
  91. }
  92. }
  93. }
  94. /// <summary>
  95. /// 获取功能列表的树形数据
  96. /// </summary>
  97. /// <returns></returns>
  98. public List<TreeModel> GetModuleTree()
  99. {
  100. List<ModuleEntity> modulelist = GetModuleList();
  101. List<TreeModel> treeList = new List<TreeModel>();
  102. foreach (var item in modulelist) {
  103. TreeModel node = new TreeModel();
  104. node.id = item.F_ModuleId;
  105. node.text = item.F_FullName;
  106. node.value = item.F_EnCode;
  107. node.showcheck = false;
  108. node.checkstate = 0;
  109. node.isexpand = (item.F_AllowExpand == 1);
  110. node.icon = item.F_Icon;
  111. node.parentId = item.F_ParentId;
  112. treeList.Add(node);
  113. }
  114. return treeList.ToTree();
  115. }
  116. /// <summary>
  117. /// 获取功能列表的树形数据(带勾选框)
  118. /// </summary>
  119. /// <returns></returns>
  120. public List<TreeModel> GetModuleCheckTree()
  121. {
  122. List<ModuleEntity> modulelist = GetModuleList();
  123. List<TreeModel> treeList = new List<TreeModel>();
  124. foreach (var item in modulelist)
  125. {
  126. TreeModel node = new TreeModel();
  127. node.id = item.F_ModuleId;
  128. node.text = item.F_FullName;
  129. node.value = item.F_EnCode;
  130. node.showcheck = true;
  131. node.checkstate = 0;
  132. node.isexpand = true;
  133. node.icon = item.F_Icon;
  134. node.parentId = item.F_ParentId;
  135. treeList.Add(node);
  136. }
  137. return treeList.ToTree();
  138. }
  139. /// <summary>
  140. /// 获取功能列表的树形数据(只有展开项)
  141. /// </summary>
  142. /// <returns></returns>
  143. public List<TreeModel> GetExpendModuleTree()
  144. {
  145. List<ModuleEntity> modulelist = GetModuleList();
  146. List<TreeModel> treeList = new List<TreeModel>();
  147. foreach (var item in modulelist)
  148. {
  149. if (item.F_Target == "expand")
  150. {
  151. TreeModel node = new TreeModel();
  152. node.id = item.F_ModuleId;
  153. node.text = item.F_FullName;
  154. node.value = item.F_EnCode;
  155. node.showcheck = false;
  156. node.checkstate = 0;
  157. node.isexpand = true;
  158. node.icon = item.F_Icon;
  159. node.parentId = item.F_ParentId;
  160. treeList.Add(node);
  161. }
  162. }
  163. return treeList.ToTree();
  164. }
  165. /// <summary>
  166. /// 根据父级主键获取数据
  167. /// </summary>
  168. /// <param name="keyword">关键字</param>
  169. /// <param name="parentId">父级主键</param>
  170. /// <returns></returns>
  171. public List<ModuleEntity> GetModuleListByParentId(string keyword, string parentId)
  172. {
  173. try
  174. {
  175. List<ModuleEntity> list = (List<ModuleEntity>)GetModuleList();
  176. list = list.FindAll(t => t.F_ParentId == parentId);
  177. if (!string.IsNullOrEmpty(keyword))
  178. {
  179. list = list.FindAll(t => t.F_FullName.Contains(keyword) || t.F_EnCode.Contains(keyword));
  180. }
  181. return list;
  182. }
  183. catch (Exception ex)
  184. {
  185. if (ex is ExceptionEx)
  186. {
  187. throw;
  188. }
  189. else
  190. {
  191. throw ExceptionEx.ThrowBusinessException(ex);
  192. }
  193. }
  194. }
  195. /// <summary>
  196. /// 功能实体
  197. /// </summary>
  198. /// <param name="keyValue">主键值</param>
  199. /// <returns></returns>
  200. public ModuleEntity GetModuleEntity(string keyValue)
  201. {
  202. try
  203. {
  204. return moduleService.GetEntity(keyValue);
  205. }
  206. catch (Exception ex)
  207. {
  208. if (ex is ExceptionEx)
  209. {
  210. throw;
  211. }
  212. else
  213. {
  214. throw ExceptionEx.ThrowBusinessException(ex);
  215. }
  216. }
  217. }
  218. #endregion
  219. #region 模块按钮
  220. /// <summary>
  221. /// 获取按钮列表数据
  222. /// </summary>
  223. /// <param name="moduleId">模块Id</param>
  224. /// <returns></returns>
  225. public List<ModuleButtonEntity> GetButtonListNoAuthorize(string moduleId)
  226. {
  227. try
  228. {
  229. List<ModuleButtonEntity> list = cache.Read<List<ModuleButtonEntity>>(cacheKeyBtn + moduleId, CacheId.module);
  230. if (list == null)
  231. {
  232. list = (List<ModuleButtonEntity>)moduleService.GetButtonList(moduleId);
  233. cache.Write<List<ModuleButtonEntity>>(cacheKeyBtn + moduleId, list, CacheId.module);
  234. }
  235. return list;
  236. }
  237. catch (Exception ex)
  238. {
  239. if (ex is ExceptionEx)
  240. {
  241. throw;
  242. }
  243. else
  244. {
  245. throw ExceptionEx.ThrowBusinessException(ex);
  246. }
  247. }
  248. }
  249. /// <summary>
  250. /// 获取按钮列表数据
  251. /// </summary>
  252. /// <param name="moduleId">模块Id</param>
  253. /// <returns></returns>
  254. public List<ModuleButtonEntity> GetButtonList(string moduleId)
  255. {
  256. try
  257. {
  258. List<ModuleButtonEntity> list = cache.Read<List<ModuleButtonEntity>>(cacheKeyBtn + moduleId, CacheId.module);
  259. if (list == null) {
  260. list = (List<ModuleButtonEntity>)moduleService.GetButtonList(moduleId);
  261. cache.Write<List<ModuleButtonEntity>>(cacheKeyBtn + moduleId, list, CacheId.module);
  262. }
  263. UserInfo userInfo = LoginUserInfo.Get();
  264. /*关联权限*/
  265. if (!userInfo.isSystem)
  266. {
  267. string objectIds = userInfo.userId + (string.IsNullOrEmpty(userInfo.roleIds) ? "" : ("," + userInfo.roleIds));
  268. List<string> itemIdList = authorizeIBLL.GetItemIdListByobjectIds(objectIds, 2);
  269. list = list.FindAll(t => itemIdList.IndexOf(t.F_ModuleButtonId) >= 0);
  270. }
  271. return list;
  272. }
  273. catch (Exception ex)
  274. {
  275. if (ex is ExceptionEx)
  276. {
  277. throw;
  278. }
  279. else
  280. {
  281. throw ExceptionEx.ThrowBusinessException(ex);
  282. }
  283. }
  284. }
  285. /// <summary>
  286. /// 获取按钮列表数据
  287. /// </summary>
  288. /// <param name="url">功能模块地址</param>
  289. /// <returns></returns>
  290. public List<ModuleButtonEntity> GetButtonListByUrl(string url)
  291. {
  292. try
  293. {
  294. ModuleEntity moduleEntity = GetModuleByUrl(url);
  295. if (moduleEntity == null)
  296. {
  297. return new List<ModuleButtonEntity>();
  298. }
  299. return GetButtonList(moduleEntity.F_ModuleId);
  300. }
  301. catch (Exception ex)
  302. {
  303. if (ex is ExceptionEx)
  304. {
  305. throw;
  306. }
  307. else
  308. {
  309. throw ExceptionEx.ThrowBusinessException(ex);
  310. }
  311. }
  312. }
  313. /// <summary>
  314. /// 获取按钮列表树形数据(基于功能模块)
  315. /// </summary>
  316. /// <returns></returns>
  317. public List<TreeModel> GetButtonCheckTree()
  318. {
  319. List<ModuleEntity> modulelist = GetModuleList();
  320. List<TreeModel> treeList = new List<TreeModel>();
  321. foreach (var module in modulelist)
  322. {
  323. TreeModel node = new TreeModel();
  324. node.id = module.F_ModuleId + "_learun_moduleId";
  325. node.text = module.F_FullName;
  326. node.value = module.F_EnCode;
  327. node.showcheck = true;
  328. node.checkstate = 0;
  329. node.isexpand = true;
  330. node.icon = module.F_Icon;
  331. node.parentId = module.F_ParentId + "_learun_moduleId";
  332. if (module.F_Target != "expand")
  333. {
  334. List<ModuleButtonEntity> buttonList = GetButtonList(module.F_ModuleId);
  335. if (buttonList.Count > 0)
  336. {
  337. treeList.Add(node);
  338. }
  339. foreach (var button in buttonList)
  340. {
  341. TreeModel buttonNode = new TreeModel();
  342. buttonNode.id = button.F_ModuleButtonId;
  343. buttonNode.text = button.F_FullName;
  344. buttonNode.value = button.F_EnCode;
  345. buttonNode.showcheck = true;
  346. buttonNode.checkstate = 0;
  347. buttonNode.isexpand = true;
  348. buttonNode.icon = "fa fa-wrench";
  349. buttonNode.parentId = (button.F_ParentId == "0" ? button.F_ModuleId + "_learun_moduleId" : button.F_ParentId);
  350. treeList.Add(buttonNode);
  351. };
  352. }
  353. else
  354. {
  355. treeList.Add(node);
  356. }
  357. }
  358. return treeList.ToTree();
  359. }
  360. #endregion
  361. #region 模块视图
  362. /// <summary>
  363. /// 获取视图列表数据
  364. /// </summary>
  365. /// <param name="moduleId">模块Id</param>
  366. /// <returns></returns>
  367. public List<ModuleColumnEntity> GetColumnList(string moduleId)
  368. {
  369. try
  370. {
  371. List<ModuleColumnEntity> list = cache.Read<List<ModuleColumnEntity>>(cacheKeyColumn + moduleId, CacheId.module);
  372. if (list == null)
  373. {
  374. list = (List<ModuleColumnEntity>)moduleService.GetColumnList(moduleId);
  375. cache.Write<List<ModuleColumnEntity>>(cacheKeyColumn + moduleId, list, CacheId.module);
  376. }
  377. UserInfo userInfo = LoginUserInfo.Get();
  378. /*关联权限*/
  379. if (!userInfo.isSystem)
  380. {
  381. string objectIds = userInfo.userId + (string.IsNullOrEmpty(userInfo.roleIds) ? "" : ("," + userInfo.roleIds));
  382. List<string> itemIdList = authorizeIBLL.GetItemIdListByobjectIds(objectIds, 3);
  383. list = list.FindAll(t => itemIdList.IndexOf(t.F_ModuleColumnId) >= 0);
  384. }
  385. return list;
  386. }
  387. catch (Exception ex)
  388. {
  389. if (ex is ExceptionEx)
  390. {
  391. throw;
  392. }
  393. else
  394. {
  395. throw ExceptionEx.ThrowBusinessException(ex);
  396. }
  397. }
  398. }
  399. /// <summary>
  400. /// 获取视图列表数据
  401. /// </summary>
  402. /// <param name="url">功能模块地址</param>
  403. /// <returns></returns>
  404. public List<ModuleColumnEntity> GetColumnListByUrl(string url)
  405. {
  406. try
  407. {
  408. ModuleEntity moduleEntity = GetModuleByUrl(url);
  409. if (moduleEntity == null)
  410. {
  411. return new List<ModuleColumnEntity>();
  412. }
  413. return GetColumnList(moduleEntity.F_ModuleId);
  414. }
  415. catch (Exception ex)
  416. {
  417. if (ex is ExceptionEx)
  418. {
  419. throw;
  420. }
  421. else
  422. {
  423. throw ExceptionEx.ThrowBusinessException(ex);
  424. }
  425. }
  426. }
  427. /// <summary>
  428. /// 获取按钮列表树形数据(基于功能模块)
  429. /// </summary>
  430. /// <returns></returns>
  431. public List<TreeModel> GetColumnCheckTree()
  432. {
  433. List<ModuleEntity> modulelist = GetModuleList();
  434. List<TreeModel> treeList = new List<TreeModel>();
  435. foreach (var module in modulelist)
  436. {
  437. TreeModel node = new TreeModel();
  438. node.id = module.F_ModuleId + "_learun_moduleId";
  439. node.text = module.F_FullName;
  440. node.value = module.F_EnCode;
  441. node.showcheck = true;
  442. node.checkstate = 0;
  443. node.isexpand = true;
  444. node.icon = module.F_Icon;
  445. node.parentId = module.F_ParentId + "_learun_moduleId";
  446. if (module.F_Target != "expand")
  447. {
  448. List<ModuleColumnEntity> columnList = GetColumnList(module.F_ModuleId);
  449. if (columnList.Count > 0)
  450. {
  451. treeList.Add(node);
  452. }
  453. foreach (var column in columnList)
  454. {
  455. TreeModel columnNode = new TreeModel();
  456. columnNode.id = column.F_ModuleColumnId;
  457. columnNode.text = column.F_FullName;
  458. columnNode.value = column.F_EnCode;
  459. columnNode.showcheck = true;
  460. columnNode.checkstate = 0;
  461. columnNode.isexpand = true;
  462. columnNode.icon = "fa fa-filter";
  463. columnNode.parentId = column.F_ModuleId + "_learun_moduleId";
  464. treeList.Add(columnNode);
  465. };
  466. }
  467. else
  468. {
  469. treeList.Add(node);
  470. }
  471. }
  472. return treeList.ToTree();
  473. }
  474. #endregion
  475. #region 模块表单
  476. /// <summary>
  477. /// 获取表单字段数据
  478. /// </summary>
  479. /// <param name="moduleId">模块Id</param>
  480. /// <returns></returns>
  481. public List<ModuleFormEntity> GetFormList(string moduleId)
  482. {
  483. try
  484. {
  485. List<ModuleFormEntity> list = cache.Read<List<ModuleFormEntity>>(cacheKeyForm + moduleId, CacheId.module);
  486. if (list == null)
  487. {
  488. list = (List<ModuleFormEntity>)moduleService.GetFormList(moduleId);
  489. cache.Write<List<ModuleFormEntity>>(cacheKeyForm + moduleId, list, CacheId.module);
  490. }
  491. UserInfo userInfo = LoginUserInfo.Get();
  492. /*关联权限*/
  493. if (!userInfo.isSystem)
  494. {
  495. string objectIds = userInfo.userId + (string.IsNullOrEmpty(userInfo.roleIds) ? "" : ("," + userInfo.roleIds));
  496. List<string> itemIdList = authorizeIBLL.GetItemIdListByobjectIds(objectIds, 3);
  497. list = list.FindAll(t => itemIdList.IndexOf(t.F_ModuleFormId) >= 0);
  498. }
  499. return list;
  500. }
  501. catch (Exception ex)
  502. {
  503. if (ex is ExceptionEx)
  504. {
  505. throw;
  506. }
  507. else
  508. {
  509. throw ExceptionEx.ThrowBusinessException(ex);
  510. }
  511. }
  512. }
  513. /// <summary>
  514. /// 获取表单字段数据
  515. /// </summary>
  516. /// <param name="url">功能模块地址</param>
  517. /// <returns></returns>
  518. public List<ModuleFormEntity> GetFormListByUrl(string url)
  519. {
  520. try
  521. {
  522. ModuleEntity moduleEntity = GetModuleByUrl(url);
  523. if (moduleEntity == null)
  524. {
  525. return new List<ModuleFormEntity>();
  526. }
  527. return GetFormList(moduleEntity.F_ModuleId);
  528. }
  529. catch (Exception ex)
  530. {
  531. if (ex is ExceptionEx)
  532. {
  533. throw;
  534. }
  535. else
  536. {
  537. throw ExceptionEx.ThrowBusinessException(ex);
  538. }
  539. }
  540. }
  541. /// <summary>
  542. /// 获取表单字段树形数据(基于功能模块)
  543. /// </summary>
  544. /// <returns></returns>
  545. public List<TreeModel> GetFormCheckTree()
  546. {
  547. List<ModuleEntity> modulelist = GetModuleList();
  548. List<TreeModel> treeList = new List<TreeModel>();
  549. foreach (var module in modulelist)
  550. {
  551. TreeModel node = new TreeModel();
  552. node.id = module.F_ModuleId + "_learun_moduleId";
  553. node.text = module.F_FullName;
  554. node.value = module.F_EnCode;
  555. node.showcheck = true;
  556. node.checkstate = 0;
  557. node.isexpand = true;
  558. node.icon = module.F_Icon;
  559. node.parentId = module.F_ParentId + "_learun_moduleId";
  560. if (module.F_Target != "expand")
  561. {
  562. List<ModuleFormEntity> columnList = GetFormList(module.F_ModuleId);
  563. if (columnList.Count > 0)
  564. {
  565. treeList.Add(node);
  566. }
  567. foreach (var column in columnList)
  568. {
  569. TreeModel columnNode = new TreeModel();
  570. columnNode.id = column.F_ModuleFormId;
  571. columnNode.text = column.F_FullName;
  572. columnNode.value = column.F_EnCode;
  573. columnNode.showcheck = true;
  574. columnNode.checkstate = 0;
  575. columnNode.isexpand = true;
  576. columnNode.icon = "fa fa-filter";
  577. columnNode.parentId = column.F_ModuleId + "_learun_moduleId";
  578. treeList.Add(columnNode);
  579. };
  580. }
  581. else
  582. {
  583. treeList.Add(node);
  584. }
  585. }
  586. return treeList.ToTree();
  587. }
  588. #endregion
  589. #region 提交数据
  590. /// <summary>
  591. /// 虚拟删除模块功能
  592. /// </summary>
  593. /// <param name="keyValue">主键值</param>
  594. public bool Delete(string keyValue)
  595. {
  596. try
  597. {
  598. List<ModuleEntity> list = GetModuleListByParentId("", keyValue);
  599. if (list.Count > 0)
  600. {
  601. return false;
  602. }
  603. moduleService.Delete(keyValue);
  604. cache.Remove(cacheKey, CacheId.module);
  605. cache.Remove(cacheKeyBtn + keyValue, CacheId.module);
  606. cache.Remove(cacheKeyColumn + keyValue, CacheId.module);
  607. cache.Remove(cacheKeyForm + keyValue, CacheId.module);
  608. return true;
  609. }
  610. catch (Exception ex)
  611. {
  612. if (ex is ExceptionEx)
  613. {
  614. throw;
  615. }
  616. else
  617. {
  618. throw ExceptionEx.ThrowBusinessException(ex);
  619. }
  620. }
  621. }
  622. /// <summary>
  623. /// 保存模块功能实体(新增、修改)
  624. /// </summary>
  625. /// <param name="keyValue">主键值</param>
  626. /// <param name="moduleEntity">实体</param>
  627. /// <param name="moduleButtonEntitys">按钮列表</param>
  628. /// <param name="moduleColumnEntitys">视图列集合</param>
  629. /// <param name="moduleFormEntitys">表单字段集合</param>
  630. public void SaveEntity(string keyValue, ModuleEntity moduleEntity, List<ModuleButtonEntity> moduleButtonEntitys, List<ModuleColumnEntity> moduleColumnEntitys, List<ModuleFormEntity> moduleFormEntitys)
  631. {
  632. try
  633. {
  634. moduleService.SaveEntity(keyValue, moduleEntity, moduleButtonEntitys, moduleColumnEntitys, moduleFormEntitys);
  635. /*移除缓存信息*/
  636. cache.Remove(cacheKey, CacheId.module);
  637. if (!string.IsNullOrEmpty(keyValue))
  638. {
  639. cache.Remove(cacheKeyBtn + keyValue, CacheId.module);
  640. cache.Remove(cacheKeyColumn + keyValue, CacheId.module);
  641. cache.Remove(cacheKeyForm + keyValue, CacheId.module);
  642. }
  643. }
  644. catch (Exception ex)
  645. {
  646. if (ex is ExceptionEx)
  647. {
  648. throw;
  649. }
  650. else
  651. {
  652. throw ExceptionEx.ThrowBusinessException(ex);
  653. }
  654. }
  655. }
  656. #endregion
  657. #region 权限验证
  658. /// <summary>
  659. /// 验证当前访问的地址是否有权限
  660. /// </summary>
  661. /// <param name="url">访问地址</param>
  662. /// <returns></returns>
  663. public bool FilterAuthorize(string url)
  664. {
  665. try
  666. {
  667. List<ModuleEntity> list = GetModuleList();
  668. // 验证是否是功能页面
  669. var modulelist = list.FindAll(t => t.F_UrlAddress == url);
  670. if (modulelist.Count > 0)
  671. {
  672. return true;
  673. }
  674. // 是否是功能按钮的
  675. foreach (var item in list)
  676. {
  677. List<ModuleButtonEntity> buttonList = GetButtonList(item.F_ModuleId);
  678. var buttonList2 = buttonList.FindAll(t => t.F_ActionAddress == url);
  679. if (buttonList2.Count > 0)
  680. {
  681. return true;
  682. }
  683. }
  684. return false;
  685. }
  686. catch (Exception ex)
  687. {
  688. if (ex is ExceptionEx)
  689. {
  690. throw;
  691. }
  692. else
  693. {
  694. throw ExceptionEx.ThrowBusinessException(ex);
  695. }
  696. }
  697. }
  698. #endregion
  699. }
  700. }