Exemplo n.º 1
0
        public static bool UpdateUser(IUser user)
        {
            bool result;

            if (null == user)
            {
                result = false;
            }
            else
            {
                bool flag = UserHelper.UpdateUser(user.MembershipUser);
                if (flag)
                {
                    UserFactory userFactory = UserFactory.Create(user.UserRole);
                    flag = userFactory.UpdateUser(user);
                    HiContext current = HiContext.Current;
                    if (current.User.UserId == user.UserId)
                    {
                        current.User = user;
                    }
                }
                Users.ClearUserCache(user);
                result = flag;
            }
            return(result);
        }
Exemplo n.º 2
0
        public static CreateUserStatus CreateUser(IUser user, string[] roles)
        {
            CreateUserStatus createUserStatus = UserHelper.Create(user.MembershipUser, roles);

            if (createUserStatus == CreateUserStatus.Created)
            {
                UserFactory userFactory = UserFactory.Create(user.UserRole);
                if (!userFactory.Create(user))
                {
                    HiMembership.Delete(user.Username);
                    createUserStatus = CreateUserStatus.UnknownFailure;
                }
            }
            return(createUserStatus);
        }
Exemplo n.º 3
0
        public static IUser GetUser(int userId, string username, bool isCacheable, bool userIsOnline)
        {
            IUser result;

            if (userId == 0 && !string.IsNullOrEmpty(username) && username.Equals("Anonymous", System.StringComparison.CurrentCultureIgnoreCase))
            {
                result = Users.GetAnonymousUser();
            }
            else
            {
                System.Collections.Hashtable hashtable = Users.UserCache();
                string key = (userId > 0) ? Users.UserKey(userId.ToString(System.Globalization.CultureInfo.InvariantCulture)) : Users.UserKey(username);
                if (isCacheable)
                {
                    IUser user = hashtable[key] as IUser;
                    if (user != null)
                    {
                        result = user;
                        return(result);
                    }
                }
                HiMembershipUser membershipUser = UserHelper.GetMembershipUser(userId, username, userIsOnline);
                if (membershipUser == null)
                {
                    result = Users.GetAnonymousUser();
                }
                else
                {
                    UserFactory userFactory = UserFactory.Create(membershipUser.UserRole);
                    IUser       user        = userFactory.GetUser(membershipUser);
                    if (isCacheable)
                    {
                        hashtable[Users.UserKey(user.Username)] = user;
                        hashtable[Users.UserKey(user.UserId.ToString(System.Globalization.CultureInfo.InvariantCulture))] = user;
                    }
                    result = user;
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        public static bool ValidTradePassword(IUser user)
        {
            UserFactory userFactory = UserFactory.Create(user.UserRole);

            return(userFactory.ValidTradePassword(user.Username, user.TradePassword));
        }