Ejemplo n.º 1
0
        /// <summary>
        ///     确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (txtConfirmPsw.Text != txtPassword.Text)
            {
                MyMessageBox.ShowMessage("Error", "Password and Confirm Password not match!");
                return;
            }
            //MongoUser不能同时具备Password和userSource字段!
            var user = new MongoUtility.Security.User
            {
                Username = txtUserName.Text,
                Password = txtUserName.Text,
                Roles    = userRoles.GetRoles()
            };
            var otherDbRoles = new BsonDocument();

            foreach (var item in _otherDbRolesDict.Values)
            {
                otherDbRoles.Add(item);
            }
            user.OtherDbRoles = otherDbRoles;
            user.UserSource   = txtuserSource.Text;
            if (txtUserName.Text == string.Empty)
            {
                MyMessageBox.ShowMessage("Error", "Please fill username!");
                return;
            }
            //2013/08/13 用户结构发生大的变化
            //取消了ReadOnly字段,添加了Roles等字段
            //简化逻辑,不论新建还是修改,AddUser都可以
            try
            {
                MongoUtility.Security.User.AddUserToSystem(user, _isAdmin);
            }
            catch (Exception ex)
            {
                Utility.ExceptionDeal(ex);
            }
            Close();
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     确定
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdOK_Click(object sender, EventArgs e)
 {
     if (txtConfirmPsw.Text != txtPassword.Text)
     {
         MyMessageBox.ShowMessage("Error", "Password and Confirm Password not match!");
         return;
     }
     //MongoUser不能同时具备Password和userSource字段!
     var user = new MongoUtility.Security.User
     {
         Username = txtUserName.Text,
         Password = txtUserName.Text,
         Roles = userRoles.GetRoles()
     };
     var otherDbRoles = new BsonDocument();
     foreach (var item in _otherDbRolesDict.Values)
     {
         otherDbRoles.Add(item);
     }
     user.OtherDbRoles = otherDbRoles;
     user.UserSource = txtuserSource.Text;
     if (txtUserName.Text == string.Empty)
     {
         MyMessageBox.ShowMessage("Error", "Please fill username!");
         return;
     }
     //2013/08/13 用户结构发生大的变化
     //取消了ReadOnly字段,添加了Roles等字段
     //简化逻辑,不论新建还是修改,AddUser都可以
     try
     {
         MongoUtility.Security.User.AddUserToSystem(user, _isAdmin);
     }
     catch (Exception ex)
     {
         Utility.ExceptionDeal(ex);
     }
     Close();
 }