//
 // GET: /Roles/Delete/5
 public ActionResult Delete(string id)
 {
     RoleModel model = new RoleModel();
     model.RoleName = id;
     if (id == "Administrator" || id == "Editor")
         return View("NoDelete",model);
     else
         return View(model);
 }
Пример #2
0
 public ActionResult Create(RoleModel rolemodel)
 {
     if (ModelState.IsValid)
     {
         if (!Roles.RoleExists(rolemodel.RoleName))
             Roles.CreateRole(rolemodel.RoleName);
         return RedirectToAction("Index");
     }
     return View(rolemodel);
 }
Пример #3
0
 public ActionResult Delete(string name)
 {
     if (!Roles.RoleExists(name))
     {
         throw new HttpException(404, "Not Found");
     }
     RoleModel rolemodel = new RoleModel();
     rolemodel.RoleName = name;
     return View(rolemodel);
 }
Пример #4
0
 public IEnumerable<RoleModel> GetRoleList(RoleModel filterModel)
 {
     var dtRoles = _dalRole.GetRoleList(filterModel.ToHashTable());
     return dtRoles.AsEnumerable().Select(dr => new RoleModel
     {
         //Authority = Convert.ToInt32(dr["Authority"]),
         AuthorityCode = dr["AuthorityCode"].ToString(),
         Description = dr["Description"].ToString(),
         Id = Convert.ToInt32(dr["Id"]),
         Name = dr["Name"].ToString()
     });
 }
        public ActionResult Create(RoleModel model)
        {
            try
            {
                Roles.CreateRole(model.RoleName);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Пример #6
0
 public override bool UpdateRole(RoleModel model)
 {
     using (SqlConnection cn = new SqlConnection(this.ConnectionString))
     {
         SqlCommand cmd = new SqlCommand("proc_UPDATE_ROLE", cn);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add("@Id_Role", SqlDbType.Int).Value = model.IdRole;
         cmd.Parameters.Add("@ID_USER_ROLE", SqlDbType.Int).Value = model.UserRole;
         cmd.Parameters.Add("@STATUS", SqlDbType.Int).Value = model.Status;
         cn.Open();
         int re = ExecuteNonQuery(cmd);
         return (re == 1);
     }
 }
Пример #7
0
    public override RoleModel GetByIdRole(int id)
    {
        using (SqlConnection cn = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("proc_GET_ROLE_BY_ID", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@ID_ROLE", SqlDbType.Int).Value = id;
            cn.Open();
            IDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
            if (reader.Read())
            {
                RoleModel model = new RoleModel {
                    (int)reader["IdRole"],
                    (int)reader["UserRole"],
                    (int)reader["STATUS"]

                          };
            }
            else
                return null;
        }
    }
Пример #8
0
        public string Add(AddRoleModel model)
        {
            if (ModelState.IsValid)
            {
                RoleModel role = new RoleModel();
                role.Name = model.Name;                             //角色名称
                role.Remark = model.Remark;                         //备注
                role.CreateMan = SysConfig.CurrentUser.Id;          //创建人
                role.CreateTime = DateTime.Now;                     //创建时间
                role.DelFlag = 0;                                   //有效状态
                int result = role.Insert().ToInt();

                if (result > 0)
                {
                    //记录操作日志
                    CommonMethod.Log(SysConfig.CurrentUser.Id, "Insert", "Sys_Role");

                    return "1";
                }
            }

            return "0";
        }
Пример #9
0
 public string SaveRole(RoleModel model)
 {
     return model.Id.HasValue ? ModifyRole(model) : CreateRole(model);
 }
 public ActionResult Edit(RoleModel model)
 {
     try
     {
         // TODO: Add update logic here
         string[] users = Roles.GetUsersInRole(model.RoleName);
         if (users.Length > 0)
         {
             Roles.RemoveUsersFromRole(users, model.RoleName);
         }
         if (model.SelectedUsers != null)
         {
             Roles.AddUsersToRole(model.SelectedUsers, model.RoleName);
         }
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Пример #11
0
        public async Task<HttpResponseMessage> Put(string ID, RoleModel entity)
        {
            try
            {
                if (ID != entity.ID)
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest,
                        "IDs do not match.");
                }

                var result = await Service.UpdateAsync(Mapper.Map<IRole>(entity));
                if (result == 1)
                {
                    return Request.CreateResponse(HttpStatusCode.OK, entity);
                }
                else
                {
                    return Request.CreateResponse(HttpStatusCode.InternalServerError,
                        "PUT unsuccessful.");
                }
            }
            catch (Exception e)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest, e.ToString());
            }
        }
Пример #12
0
 public void SetRole(RoleModel role)
 {
     this.role = role;
 }
Пример #13
0
 public static UserRole ToEntity(this RoleModel model, UserRole destination)
 {
     return(model.MapTo(destination));
 }
Пример #14
0
 protected string ModifyRole(RoleModel model)
 {
     return _dalRole.ModifyRole(model.ToHashTable());
 }
Пример #15
0
 protected RoleMessage(RoleModel role) : base(role.Id)
 {
     this.Target = role;
 }
Пример #16
0
        public async Task <IdentityResult> Update(RoleModel RoleDefinition)
        {
            IdentityResult result = await _repository.UpdateRole(RoleDefinition);

            return(result);
        }
Пример #17
0
        private static async Task AccountServiceTest(IUnityContainer container)
        {
            IAccountService accountService = container.Resolve <IAccountService>();

            #region "Roles"
            // Create Roles
            var role1 = new RoleModel
            {
                Name        = "Role 1",
                Description = "Role 1 Description"
            };

            var userRole1 = await accountService.AddRoleAsync(role1);

            var role2 = new RoleModel
            {
                Name        = "Role 2",
                Description = "Role 2 Description"
            };

            var userRole2 = await accountService.AddRoleAsync(role2);

            var role3 = new RoleModel
            {
                Name        = "Role 3",
                Description = "Role 3 Description"
            };

            var userRole3 = await accountService.AddRoleAsync(role3);

            #endregion "Roles"

            #region "Resources"
            // Create Resources
            var resource1 = new ResourceModel
            {
                Name        = "Resource 1",
                Description = "Resource 1 Description"
            };

            var userResource1 = await accountService.AddResourceAsync(resource1);

            var resource2 = new ResourceModel
            {
                Name        = "Resource 2",
                Description = "Resource 2 Description"
            };

            var userResource2 = await accountService.AddResourceAsync(resource2);

            var resource3 = new ResourceModel
            {
                Name        = "Resource 3",
                Description = "Resource 3 Description"
            };

            var userResource3 = await accountService.AddResourceAsync(resource3);

            var resource4 = new ResourceModel
            {
                Name        = "Resource 4",
                Description = "Resource 4 Description"
            };

            var userResource4 = await accountService.AddResourceAsync(resource4);

            #endregion "Resources"

            #region Role Resources
            await accountService.AddRoleResourceAsync(userRole1.Model.ID, userResource1.Model.ID);

            await accountService.AddRoleResourceAsync(userRole1.Model.ID, userResource2.Model.ID);

            await accountService.AddRoleResourceAsync(userRole1.Model.ID, userResource3.Model.ID);

            await accountService.AddRoleResourceAsync(userRole2.Model.ID, userResource1.Model.ID);

            await accountService.AddRoleResourceAsync(userRole2.Model.ID, userResource4.Model.ID);

            await accountService.AddRoleResourceAsync(userRole3.Model.ID, userResource1.Model.ID);

            #endregion Role Resources

            // Create User
            var newUser = new UserModel
            {
                FirstName = "User-" + DateTime.Now.ToString(),
                LastName  = "Last Name",
                UserName  = "******",
                Password  = "******",
                Roles     = new List <RoleModel> {
                    userRole1.Model, userRole2.Model
                }
            };

            var response = await accountService.AddUserAccountAsync(newUser);

            var userResponse = await accountService.AddUserRoleAsync(response.Model.ID, userRole3.Model.ID);
        }
Пример #18
0
        private static async Task UserWithRolesAndResourcesTest(IUnityContainer container)
        {
            IAccountService accountService = container.Resolve <IAccountService>();

            // About this test
            // 1. Create User
            // 2. Create Roles
            // 3. Create Resources
            // 4. Create Role <-> Resources
            // 5. Create User <-> Role

            // 1. Create User
            var newUser = new UserModel
            {
                FirstName = "User-" + DateTime.Now.ToString(),
                LastName  = "Last Name",
                UserName  = "******",
                Password  = "******"
            };

            await accountService.AddUserAsync(newUser);

            #region "Roles"
            // 2. Create Roles
            var role1 = new RoleModel
            {
                Name        = "Role 1",
                Description = "Role 1 Description"
            };

            await accountService.AddRoleAsync(role1);

            var role2 = new RoleModel
            {
                Name        = "Role 2",
                Description = "Role 2 Description"
            };

            await accountService.AddRoleAsync(role2);

            #endregion "Roles"

            #region "Resources"
            // 3. Create Resources
            var resource1 = new ResourceModel
            {
                Name        = "Resource 1",
                Description = "Resource 1 Description"
            };

            await accountService.AddResourceAsync(resource1);

            var resource2 = new ResourceModel
            {
                Name        = "Resource 2",
                Description = "Resource 2 Description"
            };

            await accountService.AddResourceAsync(resource2);

            var resource3 = new ResourceModel
            {
                Name        = "Resource 3",
                Description = "Resource 3 Description"
            };

            await accountService.AddResourceAsync(resource3);

            var resource4 = new ResourceModel
            {
                Name        = "Resource 4",
                Description = "Resource 4 Description"
            };

            await accountService.AddResourceAsync(resource4);

            #endregion "Resources"

            #region Role Resources
            // 4. Create Role <-> Resources


            #endregion Role Resources
        }
Пример #19
0
        // POST api/role
        public string Post([FromBody] RoleModel model)
        {
            var result = _bllRole.SaveRole(model);

            return(result);
        }
Пример #20
0
 internal Role(RoleModel model)
 {
     Id   = model.Id;
     Name = model.Name;
 }
        public IEnumerable <RoleModel> GetRoleList(int?page, string Name, string Description, string searchfilter, string SortCol, string SortOrder)
        {
            IList <RoleModel> RoleList = new List <RoleModel>();
            var roleId = Convert.ToInt32(HttpContext.Current.Session["RoleId"].ToString());

            var query = (from m in db.RoleMasters
                         where m.IsDeleted == false && m.RoleId > roleId
                         select new { m.RoleName, m.RoleDesc, m.RoleId, m.IsActive, m.IsDeleted, m.CreatedOn }).OrderByDescending(x => x.CreatedOn).ToList();

            #region Searching
            if (!string.IsNullOrEmpty(searchfilter))
            {
                query = query.Where(e => (!String.IsNullOrEmpty(e.RoleName) && e.RoleName.ToUpper().Contains(searchfilter.ToUpper())) ||
                                    (!String.IsNullOrEmpty(e.RoleDesc) && e.RoleDesc.ToUpper().Contains(searchfilter.ToUpper()))).ToList();
            }
            #endregion

            #region Sorting Acs/Desc
            if (SortOrder == "asc")
            {
                if (SortCol == "0")
                {
                    query = query.OrderBy(e => e.RoleName).ToList();
                }
            }
            else
            {
                if (SortCol == "0")
                {
                    query = query.OrderByDescending(e => e.RoleName).ToList();
                }
            }

            if (SortOrder == "asc")
            {
                if (SortCol == "1")
                {
                    query = query.OrderBy(e => e.RoleDesc).ToList();
                }
            }
            else
            {
                if (SortCol == "1")
                {
                    query = query.OrderByDescending(e => e.RoleDesc).ToList();
                }
            }

            /*-------  -----------*/

            if (SortOrder == "asc")
            {
                if (SortCol == "2")
                {
                    query = query.OrderBy(e => e.IsActive).ToList();
                }
            }
            else
            {
                if (SortCol == "2")
                {
                    query = query.OrderByDescending(e => e.IsActive).ToList();
                }
            }


            #endregion

            foreach (var PageData in query)
            {
                RoleModel PageModel = new RoleModel();
                {
                    PageModel.RoleId    = PageData.RoleId;
                    PageModel.RoleName  = PageData.RoleName;
                    PageModel.RoleDesc  = PageData.RoleDesc;
                    PageModel.IsActive  = PageData.IsActive;
                    PageModel.CreatedOn = PageData.CreatedOn;
                    PageModel.IsDeleted = PageData.IsDeleted;
                    RoleList.Add(PageModel);
                };
            }
            return(RoleList);
        }
Пример #22
0
 public TaskAgentMapper(string oracleXMLPath)
 {
     _roleModel  = new RoleModel(oracleXMLPath);
     _agentModel = new AgentModel(oracleXMLPath);
 }
Пример #23
0
 public void ShowData(string str)
 {
     try
     {
         this.dbo = new DB_OPT();
         this.dbo.Open();
         if (str != "")
         {
             str = " where " + str + " ";
         }
         DataSet set = this.pagesize.pagesize("*", "DB_Role", str, "RolePK", " order by BH ", this.Master.PageIndex, this.Master.PageSize, out this.count);
         this.Master.RecordCount = Convert.ToInt32(this.count);
         if ((set != null) && (set.Tables[0].Rows.Count > 0))
         {
             DataView defaultView = set.Tables[0].DefaultView;
             if ((this.ViewState["SortOrder"] != null) && (this.ViewState["OrderDire"] != null))
             {
                 string str2 = ((string)this.ViewState["SortOrder"]) + " " + ((string)this.ViewState["OrderDire"]);
                 defaultView.Sort = str2;
             }
             this.gvResult.DataSource = defaultView;
             this.gvResult.DataBind();
         }
         else
         {
             this.rm = new RoleDal();
             DataTable table = new DataTable();
             table = this.rm.GetList("RolePK=''", this.dbo).Tables[0];
             DataRow row = table.NewRow();
             table.Rows.Add(row);
             this.gvResult.DataSource = table.DefaultView;
             this.gvResult.DataBind();
         }
     }
     catch (Exception exception)
     {
         this.el = new ExceptionLog.ExceptionLog();
         this.el.ErrClassName = base.GetType().ToString();
         this.el.ErrMessage = exception.Message.ToString();
         this.el.ErrMethod = "ShowData()";
         this.el.WriteExceptionLog(true);
         Const.OpenErrorPage("获取数据失败,请联系系统管理员!", this.Page);
     }
     finally
     {
         if (this.dbo != null)
         {
             this.dbo.Close();
         }
     }
 }
Пример #24
0
 public async Task DeleteAsync(RoleModel role)
 {
     a3SContext.Role.Remove(role);
     await a3SContext.SaveChangesAsync();
 }
Пример #25
0
 public static UserRole ToEntity(this RoleModel model)
 {
     return(model.MapTo <RoleModel, UserRole>());
 }
Пример #26
0
        public ActionResult Create()
        {
            var model = new RoleModel();

            return(PartialView(model));
        }
Пример #27
0
        private void BootstrapAdminUserWithRolesAndPermissions(IApplicationBuilder app)
        {
            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                var context = serviceScope.ServiceProvider.GetRequiredService <A3SContext>();

                var writePermission = context.Permission.Where(p => p.Name == "a3s.securityContracts.update").FirstOrDefault();

                if (writePermission == null)
                {
                    writePermission = new PermissionModel
                    {
                        Name        = "a3s.securityContracts.update",
                        Description = "Enables idempotently applying (creating or updating) a security contract definition. This includes creation or updating of permissions, functions, applications and the relationships between them.",
                        ChangedBy   = Guid.Empty
                    };
                }

                var readPermission = context.Permission.Where(p => p.Name == "a3s.securityContracts.read").FirstOrDefault();

                if (readPermission == null)
                {
                    readPermission = new PermissionModel
                    {
                        Name        = "a3s.securityContracts.read",
                        Description = "Enables fetching of a security contract definition.",
                        ChangedBy   = Guid.Empty
                    };
                }

                // Ensure that the A3S application is createdd.
                var application = context.Application.Where(a => a.Name == "a3s").FirstOrDefault();

                if (application == null)
                {
                    application = new ApplicationModel
                    {
                        Name = "a3s",
                        ApplicationFunctions = new List <ApplicationFunctionModel>()
                        {
                            new ApplicationFunctionModel
                            {
                                Application = application,
                                Name        = "a3s.securityContracts",
                                ApplicationFunctionPermissions = new List <ApplicationFunctionPermissionModel>
                                {
                                    new ApplicationFunctionPermissionModel
                                    {
                                        Permission = writePermission
                                    },
                                    new ApplicationFunctionPermissionModel
                                    {
                                        Permission = readPermission
                                    }
                                }
                            }
                        }
                    };

                    context.Application.Add(application);
                    context.SaveChanges();
                }

                // Create the 'a3s.securityContractMaintenance' function.
                var function = context.Function.Where(f => f.Name == "a3s.securityContractMaintenance").FirstOrDefault();

                if (function == null)
                {
                    function = new FunctionModel
                    {
                        FunctionPermissions = new List <FunctionPermissionModel>(),
                        Name        = "a3s.securityContractMaintenance",
                        Description = "Functionality to apply security contracts for micro-services.",
                        Application = application,
                        ChangedBy   = Guid.Empty
                    };
                    function.FunctionPermissions.Add(new FunctionPermissionModel
                    {
                        Function   = function,
                        Permission = writePermission,
                        ChangedBy  = Guid.Empty
                    });
                    function.FunctionPermissions.Add(new FunctionPermissionModel
                    {
                        Function   = function,
                        Permission = readPermission,
                        ChangedBy  = Guid.Empty
                    });

                    context.Function.Add(function);
                    context.SaveChanges();
                }


                // Create the bootsrap Role.
                var bootstrapRole = context.Role.Where(r => r.Name == "a3s-bootstrap").FirstOrDefault();

                if (bootstrapRole == null)
                {
                    bootstrapRole = new RoleModel();
                    bootstrapRole.RoleFunctions = new List <RoleFunctionModel>();
                    bootstrapRole.Name          = "a3s-bootstrap";
                    bootstrapRole.Description   = "A3S bootstrap role for applying security contracts.";
                    bootstrapRole.ChangedBy     = Guid.Empty;
                    bootstrapRole.RoleFunctions.Add(new RoleFunctionModel
                    {
                        Role      = bootstrapRole,
                        Function  = function,
                        ChangedBy = Guid.Empty
                    });

                    context.Role.Add(bootstrapRole);
                    context.SaveChanges();
                }

                // Check to see if the admin user is already present.
                var adminUser = context.User.Where(u => u.UserName == "a3s-bootstrap-admin").FirstOrDefault();

                if (adminUser != null)
                {
                    return;
                }

                adminUser                          = new UserModel();
                adminUser.FirstName                = "Bootstrap";
                adminUser.Surname                  = "Admin";
                adminUser.UserName                 = "******";
                adminUser.NormalizedUserName       = "******";
                adminUser.Email                    = "a3s-bootstrap-admin@localhost";
                adminUser.NormalizedEmail          = "A3S-BOOTSTRAP-ADMIN@LOCALHOST";
                adminUser.EmailConfirmed           = true;
                adminUser.LdapAuthenticationModeId = null;
                adminUser.ChangedBy                = Guid.Empty;

                var userManager = serviceScope.ServiceProvider.GetRequiredService <UserManager <UserModel> >();

                IdentityResult result = userManager.CreateAsync
                                            (adminUser, "Password1#").Result;

                if (result.Succeeded)
                {
                    adminUser = context.User.Where(u => u.UserName == "a3s-bootstrap-admin")
                                .Include(u => u.UserRoles)
                                .ThenInclude(ur => ur.Role)
                                .FirstOrDefault();

                    adminUser.UserRoles.Add(new UserRoleModel {
                        User      = adminUser,
                        Role      = bootstrapRole,
                        ChangedBy = Guid.Empty
                    });

                    context.Entry(adminUser).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
        }
Пример #28
0
        public ActionResult Index()
        {
            var model = new RoleModel();

            return(View(model));
        }
Пример #29
0
 public void Update(Role role, RoleModel roleModel)
 {
     role.Name = roleModel.Name;
     role.Code = roleModel.Code;
 }
Пример #30
0
 public async Task CreateRoleAsync(RoleModel args)
 {
     await PostAsync($"/api/identity/role", args);
 }
Пример #31
0
        public async Task<HttpResponseMessage> Post(RoleModel entity)
        {
            entity.ID = Guid.NewGuid().ToString("N");

            try
            {
                var result = await Service.InsertAsync(Mapper.Map<IRole>(entity));

                if (result == 0)
                    return Request.CreateResponse(HttpStatusCode.BadRequest, "Add operation error.");

                return Request.CreateResponse(HttpStatusCode.OK, result);
            }
            catch (Exception e)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest, e.Message);
            }
        }
Пример #32
0
 public bool checkRole(string strWhere)
 {
     this.rm = new RoleDal();
     this.dbo = new DB_OPT();
     return (this.rm.GetList(strWhere, this.dbo).Tables[0].Rows.Count > 0);
 }
        private async Task ApplyFunctionsToDefaultRole(SecurityContractDefaultConfigurationRole defaultRole, RoleModel defaultRoleToApply, Guid updatedById)
        {
            defaultRoleToApply.RoleFunctions = new List <RoleFunctionModel>();

            if (defaultRole.Functions != null && defaultRole.Functions.Count > 0)
            {
                foreach (var functionToAdd in defaultRole.Functions)
                {
                    logger.Debug($"Attempting to add function: '{functionToAdd}' to role '{defaultRole.Name}'.");
                    // Ensure that the function exists.
                    var existingFunction = await functionRepository.GetByNameAsync(functionToAdd);

                    if (existingFunction == null)
                    {
                        logger.Warn($"Function '{functionToAdd}' does not exists. Not assinging it to role '{defaultRole.Name}'.");
                        break;
                    }

                    logger.Debug($"Function '{functionToAdd}' exists and is being assigned to role '{defaultRole.Name}'.");
                    defaultRoleToApply.RoleFunctions.Add(new RoleFunctionModel
                    {
                        Role      = defaultRoleToApply,
                        Function  = existingFunction,
                        ChangedBy = updatedById
                    });
                }
            }
        }
        private async Task ApplyParentRolesToDefaultRole(SecurityContractDefaultConfigurationRole defaultRole, RoleModel defaultRoleToApply, Guid updatedById)
        {
            defaultRoleToApply.ChildRoles = new List <RoleRoleModel>();

            if (defaultRole.Roles != null && defaultRole.Roles.Count > 0)
            {
                foreach (var roleToAdd in defaultRole.Roles)
                {
                    logger.Debug($"Attempting to add child role: '{roleToAdd}' to role '{defaultRole.Name}'.");

                    // Ensure that the role exists.
                    var existingchildRole = await roleRepository.GetByNameAsync(roleToAdd);

                    if (existingchildRole == null)
                    {
                        logger.Warn($"Child role '{existingchildRole}' does not exists. Not assinging it to role '{defaultRole.Name}'.");
                        break;
                    }

                    logger.Debug($"Child role '{existingchildRole}' exists and is being assigned to role '{defaultRole.Name}'.");
                    defaultRoleToApply.ChildRoles.Add(new RoleRoleModel
                    {
                        ParentRole = defaultRoleToApply,
                        ChildRole  = existingchildRole,
                        ChangedBy  = updatedById
                    });
                }
            }
        }
 //
 // GET: /Roles/Edit/5
 public ActionResult Edit(string roleName)
 {
     RoleModel model = new RoleModel();
     var allUsers = Membership.GetAllUsers();
     string[] userRoles = Roles.GetUsersInRole(roleName);
     model.SelectedUsers = userRoles;
     model.Users = new MultiSelectList(allUsers, "UserName", "UserName" ,userRoles);
     model.RoleName = roleName;
     return View(model);
 }
Пример #36
0
 public ActionResult Edit(RoleModel rolemodel)
 {
     if (ModelState.IsValid)
     {
         string oldRoleName = Request.Form["oldRole"].ToString();
         if (oldRoleName != rolemodel.RoleName)
         {
             Roles.CreateRole(rolemodel.RoleName);
             string[] usernames = Roles.GetUsersInRole(oldRoleName);
             if (usernames.Count() > 0)
             {
                 Roles.AddUsersToRole(usernames, rolemodel.RoleName);
                 Roles.RemoveUsersFromRole(usernames, oldRoleName);
             }
             Roles.DeleteRole(oldRoleName);
         }
         return RedirectToAction("Index");
     }
     ViewBag.oldRole = Request.Form["oldRole"].ToString();
     return View(rolemodel);
 }
Пример #37
0
 public async Task UpdateRole(RoleModel args)
 {
     await PutAsync("/api/identity/role", args);
 }
        private SecurityContractDefaultConfigurationRole RetrieveIndividualDefaultConfigRole(RoleModel role)
        {
            logger.Debug($"Retrieving default configuration contract definition for Role [{role.Name}].");

            var contractRole = new SecurityContractDefaultConfigurationRole()
            {
                Name        = role.Name,
                Description = role.Description,
                Functions   = new List <string>(),
                Roles       = new List <string>()
            };

            foreach (var function in role.RoleFunctions.OrderBy(o => o.Function.SysPeriod.LowerBound))
            {
                contractRole.Functions.Add(function.Function.Name);
            }

            foreach (var childRole in role.ChildRoles.OrderBy(o => o.ChildRole.SysPeriod.LowerBound))
            {
                contractRole.Roles.Add(childRole.ChildRole.Name);
            }

            return(contractRole);
        }
Пример #39
0
        private void UpdateRoles()
        {
            foreach (var role in Roles.Select(x => new { x.Id, Name = x.Name }).Where(x => !ActiveDirectorySettings.RoleNameToGroupNameMapping.Keys.Contains(x.Name, StringComparer.OrdinalIgnoreCase)))
            {
                Roles.Remove(role.Id);
            }

            PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, ActiveDirectorySettings.DefaultDomain);
            foreach (string roleName in ActiveDirectorySettings.RoleNameToGroupNameMapping.Keys)
            {
                GroupPrincipal group = GroupPrincipal.FindByIdentity(principalContext, IdentityType.Name, ActiveDirectorySettings.RoleNameToGroupNameMapping[roleName]);

                RoleModel roleModel = new RoleModel()
                {
                    Id = group.Guid.Value,
                    Name = roleName,
                    Members = group.GetMembers(true).Where(x => x is UserPrincipal).Select(x => x.Guid.Value).ToArray()
                };
                Roles.AddOrUpdate(roleModel);
            }
        }
Пример #40
0
 public RoleImpl(RoleModel model)
 {
     Name  = model.RoleName;
     Group = model.GroupName;
 }
Пример #41
0
 public ActionResult Index()
 {
     List<RoleModel> roles = new List<RoleModel>();
     foreach (string roleName in Roles.GetAllRoles())
     {
         RoleModel newRole = new RoleModel();
         newRole.RoleName = roleName;
         roles.Add(newRole);
     }
     return View(roles);
 }
    public void MoveRole(RoleModel role)//移动角色
    {
        if (user_gui.sign != 0)
        {
            return;
        }
        if (role.IsOnBoat())
        {
            BankModel land;
            if (boat.GetBoatSign() == -1)
            {
                land = end_land;
            }
            else
            {
                land = start_land;
            }
            boat.DeleteRoleByName(role.GetName());
            Debug.Log("DeleteRoleByName");
            Debug.Log(role.GetName());

            //role.Move(land.GetEmptyPosition());
            //动作分离版本改变
            Debug.Log(land.GetBankSign());
            Vector3 end_pos = land.GetEmptyPosition();
            Debug.Log(end_pos);
            Vector3 middle_pos = new Vector3(role.getGameObject().transform.position.x, end_pos.y, end_pos.z);
            Debug.Log(middle_pos);
            actionManager.moveRole(role.getGameObject(), middle_pos, end_pos, role.move_speed);


            role.GoLand(land);
            land.AddRole(role);
        }
        else
        {
            BankModel land = role.GetBankModel();
            ///船没有空位,也不是停靠的陆地,就不上船
            if (boat.GetEmptyNumber() == -1 || land.GetBankSign() != boat.GetBoatSign())
            {
                return;
            }

            land.DeleteRoleByName(role.GetName());

            //role.Move(boat.GetEmptyPosition());
            //动作分离版本改变
            Vector3 end_pos = boat.GetEmptyPosition();
            Debug.Log("?????");
            Vector3 middle_pos = new Vector3(end_pos.x, role.getGameObject().transform.position.y, end_pos.z);
            actionManager.moveRole(role.getGameObject(), middle_pos, end_pos, role.move_speed);


            role.GoBoat(boat);
            boat.AddRole(role);
        }
        user_gui.sign = judge.Check((start_land.GetRoleNum())[0], (start_land.GetRoleNum())[1], (end_land.GetRoleNum())[0], (end_land.GetRoleNum())[1]);
        if (user_gui.sign == 1)
        {
            for (int i = 0; i < RoleAmount; i++)
            {
                roles[i].PlayGameOver();
                roles[i + RoleAmount].PlayGameOver();
            }
        }
    }
Пример #43
0
        public ActionResult EditRole(RoleModel model)
        {
            RoleEdit(model.BusinessRolesKey, model.Description, model.EditUsers, model.MakeSurvey, model.EditSurvey, model.AssignSurvey, model.ModifyBy);

            return(RedirectToAction("RoleView"));
        }
Пример #44
0
        public ActionResult AddRole(RoleModel model)
        {
            CreateRole(model.Description, model.InsertBy);

            return(RedirectToAction("RoleView"));
        }
Пример #45
0
 private void ChildDataBindRole(string strPK)
 {
     try
     {
         this.dbo = new DB_OPT();
         this.dbo.Open();
         this.role = new RoleDal();
         DataSet list = new DataSet();
         list = this.role.GetList(" BranchPK='" + strPK + "'", this.dbo);
         if ((list != null) && (list.Tables[0].Rows.Count > 0))
         {
             this.gvResult2.DataSource = list;
             this.gvResult2.DataBind();
         }
         else
         {
             DataTable table = new DataTable();
             table = list.Tables[0];
             DataRow row = table.NewRow();
             table.Rows.Add(row);
             this.gvResult2.DataSource = table.DefaultView;
             this.gvResult2.DataBind();
         }
     }
     catch (Exception exception)
     {
         this.el = new ExceptionLog.ExceptionLog();
         this.el.ErrClassName = base.GetType().ToString();
         this.el.ErrMessage = exception.Message.ToString();
         this.el.ErrMethod = "ChildDataBindRole()";
         this.el.WriteExceptionLog(true);
         Const.OpenErrorPage("获取数据失败,请联系系统管理员!", this.Page);
     }
     finally
     {
         if (this.dbo != null)
         {
             this.dbo.Close();
         }
     }
 }
Пример #46
0
        public ActionResult DeleteRole(RoleModel model)
        {
            RoleDelete(model.BusinessRolesKey, model.DeletedBy);

            return(RedirectToAction("RoleView"));
        }
Пример #47
0
 private void DataDelete(string strPK, string bh, string name, string company, string branch)
 {
     try
     {
         this.dbo = new DB_OPT();
         this.dbo.Open();
         this.rm = new RoleDal();
         this.rm.RolePK = strPK;
         this.rm.Delete(this.dbo);
         OperationLogBll.insertOp("删除", "角色列表", "删除 " + company + " 单位, " + branch + "部门下编号为:" + bh + " 名称为:" + name + " 的角色", "Y", this.Page);
         if (this.Master.PageIndex > 1)
         {
             this.pageind = this.Master.PageIndex;
         }
         this.ShowData(this.Master.StrSelect);
     }
     catch (Exception exception)
     {
         this.el = new ExceptionLog.ExceptionLog();
         this.el.ErrClassName = base.GetType().ToString();
         this.el.ErrMessage = exception.Message.ToString();
         this.el.ErrMethod = "DataDelete()";
         this.el.WriteExceptionLog(true);
         Const.OpenErrorPage("操作失败,请联系系统管理员!", this.Page);
     }
     finally
     {
         if (this.dbo != null)
         {
             this.dbo.Close();
         }
     }
 }
Пример #48
0
 protected string CreateRole(RoleModel model)
 {
     return _dalRole.CreateRole(model.ToHashTable());
 }