Пример #1
0
 /// <summary>
 /// 添加操作记录(不与数据库进行交互)
 /// </summary>
 /// <param name="actionType">操作动作类型(1:增,2:修改,3:查看,4:删除)</param>
 /// <param name="title">操作标题</param>
 /// <param name="content">操作内容</param>
 public static void AddOperation(int actionType, string title, string content)
 {
     AuthorDesign.Model.AdminOperation operation = new Model.AdminOperation()
     {
         Action       = actionType,
         AdminId      = WebCookieHelper.GetAdminId(0),
         AuthoryId    = WebCookieHelper.GetAdminId(6),
         Content      = content,
         CreateTime   = DateTime.Now,
         IsSuperAdmin = (byte)WebCookieHelper.GetAdminId(5),
         Title        = title,
         OperateIP    = IpHelper.GetRealIP(),
         OperateInfo  = IpHelper.GetBrowerVersion()
     };
     operation.OperateAddress = IpHelper.GetAdrByIp(operation.OperateIP);
     EnterRepository.GetRepositoryEnter().GetAdminOperationRepository.AddEntity(operation);
 }
        /// <summary>
        /// 获取权限选择框列表
        /// </summary>
        /// <param name="nowId">当前权限Id</param>
        /// <returns></returns>
        public static IEnumerable <SelectListItem> GetRoleItemList(int nowId)
        {
            IEnumerable <Model.Authory> authoryEnu = EnterRepository.GetRepositoryEnter().GetAuthoryRepository.LoadAllRole();
            List <SelectListItem>       itemList   = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = "请选择权限", Value = "-1"
                }
            };

            foreach (var item in authoryEnu)
            {
                itemList.Add(new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = item.Name, Selected = item.Id == nowId
                });
            }
            return(itemList);
        }
Пример #3
0
 /// <summary>
 /// 获取管理员可操作菜单列表
 /// </summary>
 /// <param name="adminId">管理员Id</param>
 /// <returns></returns>
 public static List <Model.AdminPageAction> GetAdminMenu(int adminId)
 {
     if (CacheHelper.IsExistCache("AdminMenuList"))
     {
         Dictionary <int, List <Model.AdminPageAction> > adminMenuListDic = CacheHelper.GetCache("AdminMenuList") as Dictionary <int, List <Model.AdminPageAction> >;
         if (adminMenuListDic[adminId] != null)
         {
             List <Model.AdminPageAction> adminMenuList = adminMenuListDic[adminId];
             if (adminMenuList == null)
             {
                 adminMenuList = EnterRepository.GetRepositoryEnter().GetPageMenuRepository.GetAdminShowPage(adminId);
                 adminMenuListDic.Add(adminId, adminMenuList);
                 CacheHelper.AddCache("AdminMenuList", adminMenuListDic, 2);
             }
             return(adminMenuList);
         }
         else
         {
             return(adminMenuListDic[adminId]);
         }
     }
     else
     {
         List <Model.AdminPageAction> adminMenuList = EnterRepository.GetRepositoryEnter().GetPageMenuRepository.GetAdminShowPage(adminId);
         Dictionary <int, List <Model.AdminPageAction> > adminMenuListDic = new Dictionary <int, List <Model.AdminPageAction> >();
         adminMenuListDic.Add(adminId, adminMenuList);
         CacheHelper.AddCache("AdminMenuList", adminMenuListDic, 2);
         return(adminMenuList);
     }
     //if (CacheHelper.IsExistCache("AdminMenuList_"+adminId)) {
     //    return CacheHelper.GetCache("AdminMenuList_" + adminId) as List<Model.AdminPageAction>;
     //}
     //else {
     //    List<Model.AdminPageAction> adminMenuList = EnterRepository.GetRepositoryEnter().GetPageMenuRepository.GetAdminShowPage(adminId);
     //    CacheHelper.AddCache("AdminMenuList_" + adminId, adminMenuList, 1);
     //    return adminMenuList;
     //}
     //return EnterRepository.GetRepositoryEnter().GetPageMenuRepository.GetAdminShowPage(adminId);
 }