Пример #1
0
        public static IUser GetUser(int userId, string username, bool isCacheable, bool userIsOnline)
        {
            if (userId == 0 && username == "Anonymous")
            {
                return(Users.GetAnonymousUser());
            }
            System.Collections.Hashtable hashtable = Users.smethod_0();
            string key = (userId > 0) ? Users.smethod_1(userId.ToString()) : Users.smethod_1(username);
            IUser  user;

            if (isCacheable)
            {
                user = (hashtable[key] as IUser);
                if (user != null)
                {
                    return(user);
                }
            }
            HiMembershipUser membershipUser = UserHelper.GetMembershipUser(userId, username, userIsOnline);

            if (membershipUser == null)
            {
                return(Users.GetAnonymousUser());
            }
            user = Class0.smethod_0(membershipUser.UserRole).vmethod_3(membershipUser);
            if (isCacheable)
            {
                hashtable[Users.smethod_1(user.Username)]          = user;
                hashtable[Users.smethod_1(user.UserId.ToString())] = user;
            }
            return(user);
        }
Пример #2
0
        public override bool UpdateMembershipUser(HiMembershipUser user)
        {
            bool result;

            if (user == null)
            {
                result = false;
            }
            else
            {
                try
                {
                    HiMembership.Update(user.Membership);
                }
                catch
                {
                    result = false;
                    return(result);
                }
                System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_Users SET MobilePIN = @MobilePIN, Gender = @Gender, BirthDate = @BirthDate WHERE UserId = @UserId");
                this.database.AddInParameter(sqlStringCommand, "MobilePIN", System.Data.DbType.String, user.MobilePIN);
                this.database.AddInParameter(sqlStringCommand, "Gender", System.Data.DbType.Int32, (int)user.Gender);
                this.database.AddInParameter(sqlStringCommand, "BirthDate", System.Data.DbType.DateTime, user.BirthDate);
                this.database.AddInParameter(sqlStringCommand, "UserId", System.Data.DbType.Int32, user.UserId);
                result = (this.database.ExecuteNonQuery(sqlStringCommand) == 1);
            }
            return(result);
        }
Пример #3
0
        public static IUser GetUser(int userId, string username, bool isCacheable, bool userIsOnline)
        {
            if ((userId == 0) && (username == "Anonymous"))
            {
                return(GetAnonymousUser());
            }
            Hashtable hashtable = UserCache();
            string    str       = (userId > 0) ? UserKey(userId.ToString(CultureInfo.InvariantCulture)) : UserKey(username);
            IUser     user      = null;

            if (isCacheable)
            {
                user = hashtable[str] as IUser;
                if (user != null)
                {
                    return(user);
                }
            }
            HiMembershipUser membershipUser = UserHelper.GetMembershipUser(userId, username, userIsOnline);

            if (membershipUser == null)
            {
                return(GetAnonymousUser());
            }
            user = UserFactory.Create(membershipUser.UserRole).GetUser(membershipUser);
            if (isCacheable)
            {
                hashtable[UserKey(user.Username)] = user;
                hashtable[UserKey(user.UserId.ToString(CultureInfo.InvariantCulture))] = user;
            }
            return(user);
        }
Пример #4
0
        public static IUser GetSupplierUser(int userId, string username, bool isCacheable, bool userIsOnline)
        {
            if (((userId == 0) && !string.IsNullOrEmpty(username)) && username.Equals("Anonymous", StringComparison.CurrentCultureIgnoreCase))
            {
                return(GetAnonymousUser());
            }
            Hashtable hashtable = UserCache();
            string    str       = (userId > 0) ? UserKey(userId.ToString(CultureInfo.InvariantCulture)) : UserKey(username);
            IUser     user      = null;

            if (isCacheable)
            {
                user = hashtable[str] as IUser;
                if (user != null)
                {
                    return(user);
                }
            }
            HiMembershipUser membershipUser = UserHelper.GetMembershipUser(userId, username, userIsOnline);

            if (membershipUser == null)
            {
                return(GetAnonymousUser());
            }
            user = ManagerFactory.Instance().GetUser(membershipUser);
            if (isCacheable)
            {
                hashtable[UserKey(user.Username)] = user;
                hashtable[UserKey(user.Password)] = user;
                hashtable[UserKey(user.UserId.ToString(CultureInfo.InvariantCulture))] = user;
            }
            return(user);
        }
Пример #5
0
 public Member(Hidistro.Membership.Core.Enums.UserRole userRole, HiMembershipUser membershipUser)
 {
     if ((userRole != Hidistro.Membership.Core.Enums.UserRole.Member) && (userRole != Hidistro.Membership.Core.Enums.UserRole.Underling))
     {
         throw new Exception("UserRole must be Member or Underling");
     }
     this.MembershipUser = membershipUser;
 }
Пример #6
0
 public StoreAdmin(Hidistro.Membership.Core.Enums.UserRole userRole, HiMembershipUser membershipUser)
 {
     if (userRole != Hidistro.Membership.Core.Enums.UserRole.StoreAdmin)
     {
         throw new Exception("UserRole must be Member or Underling");
     }
     this.MembershipUser = membershipUser;
 }
Пример #7
0
 public Member(UserRole userRole, HiMembershipUser membershipUser)
 {
     if (userRole != UserRole.Member && userRole != UserRole.Underling)
     {
         throw new System.Exception("UserRole must be Member or Underling");
     }
     this.MembershipUser = membershipUser;
 }
Пример #8
0
        public override AnonymousUser GetAnonymousUser()
        {
            System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT @UserId = UserId FROM aspnet_Users WHERE IsAnonymous = 1");
            this.database.AddOutParameter(sqlStringCommand, "UserId", System.Data.DbType.Int32, 4);
            this.database.ExecuteNonQuery(sqlStringCommand);
            int userId = (int)this.database.GetParameterValue(sqlStringCommand, "UserId");
            HiMembershipUser membershipUser = this.GetMembershipUser(userId, "Anonymous", true);

            return(new AnonymousUser(membershipUser));
        }
Пример #9
0
        public override SiteManager GetManager(HiMembershipUser membershipUser)
        {
            SiteManager manager          = null;
            DbCommand   sqlStringCommand = this.database.GetSqlStringCommand("SELECT COUNT(UserId) FROM aspnet_Managers WHERE UserId = @UserId");

            this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, membershipUser.UserId);
            if (Convert.ToInt32(this.database.ExecuteScalar(sqlStringCommand)) == 1)
            {
                manager = new SiteManager(membershipUser);
            }
            return(manager);
        }
Пример #10
0
        public override HiMembershipUser GetMembershipUser(int userId, string username, bool isOnline)
        {
            MembershipUser mu = string.IsNullOrEmpty(username)
                ? HiMembership.GetUser(userId, isOnline)
                : HiMembership.GetUser(username, isOnline);

            if (mu == null)
            {
                return(null);
            }
            HiMembershipUser user2            = null;
            DbCommand        sqlStringCommand = null;

            if (!string.IsNullOrEmpty(username))
            {
                sqlStringCommand =
                    this.database.GetSqlStringCommand(
                        "SELECT MobileAlias, IsAnonymous FROM aspnet_Users WHERE LoweredUserName = LOWER(@Username)");
                this.database.AddInParameter(sqlStringCommand, "Username", DbType.String, username);
            }
            else
            {
                sqlStringCommand =
                    this.database.GetSqlStringCommand(
                        "SELECT MobilePIN, IsAnonymous, Gender, BirthDate, UserRole FROM aspnet_Users WHERE UserId = @UserId");
                this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, userId);
            }
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    user2 = new HiMembershipUser((bool)reader["IsAnonymous"],
                                                 UserRole.SiteManager, mu);
                    if (reader["MobilePIN"] != DBNull.Value)
                    {
                        user2.MobilePIN = (string)reader["MobilePIN"];
                    }
                    if (reader["Gender"] != DBNull.Value)
                    {
                        user2.Gender = (Gender)Convert.ToInt32(reader["Gender"]);
                    }
                    if (reader["BirthDate"] != DBNull.Value)
                    {
                        user2.BirthDate = new DateTime?((DateTime)reader["BirthDate"]);
                    }
                }
                reader.Close();
            }
            return(user2);
        }
Пример #11
0
        public override HiMembershipUser GetMembershipUser(int userId, string username, bool isOnline)
        {
            MembershipUser   membershipUser = string.IsNullOrEmpty(username) ? HiMembership.GetUser(userId, isOnline) : HiMembership.GetUser(username, isOnline);
            HiMembershipUser result;

            if (membershipUser == null)
            {
                result = null;
            }
            else
            {
                HiMembershipUser             hiMembershipUser = null;
                System.Data.Common.DbCommand sqlStringCommand;
                if (!string.IsNullOrEmpty(username))
                {
                    sqlStringCommand = this.database.GetSqlStringCommand("SELECT MobilePIN, IsAnonymous, Gender, BirthDate, UserRole FROM aspnet_Users WHERE LoweredUserName = LOWER(@Username)");
                    this.database.AddInParameter(sqlStringCommand, "Username", System.Data.DbType.String, username);
                }
                else
                {
                    sqlStringCommand = this.database.GetSqlStringCommand("SELECT MobilePIN, IsAnonymous, Gender, BirthDate, UserRole FROM aspnet_Users WHERE UserId = @UserId");
                    this.database.AddInParameter(sqlStringCommand, "UserId", System.Data.DbType.Int32, userId);
                }
                using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
                {
                    if (dataReader.Read())
                    {
                        hiMembershipUser = new HiMembershipUser((bool)dataReader["IsAnonymous"], (UserRole)Convert.ToInt32(dataReader["UserRole"]), membershipUser);
                        if (dataReader["MobilePIN"] != DBNull.Value)
                        {
                            hiMembershipUser.MobilePIN = (string)dataReader["MobilePIN"];
                        }
                        if (dataReader["Gender"] != DBNull.Value)
                        {
                            hiMembershipUser.Gender = (Gender)Convert.ToInt32(dataReader["Gender"]);
                        }
                        if (dataReader["BirthDate"] != DBNull.Value)
                        {
                            hiMembershipUser.BirthDate = new DateTime?((DateTime)dataReader["BirthDate"]);
                        }
                    }
                    dataReader.Close();
                }
                result = hiMembershipUser;
            }
            return(result);
        }
Пример #12
0
        public static IUser GetUser(int userId, string username, bool isCacheable, bool userIsOnline)
        {
            IUser user = null;

            try
            {
                if (((userId == 0) && !string.IsNullOrEmpty(username)) && username.Equals("Anonymous", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(GetAnonymousUser());
                }
                Hashtable hashtable = UserCache();

                string str = (userId > 0) ? UserKey(userId.ToString(CultureInfo.InvariantCulture)) : UserKey(username);

                if (isCacheable)
                {
                    user = hashtable[str] as IUser;
                    if (user != null)
                    {
                        return(user);
                    }
                }

                HiMembershipUser membershipUser = UserHelper.GetMembershipUser(userId, username, userIsOnline);

                if (membershipUser == null)
                {
                    return(GetAnonymousUser());
                }
                user = UserFactory.Create(membershipUser.UserRole).GetUser(membershipUser);
                if (isCacheable)
                {
                    hashtable[UserKey(user.Username)] = user;
                    hashtable[UserKey(user.UserId.ToString(CultureInfo.InvariantCulture))] = user;
                }
            }
            catch (Exception e)
            {
                log.GetInstance().writeLog(e.Message.ToString());
                throw;
            }
            return(user);
        }
Пример #13
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);
        }
Пример #14
0
 public override IUser GetUser(HiMembershipUser membershipUser)
 {
     return(this.provider.GetUnderling(membershipUser));
 }
Пример #15
0
 public Distributor(HiMembershipUser membershipUser)
 {
     this.MembershipUser = membershipUser;
 }
Пример #16
0
 public SiteManager(HiMembershipUser membershipUser)
 {
     this.MembershipUser = membershipUser;
 }
Пример #17
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.ValidationInput())
            {
                int?selectedRegionId            = this.dropRegion.GetSelectedRegionId();
                HiMembershipUser membershipUser = new HiMembershipUser(false, UserRole.Distributor);
                Distributor      distributor    = new Distributor(membershipUser);
                distributor.IsApproved = false;
                distributor.Username   = this.txtUserName.Text;
                distributor.Email      = this.txtEmail.Text;
                distributor.Password   = this.txtPasswordCompare.Text;
                if (!string.IsNullOrEmpty(this.txtTransactionPasswordCompare.Text))
                {
                    distributor.TradePassword = this.txtTransactionPasswordCompare.Text;
                }
                else
                {
                    distributor.TradePassword = distributor.Password;
                }
                distributor.RealName    = this.txtRealName.Text;
                distributor.CompanyName = this.txtCompanyName.Text;
                if (selectedRegionId.HasValue)
                {
                    distributor.RegionId    = selectedRegionId.Value;
                    distributor.TopRegionId = RegionHelper.GetTopRegionId(distributor.RegionId);
                }
                distributor.Address   = this.txtAddress.Text;
                distributor.Zipcode   = this.txtZipcode.Text;
                distributor.QQ        = this.txtQQ.Text;
                distributor.Wangwang  = this.txtWangwang.Text;
                distributor.MSN       = this.txtMSN.Text;
                distributor.TelPhone  = this.txtTelPhone.Text;
                distributor.CellPhone = this.txtCellPhone.Text;
                distributor.Remark    = string.Empty;
                if (this.ValidationDistributorRequest(distributor))
                {
                    switch (SubsiteStoreHelper.CreateDistributor(distributor))
                    {
                    case CreateUserStatus.UnknownFailure:
                        this.ShowMessage("未知错误", false);
                        return;

                    case CreateUserStatus.Created:
                        distributor.ChangePasswordQuestionAndAnswer(null, this.txtPasswordQuestion.Text, this.txtPasswordAnswer.Text);
                        Messenger.UserRegister(distributor, this.txtPasswordCompare.Text);
                        distributor.OnRegister(new UserEventArgs(distributor.Username, this.txtPasswordCompare.Text, null));
                        this.Page.Response.Redirect(Globals.ApplicationPath + "/Shopadmin/DistributorsRegisterComplete.aspx");
                        return;

                    case CreateUserStatus.DuplicateUsername:
                        this.ShowMessage("您输入的用户名已经被注册使用", false);
                        return;

                    case CreateUserStatus.DuplicateEmailAddress:
                        this.ShowMessage("您输入的电子邮件地址已经被注册使用", false);
                        return;

                    case CreateUserStatus.InvalidFirstCharacter:
                    case CreateUserStatus.Updated:
                    case CreateUserStatus.Deleted:
                    case CreateUserStatus.InvalidQuestionAnswer:
                        return;

                    case CreateUserStatus.DisallowedUsername:
                        this.ShowMessage("用户名被禁止注册", false);
                        return;

                    case CreateUserStatus.InvalidPassword:
                        this.ShowMessage("无效的密码", false);
                        return;

                    case CreateUserStatus.InvalidEmail:
                        this.ShowMessage("无效的电子邮件地址", false);
                        return;
                    }
                }
            }
        }
Пример #18
0
 public override IUser vmethod_3(HiMembershipUser hiMembershipUser_0)
 {
     return(this.bizActorProvider_0.GetManager(hiMembershipUser_0));
 }
Пример #19
0
 public override IUser GetUser(HiMembershipUser membershipUser)
 {
     return(this.provider.GetSupplier(membershipUser));
 }
Пример #20
0
 public Distributor()
 {
     MembershipUser = new HiMembershipUser(false, Hidistro.Membership.Core.Enums.UserRole.Distributor);
 }
Пример #21
0
 public abstract Distributor GetDistributor(HiMembershipUser membershipUser);
Пример #22
0
 public abstract Member GetUnderling(HiMembershipUser membershipUser);
Пример #23
0
        public override Distributor GetDistributor(HiMembershipUser membershipUser)
        {
            Distributor distributor      = null;
            DbCommand   sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM aspnet_Distributors WHERE UserId = @UserId");

            this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, membershipUser.UserId);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (!reader.Read())
                {
                    return(distributor);
                }
                distributor = new Distributor(membershipUser)
                {
                    GradeId             = (int)reader["GradeId"],
                    TradePassword       = (string)reader["TradePassword"],
                    TradePasswordFormat = (MembershipPasswordFormat)((int)reader["TradePasswordFormat"]),
                    PurchaseOrder       = (int)reader["PurchaseOrder"],
                    Expenditure         = (decimal)reader["Expenditure"],
                    Balance             = (decimal)reader["Balance"],
                    RequestBalance      = (decimal)reader["RequestBalance"],
                    MemberCount         = (int)reader["MemberCount"]
                };
                if (reader["TopRegionId"] != DBNull.Value)
                {
                    distributor.TopRegionId = (int)reader["TopRegionId"];
                }
                if (reader["RegionId"] != DBNull.Value)
                {
                    distributor.RegionId = (int)reader["RegionId"];
                }
                if (reader["RealName"] != DBNull.Value)
                {
                    distributor.RealName = (string)reader["RealName"];
                }
                if (reader["CompanyName"] != DBNull.Value)
                {
                    distributor.CompanyName = (string)reader["CompanyName"];
                }
                if (reader["Address"] != DBNull.Value)
                {
                    distributor.Address = (string)reader["Address"];
                }
                if (reader["Zipcode"] != DBNull.Value)
                {
                    distributor.Zipcode = (string)reader["Zipcode"];
                }
                if (reader["TelPhone"] != DBNull.Value)
                {
                    distributor.TelPhone = (string)reader["TelPhone"];
                }
                if (reader["CellPhone"] != DBNull.Value)
                {
                    distributor.CellPhone = (string)reader["CellPhone"];
                }
                if (reader["QQ"] != DBNull.Value)
                {
                    distributor.QQ = (string)reader["QQ"];
                }
                if (reader["Wangwang"] != DBNull.Value)
                {
                    distributor.Wangwang = (string)reader["Wangwang"];
                }
                if (reader["MSN"] != DBNull.Value)
                {
                    distributor.MSN = (string)reader["MSN"];
                }
                if (reader["Remark"] != DBNull.Value)
                {
                    distributor.Remark = (string)reader["Remark"];
                }
            }
            return(distributor);
        }
Пример #24
0
 public abstract Member GetMember(HiMembershipUser membershipUser);
Пример #25
0
 public abstract SiteManager GetManager(HiMembershipUser membershipUser);
Пример #26
0
        public override CreateUserStatus CreateMembershipUser(HiMembershipUser userToCreate, string passwordQuestion, string passwordAnswer)
        {
            CreateUserStatus unknownFailure = CreateUserStatus.UnknownFailure;

            if (userToCreate == null)
            {
                return(CreateUserStatus.UnknownFailure);
            }
            bool flag = false;

            if (!string.IsNullOrEmpty(passwordQuestion) && !string.IsNullOrEmpty(passwordAnswer))
            {
                flag = true;
                if ((passwordAnswer.Length > 0x80) || (passwordQuestion.Length > 0x100))
                {
                    throw new CreateUserException(CreateUserStatus.InvalidQuestionAnswer);
                }
            }
            MembershipUser user = HiMembership.Create(userToCreate.Username, userToCreate.Password, userToCreate.Email);

            if (user != null)
            {
                userToCreate.UserId = (int)user.ProviderUserKey;
                DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_Users SET IsAnonymous = @IsAnonymous, IsApproved = @IsApproved, PasswordQuestion = @PasswordQuestion, PasswordAnswer = @PasswordAnswer, Gender = @Gender, BirthDate = @BirthDate, UserRole = @UserRole WHERE UserId = @UserId");
                this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, userToCreate.UserId);
                this.database.AddInParameter(sqlStringCommand, "IsAnonymous", DbType.Boolean, userToCreate.IsAnonymous);
                this.database.AddInParameter(sqlStringCommand, "IsApproved", DbType.Boolean, userToCreate.IsApproved);
                this.database.AddInParameter(sqlStringCommand, "Gender", DbType.Int32, (int)userToCreate.Gender);
                this.database.AddInParameter(sqlStringCommand, "BirthDate", DbType.DateTime, null);
                this.database.AddInParameter(sqlStringCommand, "UserRole", DbType.Int32, (int)userToCreate.UserRole);
                this.database.AddInParameter(sqlStringCommand, "PasswordQuestion", DbType.String, null);
                this.database.AddInParameter(sqlStringCommand, "PasswordAnswer", DbType.String, null);
                if (userToCreate.BirthDate.HasValue)
                {
                    this.database.SetParameterValue(sqlStringCommand, "BirthDate", userToCreate.BirthDate.Value);
                }
                if (flag)
                {
                    string str2 = null;
                    try
                    {
                        int    num;
                        int    num2;
                        string str;
                        this.GetPasswordWithFormat(userToCreate.Username, false, out num2, out num, out str);
                        if (num2 == 0)
                        {
                            str2 = UserHelper.EncodePassword((MembershipPasswordFormat)num, passwordAnswer, str);
                            this.database.SetParameterValue(sqlStringCommand, "PasswordQuestion", passwordQuestion);
                            this.database.SetParameterValue(sqlStringCommand, "PasswordAnswer", str2);
                        }
                        if ((num2 != 0) || (!string.IsNullOrEmpty(str2) && (str2.Length > 0x80)))
                        {
                            HiMembership.Delete(userToCreate.Username);
                            throw new CreateUserException(CreateUserStatus.InvalidQuestionAnswer);
                        }
                    }
                    catch
                    {
                        HiMembership.Delete(userToCreate.Username);
                        throw new CreateUserException(CreateUserStatus.UnknownFailure);
                    }
                }
                if (this.database.ExecuteNonQuery(sqlStringCommand) == 1)
                {
                    unknownFailure = CreateUserStatus.Created;
                }
                else
                {
                    HiMembership.Delete(userToCreate.Username);
                    throw new CreateUserException(unknownFailure);
                }
            }
            return(unknownFailure);
        }
Пример #27
0
        public override CreateUserStatus CreateMembershipUser(HiMembershipUser userToCreate, string passwordQuestion, string passwordAnswer)
        {
            CreateUserStatus createUserStatus = CreateUserStatus.UnknownFailure;
            CreateUserStatus result;

            if (userToCreate == null)
            {
                result = CreateUserStatus.UnknownFailure;
            }
            else
            {
                bool flag = false;
                if (!string.IsNullOrEmpty(passwordQuestion) && !string.IsNullOrEmpty(passwordAnswer))
                {
                    flag = true;
                    if (passwordAnswer.Length > 128 || passwordQuestion.Length > 256)
                    {
                        throw new CreateUserException(CreateUserStatus.InvalidQuestionAnswer);
                    }
                }
                MembershipUser membershipUser = HiMembership.Create(userToCreate.Username, userToCreate.Password, userToCreate.Email);
                if (membershipUser != null)
                {
                    userToCreate.UserId = (int)membershipUser.ProviderUserKey;
                    System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_Users SET IsAnonymous = @IsAnonymous, IsApproved = @IsApproved, PasswordQuestion = @PasswordQuestion, PasswordAnswer = @PasswordAnswer, Gender = @Gender, BirthDate = @BirthDate, UserRole = @UserRole WHERE UserId = @UserId");
                    this.database.AddInParameter(sqlStringCommand, "UserId", System.Data.DbType.Int32, userToCreate.UserId);
                    this.database.AddInParameter(sqlStringCommand, "IsAnonymous", System.Data.DbType.Boolean, userToCreate.IsAnonymous);
                    this.database.AddInParameter(sqlStringCommand, "IsApproved", System.Data.DbType.Boolean, userToCreate.IsApproved);
                    this.database.AddInParameter(sqlStringCommand, "Gender", System.Data.DbType.Int32, (int)userToCreate.Gender);
                    this.database.AddInParameter(sqlStringCommand, "BirthDate", System.Data.DbType.DateTime, null);
                    this.database.AddInParameter(sqlStringCommand, "UserRole", System.Data.DbType.Int32, (int)userToCreate.UserRole);
                    this.database.AddInParameter(sqlStringCommand, "PasswordQuestion", System.Data.DbType.String, null);
                    this.database.AddInParameter(sqlStringCommand, "PasswordAnswer", System.Data.DbType.String, null);
                    if (userToCreate.BirthDate.HasValue)
                    {
                        this.database.SetParameterValue(sqlStringCommand, "BirthDate", userToCreate.BirthDate.Value);
                    }
                    if (flag)
                    {
                        string text = null;
                        try
                        {
                            int    num;
                            int    format;
                            string salt;
                            this.GetPasswordWithFormat(userToCreate.Username, false, out num, out format, out salt);
                            if (num == 0)
                            {
                                text = UserHelper.EncodePassword((MembershipPasswordFormat)format, passwordAnswer, salt);
                                this.database.SetParameterValue(sqlStringCommand, "PasswordQuestion", passwordQuestion);
                                this.database.SetParameterValue(sqlStringCommand, "PasswordAnswer", text);
                            }
                            if (num != 0 || (!string.IsNullOrEmpty(text) && text.Length > 128))
                            {
                                HiMembership.Delete(userToCreate.Username);
                                throw new CreateUserException(CreateUserStatus.InvalidQuestionAnswer);
                            }
                        }
                        catch
                        {
                            HiMembership.Delete(userToCreate.Username);
                            throw new CreateUserException(CreateUserStatus.UnknownFailure);
                        }
                    }
                    if (this.database.ExecuteNonQuery(sqlStringCommand) != 1)
                    {
                        HiMembership.Delete(userToCreate.Username);
                        throw new CreateUserException(createUserStatus);
                    }
                    createUserStatus = CreateUserStatus.Created;
                }
                result = createUserStatus;
            }
            return(result);
        }
Пример #28
0
        public override Member GetUnderling(HiMembershipUser membershipUser)
        {
            Member    member           = null;
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM distro_Members WHERE UserId = @UserId");

            this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, membershipUser.UserId);
            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (!reader.Read())
                {
                    return(member);
                }
                member = new Member(UserRole.Underling, membershipUser)
                {
                    GradeId      = (int)reader["GradeId"],
                    ParentUserId = new int?((int)reader["ParentUserId"])
                };
                if (reader["ReferralUserId"] != DBNull.Value)
                {
                    member.ReferralUserId = new int?((int)reader["ReferralUserId"]);
                }
                member.IsOpenBalance       = (bool)reader["IsOpenBalance"];
                member.TradePassword       = (string)reader["TradePassword"];
                member.TradePasswordFormat = (MembershipPasswordFormat)((int)reader["TradePasswordFormat"]);
                member.OrderNumber         = (int)reader["OrderNumber"];
                member.Expenditure         = (decimal)reader["Expenditure"];
                member.Points         = (int)reader["Points"];
                member.Balance        = (decimal)reader["Balance"];
                member.RequestBalance = (decimal)reader["RequestBalance"];
                if (reader["TopRegionId"] != DBNull.Value)
                {
                    member.TopRegionId = (int)reader["TopRegionId"];
                }
                if (reader["RegionId"] != DBNull.Value)
                {
                    member.RegionId = (int)reader["RegionId"];
                }
                if (reader["RealName"] != DBNull.Value)
                {
                    member.RealName = (string)reader["RealName"];
                }
                if (reader["Address"] != DBNull.Value)
                {
                    member.Address = (string)reader["Address"];
                }
                if (reader["Zipcode"] != DBNull.Value)
                {
                    member.Zipcode = (string)reader["Zipcode"];
                }
                if (reader["TelPhone"] != DBNull.Value)
                {
                    member.TelPhone = (string)reader["TelPhone"];
                }
                if (reader["CellPhone"] != DBNull.Value)
                {
                    member.CellPhone = (string)reader["CellPhone"];
                }
                if (reader["QQ"] != DBNull.Value)
                {
                    member.QQ = (string)reader["QQ"];
                }
                if (reader["Wangwang"] != DBNull.Value)
                {
                    member.Wangwang = (string)reader["Wangwang"];
                }
                if (reader["MSN"] != DBNull.Value)
                {
                    member.MSN = (string)reader["MSN"];
                }
            }
            return(member);
        }
Пример #29
0
 public abstract Supplier GetSupplier(HiMembershipUser membershipUser);
Пример #30
0
 public override IUser GetUser(HiMembershipUser membershipUser)
 {
     return(this.provider.GetDistributor(membershipUser));
 }