Esempio n. 1
0
        public IList <RoleInfo> GetRoles(int portalId)
        {
            var cacheKey = String.Format(DataCache.RolesCacheKey, portalId);

            return(CBO.GetCachedObject <IList <RoleInfo> >(
                       new CacheItemArgs(cacheKey, DataCache.RolesCacheTimeOut, DataCache.RolesCachePriority),
                       c => provider.GetRoles(portalId).Cast <RoleInfo>().ToList()));
        }
Esempio n. 2
0
        public IList <RoleInfo> GetRoles(int portalId)
        {
            var cacheKey = String.Format(DataCache.RolesCacheKey, portalId);

            return(CBO.GetCachedObject <IList <RoleInfo> >(new CacheItemArgs(cacheKey, DataCache.RolesCacheTimeOut, DataCache.RolesCachePriority, portalId),
                                                           c =>
            {
                var id = Convert.ToInt32(c.Params[0]);
                return provider.GetRoles(id).Cast <RoleInfo>().ToList();
            }));
        }
Esempio n. 3
0
        /// <summary>
        /// 从钉钉同步角色和用户
        /// </summary>
        /// <param name="DdOper"></param>
        public static void SyncUserRole(IDdOper DdOper)
        {
            SunginDataContext sc        = new SunginDataContext();
            UserProvider      uProvider = new UserProvider(DdOper);
            RoleProvider      rProvider = new RoleProvider(DdOper);

            RoleOper rOper = new RoleOper();
            UserOper uOper = new UserOper();

            var userList = DataQuery.GetAllRecords <User>();
            var roleList = rProvider.GetRoles("管理系统");

            rOper.UpdateRoles(roleList); //根据返回的roleList更新数据库

            List <IUserRole> urList = new List <IUserRole>();

            roleList.ForEach(role =>
            {
                var ruleUserList = rProvider.GetRoleUserList(role.RoleId);
                if (ruleUserList != null)
                {
                    ruleUserList.ForEach(u =>
                    {
                        var user = uProvider.GetUserInfo(u.Userid);
                        if (userList.Count(c => c.DdId == u.Userid) == 0)
                        {
                            //没有该用户,添加该用户
                            uOper.AddUser(user);
                        }
                        urList.Add(new UserRole
                        {
                            RoleId   = role.RoleId,
                            DdId     = u.Userid,
                            RoleName = role.RoleName,
                            UserName = user.UserName,
                        });
                    });
                }
            });

            new UrOper().UpdateRoles(urList); //同步UserRole表
        }
Esempio n. 4
0
        public ActionResult ListRole([DataSourceRequest] DataSourceRequest request)
        {
            var query = roleProvider.GetRoles();

            return(Json(query, JsonRequestBehavior.AllowGet));
        }