示例#1
0
    private UserInfo GetUser(UserManagerBLL bll)
    {
        // 检查用户的输入情况
        if (string.IsNullOrEmpty(txtUserName.Text.Trim()) || string.IsNullOrEmpty(txtAlias.Text.Trim()))
        {
            lblError.Text = "请输入用户账号和用户姓名!";
            return(null);
        }
        if (!string.IsNullOrEmpty(txtEmail.Text.Trim()) && !ValidationUtility.IsValidEmail(txtEmail.Text.Trim()))
        {
            lblError.Text = "请输入有效的用户邮箱!";
            return(null);
        }

        var ret = PageUtility.User;

        ret.Alias       = txtAlias.Text.Trim();
        ret.Email       = txtEmail.Text.Trim();
        ret.Description = txtDescription.Text.Trim();

        ret.LastUpdByID   = ret.ID;
        ret.LastUpdByName = ret.Alias;
        ret.LastUpdDate   = DateTime.Now;

        return(ret);
    }
示例#2
0
        public ActionResult NewRecipient(string email)
        {
            if (ValidationUtility.IsValidEmail(email))
            {
                Database.Instance.SaveNewEmailRecipient(email);
            }

            return(RedirectToAction(nameof(Settings)));
        }
示例#3
0
    private UserInfo getUser(UserInfo loginedUser, UserManagerBLL BLL)
    {
        // 检查用户的输入情况
        if (string.IsNullOrEmpty(txtUserName.Text.Trim()) || string.IsNullOrEmpty(txtAlias.Text.Trim()))
        {
            lblError.Text = "请输入用户账号和用户姓名!";
            return(null);
        }
        if (!string.IsNullOrEmpty(txtEmail.Text.Trim()) && !ValidationUtility.IsValidEmail(txtEmail.Text.Trim()))
        {
            lblError.Text = "请输入有效的用户邮箱!";
            return(null);
        }

        if (ddlOrg.SelectedItem == null || string.IsNullOrEmpty(ddlOrg.SelectedValue))
        {
            lblError.Text = "请选择管理机构!";
            return(null);
        }

        var ret = new UserInfo
        {
            ID = 0,
            EncryptedPassword        = "",
            PasswordAnswer           = string.Empty,
            PasswordQuestion         = string.Empty,
            SessionIdentify          = Guid.NewGuid().ToString(),
            IsSystem                 = false,
            IsAdmin                  = true,
            IsApproved               = true,
            PopedomIDs               = string.Empty,
            FailedPwdAttemptCount    = 0,
            FailedPwdAttemptDate     = DateTime.Now,
            FailedAnswerAttemptCount = 0,
            FailedAnswerAttemptDate  = DateTime.Now,
            LastLoginDate            = DateTime.Now,
            LastLockoutDate          = DateTime.Now,
            LastActivityDate         = DateTime.Now,
            LastPwdChangedDate       = DateTime.Now,
            DisplayOrder             = 100,
            CreatedByID              = loginedUser.ID,
            CreatedByName            = loginedUser.Alias,
            CreatedDate              = DateTime.Now
        };

        // 如果是修改,则获取要修改的对象
        if (!string.IsNullOrEmpty(hdnEditingUserNo.Value.Trim()))
        {
            UserInfo existUser = BLL.GetUser(int.Parse(hdnEditingUserNo.Value.Trim()));
            if (existUser == null)
            {
                lblError.Text = "修改的对象未找到!请确认该对象是否被其它用户删除!";
                return(null);
            }
            ret = existUser;
        }

        ret.UserName = txtUserName.Text.Trim();

        ret.OrganizationId   = Convert.ToInt32(ddlOrg.SelectedValue);
        ret.OrganizationName = ddlOrg.SelectedItem.Text;

        ret.Alias       = txtAlias.Text.Trim();
        ret.Email       = txtEmail.Text.Trim();
        ret.Description = txtDescription.Text.Trim();
        ret.IsLockedOut = cbxIsLockout.Checked;

        // 加入会员的管理角色
        var roleList = new List <RoleInfo>();

        foreach (ListItem item in chklstRoleList.Items)
        {
            if (item.Selected)
            {
                ret.AddRole(int.Parse(item.Value.Trim()));
            }
        }

        ret.LastUpdByID   = loginedUser.ID;
        ret.LastUpdByName = loginedUser.Alias;
        ret.LastUpdDate   = DateTime.Now;

        return(ret);
    }