public List <SysCategory> GetSysCategoryAccordingRoleID()
        {
            var sysCateIDs = (from userRole in _userRoleRepository.GetAll()
                              join role in _roleRepository.GetAll() on userRole.RoleId equals role.Id
                              where userRole.UserId == AbpSession.UserId
                              select role.SysCateIDs).FirstOrDefault();
            List <SysCategory> sysList = new List <Log2Net.Models.SysCategory>();
            var ids = sysCateIDs.Split(',');

            if (ids.Contains(((int)(SysCategory.ALL)).ToString()))
            {
                sysList = ComClass.GetMySysCategory();
                sysList.Remove(SysCategory.ALL);
                return(sysList);
            }
            else
            {
                foreach (var item in ids)
                {
                    Log2Net.Models.SysCategory curEnum = (Log2Net.Models.SysCategory)Convert.ToInt32(item);
                    sysList.Add(curEnum);
                }
            }
            return(sysList);
        }
Exemplo n.º 2
0
 public static string GetMySystemName(Log2Net.Models.SysCategory sysCategory)
 {
     try
     {
         var dic = Log2Net.LogApi.GetLogWebApplicationsName();
         return(dic[sysCategory]);
     }
     catch
     {
         var curEnum = (int)sysCategory;
         return(sysCategory + "__" + curEnum);
     }
 }
Exemplo n.º 3
0
        //获取所有的系统名称的下拉列表
        public ActionResult GetAllApplicationList()
        {
            List <SelectListItem> tar = new List <SelectListItem>();
            var enumList = _roleAppService.GetSysCategoryAccordingRoleID();

            enumList.Insert(0, SysCategory.ALL);
            foreach (var item in enumList)
            {
                Log2Net.Models.SysCategory curEnum = item;
                var appName = Configuration.SysNameMap.GetMySystemName(curEnum);
                tar.Add(new SelectListItem()
                {
                    Text = appName + "[id=" + ((int)item).ToString() + "]", Value = ((int)item).ToString()
                });
            }
            return(AbpJson(tar, null, null, JsonRequestBehavior.AllowGet, true, false));
        }
        public List <Log2Net.Models.SysCategory> GetUserSysCategoryAccordingRoleID(long userId = -1)
        {
            var sysCateIDs = "";

            try
            {
                var allUsersSysCategory = _cacheManager.GetCache("LgWG.LogQuery").Get("UserSysCategorys", () => GetSysCategoryForAllFromDB()) as List <UserSysCategorys>;
                sysCateIDs = allUsersSysCategory.Where(a =>
                                                       (AbpSession.UserId != null && (long)a.UserID == (long)AbpSession.UserId) ||
                                                       ((long)a.UserID == userId)

                                                       ).FirstOrDefault().SysCateIDs;
            }
            catch
            {
                sysCateIDs = (from userRole in _userRoleRepository.GetAll()
                              join role in _roleRepository.GetAll() on userRole.RoleId equals role.Id
                              where (userRole.UserId == AbpSession.UserId || userRole.UserId == userId || AbpSession.UserId == null)
                              select role.SysCateIDs).FirstOrDefault();
            }

            List <SysCategory> sysList = new List <Log2Net.Models.SysCategory>();
            var ids = sysCateIDs.Split(',');

            if (ids.Contains(((int)(SysCategory.ALL)).ToString()))
            {
                sysList = ComClass.GetMySysCategory();
                sysList.Remove(SysCategory.ALL);
                return(sysList);
            }
            else
            {
                foreach (var item in ids)
                {
                    Log2Net.Models.SysCategory curEnum = (Log2Net.Models.SysCategory)Convert.ToInt32(item);
                    sysList.Add(curEnum);
                }
            }
            return(sysList);
        }