public void SignIn(string loginName, string password, bool rememberMe = false)
        {
            var user = AuthService.Login(loginName, password, true);

            var authUser = GetAuthUserFromDb(user);

            var dataToken = new UserToken()
            {
                UserId = user.Id, LastLoginToken = user.LastLoginToken
            }.GetAuthToken();

            // Cache
            SetCacheAuthUser(dataToken, authUser);

            // Cookies
            RegisterToken(dataToken, authUser.UserName, rememberMe);

            #region 操作日志

            OperateLogService.RecordOperation(user.Id.ToString(),
                                              string.Format("{0}", MessagesResources.Login),
                                              MessagesResources.Login_Success,
                                              user,
                                              true);

            #endregion
        }
        public void SignOut()
        {
            try
            {
                var token = this.GetCurrentTokenFromCookies();

                UserDTO user = null;
                try
                {
                    var authUser = GetCurrentUserInfo();
                    if (authUser != null)
                    {
                        user = new UserDTO()
                        {
                            Id        = authUser.UserId,
                            Name      = authUser.UserName,
                            LoginName = authUser.LoginName
                        };
                    }
                }
                catch (Exception ex)
                {
                    //throw;
                }

                RemoveToken(token, user);

                FormsAuthentication.SignOut();

                if (user != null)
                {
                    #region 操作日志

                    OperateLogService.RecordOperation(user.Id.ToString(),
                                                      string.Format("{0}", MessagesResources.Logout),
                                                      MessagesResources.Logout_Success,
                                                      user,
                                                      true);

                    #endregion
                }
            }
            catch (AuthorizeTokenNotFoundException)
            {
                return;
            }
        }