コード例 #1
0
        public static void GrantDAuthsToGroups(IList <DynamicAuth> auths, IList <string> groupIDs, IList <string> operations, string tag, string granterID, string granterName)
        {
            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    IList <DynamicPermission> dps = GrantDAuths(auths, groupIDs, operations, DynamicPermissionCatalog.SysCatalogEnum.SYS_GROUP.ToString(), tag, granterID, granterName);
                    SysGroup[] grps = SysGroup.FindAll(Expression.In("GroupID", groupIDs.ToList()));

                    foreach (DynamicPermission tdp in dps)
                    {
                        IEnumerable <SysGroup> tgrps = grps.Where(tent => tent.GroupID == tdp.Data);

                        if (tgrps.Count() > 0)
                        {
                            SysGroup tgrp = tgrps.First();

                            tdp.Name = tgrp.Name;
                            tdp.Tag  = tgrp.Type.ToString();
                        }

                        tdp.Update();
                    }

                    trans.VoteCommit();
                }
                catch (Exception ex)
                {
                    trans.VoteRollBack();
                    throw ex;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 获取用户所属组(/*当你属于某个子组是,你将属于所有父组(暂不考虑)*/)
        /// </summary>
        /// <returns></returns>
        public IList <SysGroup> RetrieveAllGroup()
        {
            IList <SysGroup> groups = this.Group;

            List <string> groupIDs = new List <string>();

            foreach (SysGroup sg in groups)
            {
                if (sg.Path != null)
                {
                    string[] paths = sg.Path.Split('.');
                    foreach (string p in paths)
                    {
                        if (!groupIDs.Contains(p))
                        {
                            groupIDs.Add(p);
                        }
                    }
                }
            }

            ICriterion hqlCriterion = Expression.In("GroupID", groupIDs);

            groups = (SysGroup[])SysGroup.FindAll(hqlCriterion);

            return(groups);
        }
コード例 #3
0
        /// <summary>
        /// 由ID集合获取权限集合
        /// </summary>
        /// <param name="authIDs"></param>
        /// <returns></returns>
        public static ICollection <SysGroup> GetGroupByIDs(ICollection ids)
        {
            ICollection myIDs = null;

            if (ids is JArray)
            {
                JArray arr = ids as JArray;
                myIDs = new List <string>(arr.Values <string>());
            }
            else
            {
                myIDs = ids;
            }

            SysGroup[] tEnts = SysGroup.FindAll(Expression.In("GroupID", myIDs));

            return(tEnts);
        }