Beispiel #1
0
        /// <summary>
        /// 用户登出系统
        /// </summary>
        public static void SignOut()
        {
            String userName = UserManager.CurrentUserName;

            UserCurrentStatus.RemoveCurrentUserStatus();
            UserBrowserStatus.RemoveCurrentUserBrowserStatus();
            UserSubmitStatus.RemoveLastSubmitTime(userName);
            UserMailCache.RemoveUserUnReadMailCountCache(userName);
        }
Beispiel #2
0
        /// <summary>
        /// 当前在线用户列表
        /// </summary>
        /// <returns>当前在线用户列表</returns>
        public static IMethodResult AdminGetOnlineUserNames()
        {
            if (!AdminManager.HasPermission(PermissionType.SuperAdministrator))
            {
                throw new NoPermissionException();
            }

            List <String> list = UserMailCache.GetOnlineUserNames();

            return(MethodResult.Success(list));
        }
Beispiel #3
0
        /// <summary>
        /// 用户注销
        /// </summary>
        /// <returns>操作后的结果</returns>
        public ActionResult Logout()
        {
            String userName = UserManager.CurrentUserName;

            UserCurrentStatus.RemoveCurrentUserStatus();
            UserBrowserStatus.RemoveCurrentUserBrowserStatus();
            UserSubmitStatus.RemoveLastSubmitTime(userName);
            UserMailCache.RemoveUserUnReadMailCountCache(userName);

            return(RedirectToRefferer());
        }
Beispiel #4
0
        /// <summary>
        /// 发送用户邮件
        /// </summary>
        /// <param name="model">邮件实体</param>
        /// <returns>是否发送成功</returns>
        internal static Boolean InternalSendUserMail(UserMailEntity entity)
        {
            entity.SendDate  = DateTime.Now;
            entity.IsRead    = false;
            entity.IsDeleted = false;

            Int32 result = UserMailRepository.Instance.InsertEntity(entity);

            if (result > 0)
            {
                UserMailCache.RemoveUserUnReadMailCountCache(entity.ToUserName);//删除缓存
            }

            return(result > 0);
        }
Beispiel #5
0
        /// <summary>
        /// 获取用户邮件
        /// </summary>
        /// <param name="pageIndex">页面索引</param>
        /// <returns>用户邮件列表</returns>
        public static PagedList <UserMailEntity> GetUserMails(Int32 pageIndex)
        {
            if (!UserManager.IsUserLogined)
            {
                throw new UserUnLoginException();
            }

            Int32 pageSize    = UserMailManager.MAILBOX_PAGE_SIZE;
            Int32 recordCount = UserMailManager.CountUserMails();

            String userName = UserManager.CurrentUserName;

            UserMailCache.RemoveUserUnReadMailCountCache(userName);//删除缓存

            return(UserMailRepository.Instance
                   .GetEntities(userName, pageIndex, pageSize, recordCount)
                   .ToPagedList(pageSize, recordCount));
        }
Beispiel #6
0
        /// <summary>
        /// 更新一条邮件的状态
        /// </summary>
        /// <param name="model">对象实体</param>
        /// <returns>是否成功更新</returns>
        private static Boolean UpdateUserMailRead(UserMailEntity entity)
        {
            Boolean success = false;

            try
            {
                entity.IsRead = true;
                success       = UserMailRepository.Instance.UpdateEntityIsRead(entity) > 0;
            }
            finally
            {
                if (success)
                {
                    UserMailCache.RemoveUserUnReadMailCountCache(entity.ToUserName);//删除缓存
                }
            }

            return(success);
        }
Beispiel #7
0
        /// <summary>
        /// 获取未读邮件总数(有缓存)
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>未读邮件总数</returns>
        internal static Int32 InternalCountUserUnReadMails(String userName)
        {
            if (ConfigurationManager.AllowUserMail)
            {
                Int32 recordCount = UserMailCache.GetUserUnReadMailCountCache(userName);//获取缓存

                if (recordCount < 0)
                {
                    recordCount = UserMailRepository.Instance.CountUnReadEntities(userName);
                    UserMailCache.SetUserUnReadMailCountCache(userName, recordCount);//设置缓存
                }

                return(recordCount);
            }
            else
            {
                return(0);
            }
        }
Beispiel #8
0
        /// <summary>
        /// 删除指定ID的邮件
        /// </summary>
        /// <param name="ids">逗号分隔的邮件ID</param>
        /// <returns>是否成功删除</returns>
        public static Boolean DeleteUserMails(String ids)
        {
            if (!UserManager.IsUserLogined)
            {
                throw new UserUnLoginException();
            }

            if (!RegexVerify.IsNumericIDs(ids))
            {
                throw new InvalidRequstException(RequestType.UserMail);
            }

            String  userName = UserManager.CurrentUserName;
            Boolean success  = UserMailRepository.Instance.DeleteEntities(userName, ids) > 0;

            if (success)
            {
                UserMailCache.RemoveUserUnReadMailCountCache(userName);//删除缓存
            }

            return(success);
        }