Ejemplo n.º 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="db"></param>
 /// <param name="Username"></param>
 public void AddUser(MongoDatabase db,String Username)
 {
     var userInfo = db.GetCollection(MongoDBHelper.COLLECTION_NAME_USER).FindOneAs<BsonDocument>(MongoDB.Driver.Builders.Query.EQ("user", Username));
        if (userInfo != null)
        {
        MongoDBHelper.MongoUserEx user = new MongoDBHelper.MongoUserEx();
        user.roles = userInfo["roles"].AsBsonArray;
        if (userInfo.Contains("otherDBRoles"))
        {
            user.otherDBRoles = userInfo["otherDBRoles"].AsBsonDocument;
        }
        UserList.Add(db.Name, user);
        }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="db"></param>
        /// <param name="Username"></param>
        public void AddUser(MongoDatabase db, String Username)
        {
            var userInfo = db.GetCollection(MongoDBHelper.COLLECTION_NAME_USER).FindOneAs <BsonDocument>(MongoDB.Driver.Builders.Query.EQ("user", Username));

            if (userInfo != null)
            {
                MongoDBHelper.MongoUserEx user = new MongoDBHelper.MongoUserEx();
                user.roles = userInfo["roles"].AsBsonArray;
                if (userInfo.Contains("otherDBRoles"))
                {
                    user.otherDBRoles = userInfo["otherDBRoles"].AsBsonDocument;
                }
                UserList.Add(db.Name, user);
            }
        }
Ejemplo n.º 3
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字段!
     MongoDBHelper.MongoUserEx user = new MongoDBHelper.MongoUserEx();
     user.Username = txtUserName.Text;
     user.Password = txtUserName.Text;
     user.roles = userRoles.getRoles();
     BsonDocument 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
     {
         MongoDBHelper.AddUserToSystem(user, _IsAdmin);
     }
     catch (Exception ex)
     {
         SystemManager.ExceptionDeal(ex);
     }
     this.Close();
 }