Exemplo n.º 1
0
 public List <AppShortInfo> GetAppList()
 {
     return(AppManagerDb.GetAppList().ConvertAll(a => new AppShortInfo()
     {
         AppId = a.AppID, AppName = a.AppName
     }));
 }
Exemplo n.º 2
0
 private void Init()
 {
     Apps = AppManagerDb.GetAppList().ConvertAll(a => new AppShortInfo()
     {
         AppId = a.AppID, AppName = a.AppName, Domain = a.Domain
     });
 }
Exemplo n.º 3
0
        public List <AppShortInfo> GetAppListByUserId(int userId)
        {
            if (CommonAction.IsSysAdmin(userId))
            {
                return(AppManagerDb.GetAppList().ConvertAll(a => new AppShortInfo()
                {
                    AppId = a.AppID, AppName = a.AppName, Domain = a.Domain
                }));
            }

            var engine = PermissionDb.CreateEngine();

            //engine.Database.Log = log => System.Diagnostics.Debug.WriteLine(log);

            var roleIds    = engine.Esmart_Sys_User_Roles.Where(n => n.UserId == userId).Select(n => n.RoleId).ToArray();
            var userAppIds = ((from nav in engine.Esmart_Sys_Navigations
                               join roleNav in engine.Esmart_Sys_Role_Navigations on nav.NavigationId equals roleNav.NavigationId
                               where roleIds.Contains(roleNav.RoleId)
                               group nav by nav.AppId into appid
                               select appid.Key).Union
                                  (from nav in engine.Esmart_Sys_Navigations
                                  join userNav in engine.Esmart_Sys_User_Navigations on nav.NavigationId equals userNav.NavigationId
                                  where userNav.UserId == userId
                                  group nav by nav.AppId into appid
                                  select appid.Key)).ToList();
            var apps = AppManagerDb.GetAppList().Where(n => userAppIds.Contains(n.AppID));

            return(apps.Select(n => new AppShortInfo()
            {
                AppId = n.AppID, AppName = n.AppName, Domain = n.Domain
            }).ToList());
        }