Exemplo n.º 1
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (!int.TryParse(this.Page.Request.QueryString["userId"], out this.userId))
     {
         base.GotoResourceNotFound();
         return;
     }
     this.btnEditProfile.Click += new System.EventHandler(this.btnEditProfile_Click);
     if (!this.Page.IsPostBack)
     {
         this.dropRole.DataBind();
         Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(this.userId);
         if (manager == null)
         {
             this.ShowMsg("匿名用户或非供应商用户不能编辑", false);
             return;
         }
         this.GetAccountInfo(manager);
         this.GetPersonaInfo(manager);
         this.fkRemark.Text = manager.Comment;
         System.Data.DataTable dataTable = Methods.Supplier_SupGet(this.userId);
         if (dataTable != null && dataTable.Rows.Count > 0)
         {
             System.Data.DataRow dataRow = dataTable.Rows[0];
             if (dataRow["Supplier_GradeId"] != System.DBNull.Value)
             {
                 this.drpSupplierGrades.SelectedValue = dataRow["Supplier_GradeId"].ToString();
             }
         }
     }
 }
Exemplo n.º 2
0
 private void GetAccountInfo(Hidistro.Membership.Context.SiteManager user)
 {
     this.lblLoginNameValue.Text     = user.Username;
     this.lblRegsTimeValue.Time      = user.CreateDate;
     this.lblLastLoginTimeValue.Time = user.LastLoginDate;
     string[] userRoleNames = Hidistro.Membership.Core.RoleHelper.GetUserRoleNames(user.Username);
     string[] array         = userRoleNames;
     for (int i = 0; i < array.Length; i++)
     {
         string text = array[i];
         if (string.Compare(text, "SystemAdministrator") == 0)
         {
             this.dropRole.SelectedIndex = this.dropRole.Items.IndexOf(this.dropRole.Items.FindByText("超级管理员"));
         }
         if (Hidistro.Membership.Context.HiContext.Current.User.UserId == this.userId)
         {
             this.dropRole.Enabled = false;
         }
         if (!Hidistro.Membership.Core.RoleHelper.IsBuiltInRole(text))
         {
             this.dropRole.SelectedIndex = this.dropRole.Items.IndexOf(this.dropRole.Items.FindByText(text));
             return;
         }
     }
 }
Exemplo n.º 3
0
 protected override string AuthenticateToken(UsernameToken token)
 {
     Hidistro.Membership.Core.Enums.LoginUserStatus loginUserStatus;
     try
     {
         Hidistro.Membership.Context.SiteManager siteManager = Hidistro.Membership.Context.Users.GetUser(0, token.Identity.Name, false, false) as Hidistro.Membership.Context.SiteManager;
         if (siteManager != null && siteManager.IsAdministrator)
         {
             Hidistro.Membership.Context.HiContext arg_29_0 = Hidistro.Membership.Context.HiContext.Current;
             siteManager.Password = HiCryptographer.Decrypt(token.Password);
             loginUserStatus      = Hidistro.Membership.Context.Users.ValidateUser(siteManager);
         }
         else
         {
             loginUserStatus = Hidistro.Membership.Core.Enums.LoginUserStatus.InvalidCredentials;
         }
     }
     catch
     {
         loginUserStatus = Hidistro.Membership.Core.Enums.LoginUserStatus.InvalidCredentials;
     }
     if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.Success)
     {
         return(token.Password);
     }
     return(HiCryptographer.CreateHash(token.Password));
 }
Exemplo n.º 4
0
 public static CreateUserStatus Create(SiteManager managerToCreate, string department)
 {
     if ((managerToCreate == null) || (managerToCreate.UserRole != UserRole.SiteManager))
     {
         return CreateUserStatus.UnknownFailure;
     }
     string[] roles = new string[] { HiContext.Current.Config.RolesConfiguration.Manager, department };
     return Users.CreateUser(managerToCreate, roles);
 }
Exemplo n.º 5
0
        private void btnAdminLogin_Click(object sender, System.EventArgs e)
        {
            if (!Hidistro.Membership.Context.HiContext.Current.CheckVerifyCode(this.txtCode.Text.Trim()))
            {
                this.ShowMessage("验证码不正确");
                return;
            }
            Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(0, this.txtAdminName.Text, false, true);
            if (user == null || user.IsAnonymous || user.UserRole != Hidistro.Membership.Core.Enums.UserRole.SiteManager || !user.IsInRole("区域发货点"))
            {
                this.ShowMessage("无效的用户信息");
                return;
            }
            string text = null;

            Hidistro.Membership.Context.SiteManager siteManager = user as Hidistro.Membership.Context.SiteManager;
            siteManager.Password = this.txtAdminPassWord.Text;
            Hidistro.Membership.Core.Enums.LoginUserStatus loginUserStatus = ManagerHelper.ValidLogin(siteManager);
            if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.Success)
            {
                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(siteManager.Username, false);
                Hidistro.Membership.Core.IUserCookie userCookie = siteManager.GetUserCookie();
                userCookie.WriteCookie(authCookie, 30, false);
                Hidistro.Membership.Context.HiContext.Current.User = siteManager;
                if (!string.IsNullOrEmpty(this.Page.Request.QueryString["returnUrl"]))
                {
                    text = this.Page.Request.QueryString["returnUrl"];
                }
                if (text == null && this.ReferralLink != null && !string.IsNullOrEmpty(this.ReferralLink.Trim()))
                {
                    text = this.ReferralLink;
                }
                if (!string.IsNullOrEmpty(text) && (text.ToLower().IndexOf(Globals.GetSiteUrls().Logout.ToLower()) >= 0 || text.ToLower().IndexOf(Globals.GetSiteUrls().UrlData.FormatUrl("register").ToLower()) >= 0 || text.ToLower().IndexOf(Globals.GetSiteUrls().UrlData.FormatUrl("vote").ToLower()) >= 0 || text.ToLower().IndexOf("loginexit") >= 0))
                {
                }
                this.Page.Response.Redirect("default.html", true);
                return;
            }
            if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.AccountPending)
            {
                this.ShowMessage("用户账号还没有通过审核");
                return;
            }
            if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.AccountLockedOut)
            {
                this.ShowMessage("用户账号已被锁定,暂时不能登录系统");
                return;
            }
            if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.InvalidCredentials)
            {
                this.ShowMessage("用户名或密码错误");
                return;
            }
            this.ShowMessage("登录失败,未知错误");
        }
Exemplo n.º 6
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (!int.TryParse(this.Page.Request.QueryString["userId"], out this.userId))
     {
         base.GotoResourceNotFound();
         return;
     }
     this.btnEditProfile.Click += new System.EventHandler(this.btnEditProfile_Click);
     if (!this.Page.IsPostBack)
     {
         this.dropRole.DataBind();
         Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(this.userId);
         if (manager == null)
         {
             this.ShowMsg("匿名用户或非区域发货点用户不能编辑", false);
             return;
         }
         this.GetAccountInfo(manager);
         this.GetPersonaInfo(manager);
         this.fkRemark.Text = manager.Comment;
         System.Data.DataTable dataTable = Methods.Supplier_SupGet(this.userId);
         if (dataTable != null && dataTable.Rows.Count > 0)
         {
             System.Data.DataRow dataRow = dataTable.Rows[0];
             if (dataRow["Supplier_RegionId"] != System.DBNull.Value)
             {
                 this.rsddlRegion.SetSelectedRegionId(new int?((int)dataTable.Rows[0]["Supplier_RegionId"]));
             }
             if (dataRow["Supplier_RealName"] != System.DBNull.Value)
             {
                 this.txtRealName.Text = (string)dataRow["Supplier_RealName"];
             }
             if (dataRow["Supplier_Address"] != System.DBNull.Value)
             {
                 this.txtAddress.Text = (string)dataRow["Supplier_Address"];
             }
             if (dataRow["Supplier_Zipcode"] != System.DBNull.Value)
             {
                 this.txtZip.Text = (string)dataRow["Supplier_Zipcode"];
             }
             if (dataRow["Supplier_TelPhone"] != System.DBNull.Value)
             {
                 this.txtPhone.Text = (string)dataRow["Supplier_TelPhone"];
             }
             if (dataRow["Supplier_CellPhone"] != System.DBNull.Value)
             {
                 this.txtCellPhone.Text = (string)dataRow["Supplier_CellPhone"];
             }
         }
     }
 }
Exemplo n.º 7
0
        private void btnEditProfile_Click(object sender, System.EventArgs e)
        {
            if (!this.Page.IsValid)
            {
                return;
            }
            if (!this.rsddlRegion.GetSelectedRegionId().HasValue || string.IsNullOrEmpty(this.txtRealName.Text.Trim()) || string.IsNullOrEmpty(this.txtAddress.Text.Trim()) || string.IsNullOrEmpty(this.txtZip.Text.Trim()) || string.IsNullOrEmpty(this.txtCellPhone.Text.Trim()))
            {
                this.ShowMsg("错误:收货人、所在区域、具体地址、邮编、手机必填", false);
                return;
            }
            int    value           = this.rsddlRegion.GetSelectedRegionId().Value;
            string selectedRegions = this.rsddlRegion.SelectedRegions;

            string[] array = selectedRegions.Split(",".ToCharArray());
            if (array.Length == 1 && RegionHelper.GetCitys(value).Count > 0)
            {
                this.ShowMsg("所在区域必填填写完整", false);
                return;
            }
            if (array.Length == 2 && RegionHelper.GetCountys(value).Count > 0)
            {
                this.ShowMsg("所在区域必填填写完整", false);
                return;
            }
            Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(this.userId);
            manager.Email = this.txtprivateEmail.Text;
            if (!this.ValidationManageEamilr(manager))
            {
                return;
            }
            string[] userRoleNames = Hidistro.Membership.Core.RoleHelper.GetUserRoleNames(manager.Username);
            string[] array2        = userRoleNames;
            for (int i = 0; i < array2.Length; i++)
            {
                string text = array2[i];
                if (!Hidistro.Membership.Core.RoleHelper.IsBuiltInRole(text) || string.Compare(text, "SystemAdministrator") == 0)
                {
                    Hidistro.Membership.Core.RoleHelper.RemoveUserFromRole(manager.Username, text);
                }
            }
            Hidistro.Membership.Core.RoleHelper.AddUserToRole(manager.Username, "区域发货点");
            if (ManagerHelper.Update(manager))
            {
                Methods.Supplier_ShipPointUpdate(this.userId, this.fkRemark.Text, new int?(value), selectedRegions, this.txtRealName.Text.Trim(), this.txtAddress.Text.Trim(), this.txtZip.Text.Trim(), this.txtCellPhone.Text.Trim(), this.txtPhone.Text.Trim());
                this.ShowMsg("成功修改了当前区域发货点的个人资料", true);
                return;
            }
            this.ShowMsg("当前区域发货点的个人信息修改失败", false);
        }
 protected void Page_Load(object sender, System.EventArgs e)
 {
     this.userId = Hidistro.Membership.Context.HiContext.Current.User.UserId;
     this.btnEditPassWordOK.Click += new System.EventHandler(this.btnEditPassWordOK_Click);
     if (!this.Page.IsPostBack)
     {
         Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(this.userId);
         if (manager == null)
         {
             base.GotoResourceNotFound();
             return;
         }
         this.lblLoginNameValue.Text = manager.Username;
         this.GetSecurity();
     }
 }
Exemplo n.º 9
0
        private bool ValidationAddManager(Hidistro.Membership.Context.SiteManager siteManager)
        {
            bool flag = true;
            ValidationResults validationResults = Validation.Validate <Hidistro.Membership.Context.SiteManager>(siteManager, new string[]
            {
                "ValManagerName"
            });
            string text = string.Empty;

            if (!validationResults.IsValid)
            {
                foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)
                {
                    text += Formatter.FormatErrorMessage(current.Message);
                }
                flag = false;
            }
            validationResults = Validation.Validate <Hidistro.Membership.Context.SiteManager>(siteManager, new string[]
            {
                "ValManagerPassword"
            });
            if (!validationResults.IsValid)
            {
                foreach (ValidationResult current2 in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)
                {
                    text += Formatter.FormatErrorMessage(current2.Message);
                }
                flag = false;
            }
            validationResults = Validation.Validate <Hidistro.Membership.Context.SiteManager>(siteManager, new string[]
            {
                "ValManagerEmail"
            });
            if (!validationResults.IsValid)
            {
                foreach (ValidationResult current3 in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)
                {
                    text += Formatter.FormatErrorMessage(current3.Message);
                }
                flag = false;
            }
            if (!flag)
            {
                this.ShowMsg(text, false);
            }
            return(flag);
        }
Exemplo n.º 10
0
        private bool ValidationManageEamilr(Hidistro.Membership.Context.SiteManager siteManager)
        {
            ValidationResults validationResults = Validation.Validate <Hidistro.Membership.Context.SiteManager>(siteManager, new string[]
            {
                "ValManagerEmail"
            });
            string text = string.Empty;

            if (!validationResults.IsValid)
            {
                foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)
                {
                    text += Formatter.FormatErrorMessage(current.Message);
                }
                this.ShowMsg(text, false);
            }
            return(validationResults.IsValid);
        }
Exemplo n.º 11
0
        private void grdManager_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
        {
            int num = (int)this.grdManager.DataKeys[e.RowIndex].Value;

            if (Hidistro.Membership.Context.HiContext.Current.User.UserId == num)
            {
                this.ShowMsg("不能删除自己", false);
                return;
            }
            Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(num);
            if (!ManagerHelper.Delete(manager.UserId))
            {
                this.ShowMsg("未知错误", false);
                return;
            }
            this.BindData();
            this.ShowMsg("成功删除了一个供应商", true);
        }
Exemplo n.º 12
0
        private void btnRemark_Click(object sender, System.EventArgs e)
        {
            string value = this.hid_UserId.Value;

            if (this.ddl_UserIdList.SelectedValue == value)
            {
                this.ShowMsg("不能转移给自己", false);
                return;
            }
            Methods.Supplier_UpdateSupProjectsByUserId(int.Parse(value), int.Parse(this.ddl_UserIdList.SelectedValue), this.ddl_UserIdList.SelectedItem.Text);
            Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(int.Parse(value));
            if (!ManagerHelper.Delete(manager.UserId))
            {
                this.ShowMsg("未知错误", false);
                return;
            }
            this.BindData();
            this.ShowMsg("转移成功", true);
        }
        private void btnEditPassWordOK_Click(object sender, System.EventArgs e)
        {
            Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(this.userId);
            if (string.IsNullOrEmpty(this.txtNewPassWord.Text) || this.txtNewPassWord.Text.Length > 20 || this.txtNewPassWord.Text.Length < 6)
            {
                this.ShowMsg("密码不能为空,长度限制在6-20个字符之间", false);
                return;
            }
            if (string.Compare(this.txtNewPassWord.Text, this.txtPassWordCompare.Text) != 0)
            {
                this.ShowMsg("两次输入的密码不一样", false);
                return;
            }
            HiConfiguration config = HiConfiguration.GetConfig();

            if (string.IsNullOrEmpty(this.txtNewPassWord.Text) || this.txtNewPassWord.Text.Length < System.Web.Security.Membership.Provider.MinRequiredPasswordLength || this.txtNewPassWord.Text.Length > config.PasswordMaxLength)
            {
                this.ShowMsg(string.Format("管理员登录密码的长度只能在{0}和{1}个字符之间", System.Web.Security.Membership.Provider.MinRequiredPasswordLength, config.PasswordMaxLength), false);
                return;
            }
            if (this.userId == Hidistro.Membership.Context.HiContext.Current.User.UserId)
            {
                if (manager.ChangePassword(this.txtOldPassWord.Text, this.txtNewPassWord.Text))
                {
                    this.ShowMsg("密码修改成功", true);
                    return;
                }
                this.ShowMsg("修改密码失败,您输入的旧密码有误", false);
                return;
            }
            else
            {
                System.Web.HttpContext arg_126_0 = Hidistro.Membership.Context.HiContext.Current.Context;
                if (manager.ChangePassword(this.txtNewPassWord.Text))
                {
                    this.ShowMsg("密码修改成功", true);
                    return;
                }
                this.ShowMsg("修改密码失败,您输入的旧密码有误", false);
                return;
            }
        }
Exemplo n.º 14
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (!int.TryParse(this.Page.Request.QueryString["userId"], out this.userId))
     {
         base.GotoResourceNotFound();
         return;
     }
     this.btnEditProfile.Click += new System.EventHandler(this.btnEditProfile_Click);
     if (!this.Page.IsPostBack)
     {
         this.dropRole.DataBind();
         Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(this.userId);
         if (manager == null)
         {
             this.ShowMsg("匿名用户或非管理员用户不能编辑", false);
             return;
         }
         this.GetAccountInfo(manager);
         this.GetPersonaInfo(manager);
     }
 }
Exemplo n.º 15
0
 private void GetAccountInfo(SiteManager user)
 {
     lblLoginNameValue.Text = user.Username;
     lblRegsTimeValue.Time = user.CreateDate;
     lblLastLoginTimeValue.Time = user.LastLoginDate;
     foreach (string str in RoleHelper.GetUserRoleNames(user.Username))
     {
         if (string.Compare(str, "SystemAdministrator") == 0)
         {
             dropRole.SelectedIndex = dropRole.Items.IndexOf(dropRole.Items.FindByText("超级管理员"));
         }
         if (HiContext.Current.User.UserId == userId)
         {
             dropRole.Enabled = false;
         }
         if (!RoleHelper.IsBuiltInRole(str))
         {
             dropRole.SelectedIndex = dropRole.Items.IndexOf(dropRole.Items.FindByText(str));
             break;
         }
     }
 }
Exemplo n.º 16
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (!int.TryParse(this.Page.Request.QueryString["userId"], out this.userId))
     {
         base.GotoResourceNotFound();
         return;
     }
     this.btn_addRegion.Click += new System.EventHandler(this.btn_addRegion_Click);
     if (!this.Page.IsPostBack)
     {
         Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(this.userId);
         if (manager == null)
         {
             base.GotoResourceNotFound();
             return;
         }
         System.Data.DataTable dataSource = Methods.Supplier_aspnet_UserRegionSelect(this.userId);
         this.dlstRegion.DataSource = dataSource;
         this.dlstRegion.DataBind();
         this.lblLoginNameValue.Text = manager.Username;
     }
 }
Exemplo n.º 17
0
 private void btnEditProfile_Click(object sender, System.EventArgs e)
 {
     if (!this.Page.IsValid)
     {
         return;
     }
     if (string.IsNullOrEmpty(this.drpSupplierGrades.SelectedValue))
     {
         this.ShowMsg("错误:供应商等级必选", false);
         return;
     }
     Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(this.userId);
     manager.Email = this.txtprivateEmail.Text;
     if (!this.ValidationManageEamilr(manager))
     {
         return;
     }
     string[] userRoleNames = Hidistro.Membership.Core.RoleHelper.GetUserRoleNames(manager.Username);
     string[] array         = userRoleNames;
     for (int i = 0; i < array.Length; i++)
     {
         string text = array[i];
         if (!Hidistro.Membership.Core.RoleHelper.IsBuiltInRole(text) || string.Compare(text, "SystemAdministrator") == 0)
         {
             Hidistro.Membership.Core.RoleHelper.RemoveUserFromRole(manager.Username, text);
         }
     }
     Hidistro.Membership.Core.RoleHelper.AddUserToRole(manager.Username, "供应商");
     if (ManagerHelper.Update(manager))
     {
         Methods.Supplier_SupUpdate(this.userId, this.fkRemark.Text, int.Parse(this.drpSupplierGrades.SelectedValue));
         this.ShowMsg("成功修改了当前供应商的个人资料", true);
         return;
     }
     this.ShowMsg("当前供应商的个人信息修改失败", false);
 }
Exemplo n.º 18
0
        private void btnEditProfile_Click(object sender, System.EventArgs e)
        {
            if (!this.Page.IsValid)
            {
                return;
            }
            Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(this.userId);
            manager.Email = this.txtprivateEmail.Text;
            if (!this.ValidationManageEamilr(manager))
            {
                return;
            }
            string[] userRoleNames = Hidistro.Membership.Core.RoleHelper.GetUserRoleNames(manager.Username);
            string[] array         = userRoleNames;
            for (int i = 0; i < array.Length; i++)
            {
                string text = array[i];
                if (!Hidistro.Membership.Core.RoleHelper.IsBuiltInRole(text) || string.Compare(text, "SystemAdministrator") == 0)
                {
                    Hidistro.Membership.Core.RoleHelper.RemoveUserFromRole(manager.Username, text);
                }
            }
            string text2 = this.dropRole.SelectedItem.Text;

            if (string.Compare(text2, "超级管理员") == 0)
            {
                text2 = "SystemAdministrator";
            }
            Hidistro.Membership.Core.RoleHelper.AddUserToRole(manager.Username, text2);
            if (ManagerHelper.Update(manager))
            {
                this.ShowMsg("成功修改了当前管理员的个人资料", true);
                return;
            }
            this.ShowMsg("当前管理员的个人信息修改失败", false);
        }
Exemplo n.º 19
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            Hidistro.Membership.Core.Enums.CreateUserStatus createUserStatus = Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure;
            Hidistro.Membership.Context.SiteManager         siteManager      = new Hidistro.Membership.Context.SiteManager();
            siteManager.IsApproved     = true;
            siteManager.Username       = this.txtUserName.Text.Trim();
            siteManager.Email          = "supplier_" + System.DateTime.Now.Ticks.ToString() + "@tom.com";
            siteManager.Password       = this.txtPassword.Text.Trim();
            siteManager.PasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
            siteManager.Comment        = this.fkRemark.Text;
            if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
                return;
            }
            if (string.IsNullOrEmpty(this.drpSupplierGrades.SelectedValue))
            {
                this.ShowMsg("错误:供应商等级必选", false);
                return;
            }
            if (!this.ValidationAddManager(siteManager))
            {
                return;
            }
            try
            {
                createUserStatus = ManagerHelper.Create(siteManager, "供应商");
            }
            catch (Hidistro.Membership.Core.CreateUserException ex)
            {
                createUserStatus = ex.CreateUserStatus;
            }
            switch (createUserStatus)
            {
            case Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure:
                this.ShowMsg("未知错误", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.Created:
                Methods.Supplier_SupUpdate(siteManager.UserId, this.fkRemark.Text, int.Parse(this.drpSupplierGrades.SelectedValue));
                this.txtEmail.Text    = string.Empty;
                this.txtUserName.Text = string.Empty;
                this.fkRemark.Text    = string.Empty;
                this.ShowMsg("成功添加了一个供应商", true);
                break;

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

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

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidFirstCharacter:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.Updated:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.Deleted:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidQuestionAnswer:
                break;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.DisallowedUsername:
                this.ShowMsg("用户名被禁止注册", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidPassword:
                this.ShowMsg("无效的密码", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidEmail:
                this.ShowMsg("无效的电子邮件地址", false);
                return;

            default:
                return;
            }
        }
Exemplo n.º 20
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            Hidistro.Membership.Core.Enums.CreateUserStatus createUserStatus = Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure;
            Hidistro.Membership.Context.SiteManager         siteManager      = new Hidistro.Membership.Context.SiteManager();
            siteManager.IsApproved     = true;
            siteManager.Username       = this.txtUserName.Text.Trim();
            siteManager.Email          = "supplier_" + System.DateTime.Now.Ticks.ToString() + "@tom.com";
            siteManager.Password       = this.txtPassword.Text.Trim();
            siteManager.PasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
            siteManager.Comment        = this.fkRemark.Text;
            if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
                return;
            }
            if (!this.ValidationAddManager(siteManager))
            {
                return;
            }
            if (!this.rsddlRegion.GetSelectedRegionId().HasValue || string.IsNullOrEmpty(this.txtRealName.Text.Trim()) || string.IsNullOrEmpty(this.txtAddress.Text.Trim()) || string.IsNullOrEmpty(this.txtZip.Text.Trim()) || string.IsNullOrEmpty(this.txtCellPhone.Text.Trim()))
            {
                this.ShowMsg("错误:收货人、所在区域、具体地址、邮编、手机必填", false);
                return;
            }
            int    value           = this.rsddlRegion.GetSelectedRegionId().Value;
            string selectedRegions = this.rsddlRegion.SelectedRegions;

            string[] array = selectedRegions.Split(",".ToCharArray());
            if (array.Length == 1 && RegionHelper.GetCitys(value).Count > 0)
            {
                this.ShowMsg("所在区域必填填写完整", false);
                return;
            }
            if (array.Length == 2 && RegionHelper.GetCountys(value).Count > 0)
            {
                this.ShowMsg("所在区域必填填写完整", false);
                return;
            }
            try
            {
                createUserStatus = ManagerHelper.Create(siteManager, "区域发货点");
            }
            catch (Hidistro.Membership.Core.CreateUserException ex)
            {
                createUserStatus = ex.CreateUserStatus;
            }
            switch (createUserStatus)
            {
            case Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure:
                this.ShowMsg("未知错误", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.Created:
                Methods.Supplier_ShipPointUpdate(siteManager.UserId, this.fkRemark.Text, new int?(value), selectedRegions, this.txtRealName.Text.Trim(), this.txtAddress.Text.Trim(), this.txtZip.Text.Trim(), this.txtCellPhone.Text.Trim(), this.txtPhone.Text.Trim());
                this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "sucess", string.Format("<script language=\"javascript\" >alert('添加成功');window.location.href=\"{0}\"</script>", System.Web.HttpContext.Current.Request.RawUrl));
                break;

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

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

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidFirstCharacter:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.Updated:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.Deleted:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidQuestionAnswer:
                break;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.DisallowedUsername:
                this.ShowMsg("用户名被禁止注册", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidPassword:
                this.ShowMsg("无效的密码", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidEmail:
                this.ShowMsg("无效的电子邮件地址", false);
                return;

            default:
                return;
            }
        }
Exemplo n.º 21
0
 public static LoginUserStatus ValidLogin(SiteManager manager)
 {
     if (manager == null)
     {
         return LoginUserStatus.InvalidCredentials;
     }
     LoginUserStatus status = Users.ValidateUser(manager);
     if ((status == LoginUserStatus.Success) && (manager.UserRole == UserRole.SiteManager))
     {
         HttpContext context = HiContext.Current.Context;
         string path = context.Request.MapPath(Globals.ApplicationPath + "/config/Hishop.key");
         if (File.Exists(path))
         {
             return status;
         }
         try
         {
             XmlDocument document = new XmlDocument();
             try
             {
                 document.Load(context.Request.MapPath(Globals.ApplicationPath + "/config/key.config"));
             }
             catch
             {
                 document.Load(context.Request.MapPath(Globals.ApplicationPath + "/config/key.config.bak"));
             }
             if (int.Parse(document.SelectSingleNode("Settings/Token").InnerText) != manager.UserId)
             {
                 return status;
             }
             byte[] userData = Cryptographer.DecryptWithPassword(Convert.FromBase64String(document.SelectSingleNode("Settings/Key").InnerText), manager.Password);
             byte[] encryptedKey = ProtectedData.Protect(userData, null, DataProtectionScope.LocalMachine);
             using (Stream stream = new FileStream(path, FileMode.Create))
             {
                 KeyManager.Write(stream, encryptedKey, DataProtectionScope.LocalMachine);
             }
             CryptographyUtility.ZeroOutBytes(encryptedKey);
             CryptographyUtility.ZeroOutBytes(userData);
         }
         catch
         {
         }
     }
     return status;
 }
Exemplo n.º 22
0
 public static bool Update(SiteManager manager)
 {
     return Users.UpdateUser(manager);
 }
Exemplo n.º 23
0
 public static CreateUserStatus CreateAdministrator(SiteManager administrator)
 {
     return Create(administrator, HiContext.Current.Config.RolesConfiguration.SystemAdministrator);
 }
Exemplo n.º 24
0
 private void GetPersonaInfo(SiteManager user)
 {
     txtprivateEmail.Text = user.Email;
 }
Exemplo n.º 25
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            Hidistro.Membership.Core.Enums.CreateUserStatus createUserStatus = Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure;
            Hidistro.Membership.Context.SiteManager         siteManager      = new Hidistro.Membership.Context.SiteManager();
            siteManager.IsApproved     = true;
            siteManager.Username       = this.txtUserName.Text.Trim();
            siteManager.Email          = this.txtEmail.Text.Trim();
            siteManager.Password       = this.txtPassword.Text.Trim();
            siteManager.PasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
            if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
                return;
            }
            if (!this.ValidationAddManager(siteManager))
            {
                return;
            }
            try
            {
                string text = this.dropRole.SelectedItem.Text;
                if (string.Compare(text, "超级管理员") == 0)
                {
                    text = "SystemAdministrator";
                }
                createUserStatus = ManagerHelper.Create(siteManager, text);
            }
            catch (Hidistro.Membership.Core.CreateUserException ex)
            {
                createUserStatus = ex.CreateUserStatus;
            }
            switch (createUserStatus)
            {
            case Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure:
                this.ShowMsg("未知错误", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.Created:
                this.txtEmail.Text    = string.Empty;
                this.txtUserName.Text = string.Empty;
                this.ShowMsg("成功添加了一个管理员", true);
                break;

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

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

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidFirstCharacter:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.Updated:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.Deleted:
            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidQuestionAnswer:
                break;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.DisallowedUsername:
                this.ShowMsg("用户名被禁止注册", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidPassword:
                this.ShowMsg("无效的密码", false);
                return;

            case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidEmail:
                this.ShowMsg("无效的电子邮件地址", false);
                return;

            default:
                return;
            }
        }
Exemplo n.º 26
0
 private bool ValidationManageEamilr(SiteManager siteManager)
 {
     ValidationResults results = Hishop.Components.Validation.Validation.Validate<SiteManager>(siteManager, new string[] { "ValManagerEmail" });
     string msg = string.Empty;
     if (!results.IsValid)
     {
         foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
         {
             msg = msg + Formatter.FormatErrorMessage(result.Message);
         }
         ShowMsg(msg, false);
     }
     return results.IsValid;
 }
Exemplo n.º 27
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            CreateUserStatus unknownFailure = CreateUserStatus.UnknownFailure;
            SiteManager siteManager = new SiteManager();
            siteManager.IsApproved = true;
            siteManager.Username = txtUserName.Text.Trim();
            siteManager.Email = txtEmail.Text.Trim();
            siteManager.Password = txtPassword.Text.Trim();
            siteManager.PasswordFormat = MembershipPasswordFormat.Hashed;
            if (string.Compare(txtPassword.Text, txtPasswordagain.Text) != 0)
            {
                ShowMsg("请确保两次输入的密码相同", false);
            }
            else if (ValidationAddManager(siteManager))
            {
                try
                {
                    string text = dropRole.SelectedItem.Text;
                    if (string.Compare(text, "超级管理员") == 0)
                    {
                        text = "SystemAdministrator";
                    }
                    unknownFailure = ManagerHelper.Create(siteManager, text);
                }
                catch (CreateUserException exception)
                {
                    unknownFailure = exception.CreateUserStatus;
                }
                switch (unknownFailure)
                {
                    case CreateUserStatus.UnknownFailure:
                        ShowMsg("未知错误", false);
                        return;

                    case CreateUserStatus.Created:
                        txtEmail.Text = string.Empty;
                        txtUserName.Text = string.Empty;
                        ShowMsg("成功添加了一个管理员", true);
                        return;

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

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

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

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

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

                    case CreateUserStatus.InvalidEmail:
                        ShowMsg("无效的电子邮件地址", false);
                        return;
                }
            }
        }
Exemplo n.º 28
0
 public override bool CreateManager(SiteManager manager)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO aspnet_Managers (UserId) VALUES (@UserId)");
     this.database.AddInParameter(sqlStringCommand, "UserId", DbType.Int32, manager.UserId);
     return (this.database.ExecuteNonQuery(sqlStringCommand) == 1);
 }
Exemplo n.º 29
0
 private bool ValidationAddManager(SiteManager siteManager)
 {
     bool flag = true;
     ValidationResults results = Hishop.Components.Validation.Validation.Validate<SiteManager>(siteManager, new string[] { "ValManagerName" });
     string msg = string.Empty;
     if (!results.IsValid)
     {
         foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
         {
             msg = msg + Formatter.FormatErrorMessage(result.Message);
         }
         flag = false;
     }
     results = Hishop.Components.Validation.Validation.Validate<SiteManager>(siteManager, new string[] { "ValManagerPassword" });
     if (!results.IsValid)
     {
         foreach (ValidationResult result2 in (IEnumerable<ValidationResult>)results)
         {
             msg = msg + Formatter.FormatErrorMessage(result2.Message);
         }
         flag = false;
     }
     results = Hishop.Components.Validation.Validation.Validate<SiteManager>(siteManager, new string[] { "ValManagerEmail" });
     if (!results.IsValid)
     {
         foreach (ValidationResult result3 in (IEnumerable<ValidationResult>)results)
         {
             msg = msg + Formatter.FormatErrorMessage(result3.Message);
         }
         flag = false;
     }
     if (!flag)
     {
         ShowMsg(msg, false);
     }
     return flag;
 }
Exemplo n.º 30
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;
 }
Exemplo n.º 31
0
 private void GetPersonaInfo(Hidistro.Membership.Context.SiteManager user)
 {
     this.txtprivateEmail.Text = user.Email;
 }
Exemplo n.º 32
0
 private void GetAccountInfo(Hidistro.Membership.Context.SiteManager user)
 {
     this.lblLoginNameValue.Text     = user.Username;
     this.lblRegsTimeValue.Time      = user.CreateDate;
     this.lblLastLoginTimeValue.Time = user.LastLoginDate;
 }