Exemplo n.º 1
0
        /// <summary>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddRoleToDB_Click(object sender, EventArgs e)
        {
            var r = new Role();

            r.rolename = "tester" + DateTime.Now.ToString("yyyyMMddHHmmss");
            r.database = "admin";
            r.roles    = new Role.GrantRole[1];
            r.roles[0] = new Role.GrantRole {
                db = "admin", mRole = "read"
            };
            r.privileges    = new Role.privilege[1];
            r.privileges[0] = new Role.privilege
            {
                actions =
                    new MongoDBAction.ActionType[1]
                {
                    MongoDBAction.ActionType.DatabaseManagementActions_createCollection
                },
                resource =
                    new Resource {
                    CollectionName = "", DataBaseName = "admin", Type = Resource.ResourceType.DataBase
                }
            };
            var doc = Role.AddRole(SystemManager.GetCurrentServer().GetDatabase("admin"), r);

            if (doc.IsBsonDocument)
            {
                UIHelper.FillDataToTreeView("myClusterwideAdmin", treeViewColumns1, doc.AsBsonDocument);
            }
        }
Exemplo n.º 2
0
        protected void cmdAdd_Click(object sender, EventArgs e)
        {
            try
            {
                Role DB = new Role();

                lblResults1 = DB.AddRole(txtRole.Text, txtUserLabel.ToString());

                // Define the ADO.NET objects.
                // Fill the DataSet.
                DataSet ds = new DataSet();
                ds = DB.FindTable();
                //adapter.Fill(ds, "tb_Customer");
                // Perform the binding.
                GridView1.DataSource = ds;
                GridView1.DataBind();

                lblResults.Text = "Operation successful";
            }
            catch (FormatException err)
            {
                EventLog log = new EventLog();
                log.Source = "Milorry Frontend";
                log.WriteEntry(err.Message, EventLogEntryType.Error);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Add A Custom User
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddRole_Click(object sender, EventArgs e)
        {
            var r = new Role();

            if (RuntimeMongoDbContext.GetCurrentDataBase() != null)
            {
                r.Database = RuntimeMongoDbContext.GetCurrentDataBase().Name;
            }
            else
            {
                r.Database = ConstMgr.DatabaseNameAdmin;
            }
            r.Rolename   = txtRolename.Text;
            r.Privileges = new Role.Privilege[_privilegeList.Count];
            for (var i = 0; i < _privilegeList.Count; i++)
            {
                r.Privileges[i] = _privilegeList[i];
            }
            r.Roles = new Role.GrantRole[_roleList.Count];
            for (var i = 0; i < _roleList.Count; i++)
            {
                r.Roles[i] = _roleList[i];
            }
            var result = Role.AddRole(RuntimeMongoDbContext.GetCurrentDataBase(), r);

            if (result.IsBsonDocument)
            {
                MyMessageBox.ShowMessage("Error", "Add Role Error", ViewHelper.ConvertToString(result));
            }
            else
            {
                MyMessageBox.ShowEasyMessage("Succeed", "Add Role OK");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Add A Custom User
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddRole_Click(object sender, EventArgs e)
        {
            Role r = new Role();

            if (SystemManager.GetCurrentDataBase() != null)
            {
                r.database = SystemManager.GetCurrentDataBase().Name;
            }
            else
            {
                r.database = MongoDbHelper.DATABASE_NAME_ADMIN;
            }
            r.rolename   = txtRolename.Text;
            r.privileges = new Role.privilege[PrivilegeList.Count];
            for (int i = 0; i < PrivilegeList.Count; i++)
            {
                r.privileges[i] = PrivilegeList[i];
            }
            r.roles = new Role.GrantRole[RoleList.Count];
            for (int i = 0; i < RoleList.Count; i++)
            {
                r.roles[i] = RoleList[i];
            }
            var result = Role.AddRole(SystemManager.GetCurrentDataBase(), r);

            if (result.IsBsonDocument)
            {
                MyMessageBox.ShowMessage("Error", "Add Role Error", MongoDbHelper.ConvertToString(result));
            }
            else
            {
                MyMessageBox.ShowEasyMessage("Succeed", "Add Role OK");
            }
        }
Exemplo n.º 5
0
        private void projectRoleRecursive(Role group, oxite_Role role)
        {
            Role newRole = group.AddRole((RoleType)role.RoleType, role.RoleID, role.RoleName);

            foreach (oxite_Role childRole in context.oxite_Roles.Where(r => r.GroupRoleID == role.RoleID))
            {
                projectRoleRecursive(newRole, childRole);
            }
        }
Exemplo n.º 6
0
 public async Task HandlerAsync(RoleCommand command)
 {
     try
     {
         var role = new Role();
         role.AddRole(command.RoleName.RoleNameFa, command.RoleName.RoleNameEn);
         unitOfWork.RoleRepository.AddRole(role);
         unitOfWork.Commit();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }