private void LoadOrg() { try { PrivilegeService _proxy = Common.Util.CreateProxy(); using (_proxy as IDisposable) { organizations = _proxy.QueryUnit("HIS"); } } catch (Exception e) { MessageBox.Show(e.Message, "提示"); return; } }
/// <summary> /// 查询用户角色授权信息 /// </summary> /// <param name="user"></param> /// <returns></returns> public Dictionary <String, List <HISFC.Models.Privilege.Organization> > GetAuthorityRoleOrg(User user) { Dictionary <String, HISFC.Models.Privilege.Organization> orgIdOrgMapping = new Dictionary <string, HISFC.Models.Privilege.Organization>(); Dictionary <String, List <HISFC.Models.Privilege.Organization> > roleOrgsDictionary = new Dictionary <string, List <HISFC.Models.Privilege.Organization> >(); List <String[]> roleOrg = null; List <String> roleList = null; //获得所有类型的组织结构 List <String> appIds = new List <string>(); PrivilegeService privilegeService = new PrivilegeService(); appIds = privilegeService.QueryAppID() as List <string>; foreach (string appId in appIds) { if (privilegeService.QueryUnit(appId) == null) { continue; } foreach (HISFC.Models.Privilege.Organization newOrg in privilegeService.QueryUnit(appId)) { if (newOrg == null || String.IsNullOrEmpty(newOrg.ID)) { continue; } orgIdOrgMapping.Add(newOrg.ID, newOrg); } } //using (DaoManager daoMgr = new DaoManager()) //{ try { //daoMgr.BeginTransaction(); roleOrg = authorityLogic.Query(user.Id); roleList = authorityLogic.QueryRole(user.Id); foreach (String roleId in roleList) { roleOrgsDictionary.Add(roleId, new List <HISFC.Models.Privilege.Organization>()); { foreach (String[] roleOrgArray in roleOrg) { if (roleId == roleOrgArray[2]) { if (!orgIdOrgMapping.ContainsKey(roleOrgArray[3])) { continue; } roleOrgsDictionary[roleId].Add(orgIdOrgMapping[roleOrgArray[3]]); } } } } //daoMgr.CommitTransaction(); } catch (Exception ex) { //daoMgr.RollBackTransaction(); throw ex; } return(roleOrgsDictionary); //} }