Esempio n. 1
0
        /// <summary>
        /// Get all rights information
        /// </summary>
        /// <returns>List of right information</returns>
        public IList <RightsInfo> getRightsFullInfo()
        {
            IList <RightsInfo>      rightFullInfoList = new List <RightsInfo>();
            IList <Vrightsfullinfo> rightInfoList     = this.vrightsDao.FindAll();
            Hashtable infoTable = new Hashtable();

            foreach (Vrightsfullinfo rightInfoEntity in rightInfoList)
            {
                Rightgroup groupEntity = new Rightgroup();
                groupEntity.Id        = rightInfoEntity.GroupId;
                groupEntity.Groupname = rightInfoEntity.Groupname;
                RightBasicInfo rightBasicInfo = new RightBasicInfo();
                rightBasicInfo.RightId   = rightInfoEntity.RightId;
                rightBasicInfo.RightName = rightInfoEntity.Rightname;
                rightBasicInfo.RightUrl  = rightInfoEntity.Righturl;

                if (infoTable.ContainsKey(groupEntity.Id))
                {
                    LinkedList <RightBasicInfo> rightBasicInfoList = infoTable[groupEntity.Id] as LinkedList <RightBasicInfo>;
                    rightBasicInfoList.AddLast(rightBasicInfo);
                    infoTable[groupEntity.Id] = rightBasicInfoList;
                }
                else
                {
                    LinkedList <RightBasicInfo> rightBasicInfoList = new LinkedList <RightBasicInfo>();
                    rightBasicInfoList.AddLast(rightBasicInfo);
                    infoTable[groupEntity.Id] = rightBasicInfoList;
                }
            }
            foreach (long groupId in infoTable.Keys)
            {
                LinkedList <RightBasicInfo> rightBasicInfoList = infoTable[groupId] as LinkedList <RightBasicInfo>;
                RightsInfo rightsInfoEntity = new RightsInfo();// Includes RightGroup and its rights list.
                Rightgroup rightGroup       = new Rightgroup();
                rightGroup.Id = groupId;
                rightsInfoEntity.RightGroup = rightGroup;
                IList <Rights> rightList = new List <Rights>();
                foreach (RightBasicInfo rightBasicInfo in rightBasicInfoList)
                {
                    Rights rightsEntity = new Rights();
                    rightsEntity.Id        = rightBasicInfo.RightId;
                    rightsEntity.Rightname = rightBasicInfo.RightName;
                    rightsEntity.Righturl  = rightBasicInfo.RightUrl;
                    rightList.Add(rightsEntity);
                }
                rightsInfoEntity.RightList = rightList;
                rightFullInfoList.Add(rightsInfoEntity);
            }
            return(rightFullInfoList);
        }
Esempio n. 2
0
        /// <summary>
        /// Get all the rights of an user according to user ID.
        /// </summary>
        /// <param name="userId">User Id</param>
        /// <returns>right information list of an user.</returns>
        public LinkedList <RightsInfo> getRightsByUserId(int userId)
        {
            LinkedList <RightsInfo> rightsInfoList = new LinkedList <RightsInfo>();
            IList <Vuserrights>     userRightList  = this.userRightsDao.DescendOrderFindById(userId);
            Hashtable infoTable = new Hashtable();

            foreach (Vuserrights userRight in userRightList)
            {
                RightBasicInfo rightBasicInfo = new RightBasicInfo();
                rightBasicInfo.RightUrl  = userRight.Righturl;
                rightBasicInfo.RightName = userRight.Rightname;
                rightBasicInfo.RightId   = userRight.Rightid;
                rightBasicInfo.RightType = userRight.Righttype;
                if (infoTable.ContainsKey(userRight.Groupid))
                {
                    LinkedList <RightBasicInfo> rightBasicInfoList = infoTable[userRight.Groupid] as LinkedList <RightBasicInfo>;
                    rightBasicInfoList.AddLast(rightBasicInfo);
                    infoTable[userRight.Groupid] = rightBasicInfoList;
                }
                else
                {
                    LinkedList <RightBasicInfo> rightBasicInfoList = new LinkedList <RightBasicInfo>();
                    rightBasicInfoList.AddLast(rightBasicInfo);
                    infoTable[userRight.Groupid] = rightBasicInfoList;
                }
            }
            foreach (long groupId in infoTable.Keys)
            {
                RightsInfo rightsInfo = new RightsInfo();

                LinkedList <RightBasicInfo> rightBasicInfoList = infoTable[groupId] as LinkedList <RightBasicInfo>;
                Rightgroup rightGroup = new Rightgroup();
                rightGroup.Id         = groupId;
                rightsInfo.RightGroup = rightGroup;
                IList <Rights> rightList = new List <Rights>();
                foreach (RightBasicInfo rightBasicInfo in rightBasicInfoList)
                {
                    Rights rightPojo = new Rights();
                    rightPojo.Rightname = rightBasicInfo.RightName;
                    rightPojo.Righturl  = rightBasicInfo.RightUrl;
                    rightPojo.Id        = rightBasicInfo.RightId;
                    rightList.Add(rightPojo);
                }
                rightsInfo.RightList = rightList;
                rightsInfoList.AddLast(rightsInfo);
            }
            return(rightsInfoList);
        }