public ActionResult AuthorizationItemEdit(int authorizationId, AuthorizationModel authorizationModel) { try { var authorizationItems = RoleModuleService.GetAll(authorizationId); foreach (var authorizationItem in authorizationItems) { RoleModuleService.DeleteReal(authorizationItem.Id); } var newItems = authorizationModel.RoleModules?.ToList(); if (newItems != null) { foreach (var item in newItems) { var a = new RoleModule { RoleId = authorizationId, ModuleId = item }; RoleModuleService.Add(a); } } } catch (Exception e) { Logger.Error("Hata oluştu - " + new StackTrace().GetFrame(0).GetMethod().Name, e); } return(RedirectToAction("AuthorizationList")); }
public JsonResult RemoveFeatureItem(string id) { var module = new RoleModule(CurrentUser); var data = module.Remove(id); return(Json(new { code = 0, msg = "Ok", data = data })); }
public JsonResult RemoveFeature(string roleId, string menuId) { var module = new RoleModule(CurrentUser); var data = module.Remove(roleId, menuId); return(Json(new { code = 0, msg = "Ok", data = data })); }
private JavaScriptObject UserInfoToJSON(SysUser user, ref DataTable dtExcel) { if (user == null) { return(null); } JavaScriptObject obj2 = new JavaScriptObject(); /* * foreach (KeyValuePair<string, string> pair in user.GetUserInfo()) * { * obj2.Add(pair.Key, pair.Value); * } * */ obj2.Add("ID", user.ID); obj2.Add("用户名", user.UserName); obj2.Add("角色ID", user.RoleId); obj2.Add("管理ID", user.DistrictId); string managelName = DistrictModule.GetDistrictName(user.DistrictId); obj2.Add("管理名称", managelName); string roleName = RoleModule.GetRoleName(user.RoleId); obj2.Add("角色名称", roleName); if (dtExcel != null) { dtExcel.Rows.Add(new object[0]); int num = dtExcel.Rows.Count - 1; dtExcel.Rows[num]["用户名"] = user.UserName; dtExcel.Rows[num]["角色名称"] = roleName; dtExcel.Rows[num]["单位名称"] = managelName; } return(obj2); }
public void InsertRoleModules(string strRole, List <int> listModule) { try { IncidentEntities db = new IncidentEntities(); for (int i = 0; i < listModule.Count; i++) { RoleModule objRoleModule = new RoleModule() { RoleID = strRole, ModuleID = listModule[i] }; db.RoleModule.Add(objRoleModule); db.SaveChanges(); } } catch (DbEntityValidationException e) { foreach (var entityValidationErrors in e.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { HttpContext.Current.Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } } }
/// <summary> /// 更新用户权限 /// </summary> /// <param name="roleModules"></param> /// <returns></returns> public int UpdateRole(List <RoleModule> roleModules) { foreach (RoleModule roleModule in roleModules) { RoleModule old = roleModuleRepository.FindSingle(q => q.ModuleId == roleModule.ModuleId && q.RoleId == roleModule.RoleId); if (old == null) { if (roleModule.Enabled) { roleModuleRepository.Insert(roleModule, false); // 新增权限 } } else if (!roleModule.Enabled) { roleModuleRepository.Delete(old.ID, false);//删除未授权的条目 } else { old.Enabled = roleModule.Enabled; old.Permissions = roleModule.Permissions; roleModuleRepository.Update(old, false); // 修改已存在权限 } } return(Context.Commit()); }
private void InitRoleModule(RoleSystem roleSystem) { foreach (var module in roleSystem.System.Modules) { var roleModules = roleSystem.RoleModules.Where(rm => rm.Module.ModuleID == module.ModuleID && rm.RoleSystem.System.SystemID == roleSystem.System.SystemID); if (roleModules.Count() == 0) { RoleModule rm = new RoleModule() { RoleModuleID = Guid.NewGuid(), RoleSystem = roleSystem, Module = module, IsActive = false }; roleSystem.IsActive = false; SetParentRoleModuleIsActiveFalse(rm); RoleModuleRepository.Add(rm); RoleModuleRepository.SaveChanges(); } var roleModule = roleSystem.RoleModules.Single(rm => rm.Module.ModuleID == module.ModuleID && rm.RoleSystem.System.SystemID == roleSystem.System.SystemID); InitRoleFunctions(roleModule); } }
private void btnALL_Click(object sender, RoutedEventArgs e) { if (isRunning) { Global.LstInfo = new System.Collections.ObjectModel.ObservableCollection <string>(); Global.LstInfo.Add("已经有测试用例在执行!"); return; } isRunning = true; //德雅管理后台 DentureLoginModule.LoginAllTest(); HospitalModule.HospitalAllTest(); DoctorModule.DoctorAllTest(); DentureModule.DentureAllTest(); RoleModule.RoleAllTest(); DoctorModule.DoctorAllTest(); //Dentlab 客户端 DoctorLoginModule.LoginAllTest(); FactoryHospitalModule.HospitalAllTest(); TechnicianListModule.TechnicianAllTest(); UploadReportModule.DoctorAllTest(); isRunning = false; this.Activate(); }
public ActionResult Edit(string roleId, string txtCheckList = "") { if (string.IsNullOrEmpty(roleId)) { return(RedirectToAction("Index")); } int idNo = Convert.ToInt32(roleId); try { List <string> moduleIdList = txtCheckList.Split(',').ToList(); List <int> moduleIdListNo = moduleIdList. Select(x => Convert.ToInt32(x)) .Distinct() .ToList(); int retVal = RoleModule.UpdateRoleModule(moduleIdListNo, idNo); ViewBag.Message = "Module updated successfully."; } catch { ViewBag.Message = "Update failed. Please try again later."; } RoleModule rm = RoleModule.GetRoleModule(idNo); return(View(rm)); }
/// <summary> /// Starts discord client. /// </summary> /// <returns> /// returns nothing, awaiting commands to be executed. /// </returns> public async Task MainAsync() { RoleModule roleModule = new RoleModule(); using ServiceProvider services = ConfigureServices(); var socketConfig = new DiscordSocketConfig { ExclusiveBulkDelete = true }; client = new DiscordSocketClient(socketConfig); DiscordSocketClient getClient = services.GetRequiredService <DiscordSocketClient>(); client = getClient; client.UserJoined += roleModule.UserJoined; // Setup loggingservice and ready event. services.GetRequiredService <LoggingService>(); //await client.LoginAsync(TokenType.Bot, config["Token"]); await client.LoginAsync(TokenType.Bot, token : $"{Environment.GetEnvironmentVariable("BotToken")}", true); await client.StartAsync(); // Get the command handler class here. // Initialize async method to start things up. await services.GetRequiredService <CommandHandler>().InitializeAsync(); // Create a task, that completes after a delay. // -1 to wait indefinitely. await Task.Delay(-1); }
public string DeleteRole(string loginIdentifer, string roleId) { JavaScriptObject obj2 = new JavaScriptObject(); obj2.Add("Result", false); obj2.Add("Message", ""); LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer); if (loginUser == null) { obj2["Message"] = "未登录"; return(JavaScriptConvert.SerializeObject(obj2)); } if (loginUser.LoginTimeout) { obj2["Message"] = "登录超时"; return(JavaScriptConvert.SerializeObject(obj2)); } loginUser.LastOperateTime = DateTime.Now; try { string str = "删除失败"; if (SysUserModule.GetUserListByRole(long.Parse(roleId)).Count > 0) { str = "无法删除有用户数量的角色"; } else { if (RoleModule.DeleteRole(long.Parse(roleId))) { str = "删除成功"; MenuModule.DeleteRoleMenuByRoleId(long.Parse(roleId)); obj2["Result"] = true; } } obj2["Message"] = str; } catch (Exception exception) { obj2["Message"] = exception.Message; } try { SysLog log = new SysLog(); log.LogUserId = loginUser.UserId; log.LogUserName = loginUser.LoginName; log.LogAddress = ToolsWeb.GetIP(context.Request); log.LogTime = DateTime.Now; log.LogType = "删除角色"; log.LogContent = obj2["Message"].ToString() + "|" + roleId; SysLogModule.Add(log); } catch { } return(JavaScriptConvert.SerializeObject(obj2)); }
public JsonResult Tree(string orgId) { var module = new RoleModule(CurrentUser); var items = module.FeatchAll(orgId); var data = items.Select(t => new ComboTreeModel { children = new ComboTreeModel[0], id = t.Id, text = t.Name }).ToArray(); return(Json(data, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(string id) { if (string.IsNullOrEmpty(id)) { return(RedirectToAction("Index")); } int idNo = Convert.ToInt32(id); RoleModule rm = RoleModule.GetRoleModule(idNo); return(View(rm)); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (_isEnable) { if (SessionInfo.UserID != null) //判断是否登录 { var route = filterContext.RouteData.Values; if (_type == "menu") //菜单权限 { #region 验证菜单权限 var link = string.Format("/{0}/{1}", route["controller"], route["action"]); DataTable dt = new RoleModule().GetRoleModule(Convert.ToInt32(SessionInfo.UserID), link); if (dt.Rows.Count > 0) { var strButton = new RoleModButton().GetButtonHtml(Convert.ToInt32(SessionInfo.UserID), Convert.ToInt32(dt.Rows[0]["ModID"])); //返回页面按钮 filterContext.Controller.ViewBag.btnHtml = strButton; } else { filterContext.Result = new ContentResult() { Content = "<strong>您没有访问此功能的权限,请联系管理员!</strong>" }; } #endregion } else if (_type == "btn") //按钮/弹出页面权限 { #region 验证按钮权限 string action = filterContext.RouteData.Values["Action"].ToString(); var id = filterContext.RouteData.Values["id"]; //如果存在id是编辑,否则是添加 if (action == "Edit" && (id == null || id.ToString() == "0")) { action = "Add"; } bool b = new RoleModButton().IsButtonPower(Convert.ToInt32(SessionInfo.UserID), _pageUrl, action); if (!b) { filterContext.Result = new ContentResult() { Content = "<strong>您没有访问此功能的权限,请联系管理员!</strong>" }; } #endregion } } else { filterContext.Result = new RedirectResult("/Home/ReturnTo"); } } base.OnActionExecuting(filterContext); }
private void SetParentRoleModuleIsActiveFalse(RoleModule roleModule) { var parentRoleModule = roleModule.Module.ParentModule.RoleModules.FirstOrDefault(prm => prm.RoleSystem.Role.RoleID == roleModule.RoleSystem.Role.RoleID); if (parentRoleModule != null) { parentRoleModule.IsActive = false; if (parentRoleModule.Module.ModuleID != parentRoleModule.Module.ParentModule.ModuleID) { SetParentRoleModuleIsActiveFalse(parentRoleModule); } } }
/// <summary> /// 角色管理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRole_Click(object sender, RoutedEventArgs e) { if (isRunning) { Global.LstInfo = new System.Collections.ObjectModel.ObservableCollection <string>(); Global.LstInfo.Add("已经有测试用例在执行!"); return; } isRunning = true; RoleModule.RoleAllTest(); isRunning = false; this.Activate(); }
public JsonResult RoleFormSubmit(string orgId, string name, string remark) { var module = new RoleModule(CurrentUser); var role = new Role { IsDel = (short)DeleteStatus.No, Name = name, OrgId = orgId, Remarks = remark, Status = (short)AccountStatus.Normal }; var data = module.Add(role); return(Json(new { code = 0, msg = "Ok", data = data }, "text/html")); }
public RoleModule GetRoleModule(int roleId) { string sqlString = string.Empty; sqlString += "SELECT ID, NAME, ISDEFAULT, ISACTIVE FROM [ROLES] WHERE ID = @RoleId; "; sqlString += "select b.ID, b.[Name], b.DESCRIPTION, b.LINKURL, b.PARENTID, b.SORTID, " + "(select Count(MODULE_ID) from ROLEMODULES WHERE ROLE_ID = @RoleId AND MODULE_ID = b.ID) as IsAuth " + "FROM MODULES b WHERE ISDELETED = 0;"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@RoleId", roleId) }; DataSet ds = QuerySet(sqlString, param); //table[0] = Role //table[1] = Module RoleModule roleModule = new RoleModule(); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; RoleRPS rle = new RoleRPS { ID = Convert.ToInt32(dr["ID"]), Name = dr["NAME"].ToString(), IsActive = Convert.ToBoolean(dr["ISACTIVE"]), IsDefault = Convert.ToBoolean(dr["ISDEFAULT"]) }; roleModule.Role = rle; } if (ds.Tables[1].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[1].Rows) { ModuleRPS mod = new ModuleRPS { ID = Convert.ToInt32(dr["id"]), Name = dr["Name"].ToString(), Description = dr["DESCRIPTION"].ToString(), LinkURL = dr["LINKURL"].ToString(), ParentId = Convert.ToInt32(dr["PARENTID"]), SortId = Convert.ToInt32(dr["SORTID"]), IsAuthorized = Convert.ToInt32(dr["IsAuth"]) > 0 ? true : false }; roleModule.Module.Add(mod); } } return(roleModule); }
public void TestEditRole() { Role editRole = (userService.GetRoles().ToList()).Last(); editRole.Label += " - Test de modification"; List <Module> modules = userService.GetModules().ToList(); RoleModule roleModule = new RoleModule(); roleModule.Role_id = editRole.Id; roleModule.Module_id = modules[1].Id; editRole.RoleModules.Add(roleModule); Assert.IsNotNull(userService.EditRole(editRole)); }
public JsonResult AddFeatureItem(string roleId, string menuId, string featureId) { var module = new RoleModule(CurrentUser); var ftype = FeatureTypeHelper.Items.First(t => t.Name == featureId); var feature = new Feature { ActId = featureId, ActRemark = ftype.Summary, IsDel = (short)DeleteStatus.No, MenuId = menuId, RoleId = roleId, Status = 0 }; var data = module.Add(feature); return(Json(new { code = 0, msg = "Ok", data = data }, "text/html")); }
private void SetFunTree(Tree childTree, Module item, RoleModule roleModules) { var function = FunctionRepository.GetQueryable().Where(f => f.Module.ModuleID == item.ModuleID); IQueryable <THOK.Authority.DbModel.RoleFunction> queryRoleFunction = RoleFunctionRepository.GetQueryable(); HashSet <Tree> functionTreeSet = new HashSet <Tree>(); foreach (var func in function) { Tree funcTree = new Tree(); var roleFunction = queryRoleFunction.FirstOrDefault(rf => rf.Function.FunctionID == func.FunctionID && rf.RoleModule.RoleModuleID == roleModules.RoleModuleID); funcTree.id = roleFunction.RoleFunctionID.ToString(); funcTree.text = "功能:" + func.FunctionName; funcTree.@checked = roleFunction == null ? false : roleFunction.IsActive; funcTree.attributes = "function"; functionTreeSet.Add(funcTree); } childTree.children = functionTreeSet.ToArray(); }
private Role CreateTestRole() { Role newRole = new Role(); newRole.Label = "Role de test"; RoleModule rm = userService.GetModules().First().RoleModules.First(); newRole.RoleModules.Add(new RoleModule() { Module = rm.Module, Module_id = rm.Module_id, Role = rm.Role, Role_id = rm.Role_id }); return(userService.CreateRole(newRole)); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); NinjectModule serviceModule = new ServiceModule("DefaultConnection"); NinjectModule roleModule = new RoleModule(); NinjectModule userModule = new UserModule(); NinjectModule patientModule = new PatientModule(); NinjectModule doctorModule = new DoctorModule(); NinjectModule specialityModule = new SpecialityModule(); NinjectModule recordModule = new RecordModule(); var kernel = new StandardKernel(serviceModule, roleModule, userModule, patientModule, doctorModule, specialityModule, recordModule); DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel)); }
public string GetUserRoles(string loginIdentifer) { JavaScriptObject obj2 = new JavaScriptObject(); obj2.Add("Result", false); obj2.Add("Message", ""); JavaScriptArray array = new JavaScriptArray(); obj2.Add("UserRoles", array); LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer); if (loginUser == null) { obj2["Message"] = "未登录"; return(JavaScriptConvert.SerializeObject(obj2)); } if (loginUser.LoginTimeout) { obj2["Message"] = "登录超时"; return(JavaScriptConvert.SerializeObject(obj2)); } loginUser.LastOperateTime = DateTime.Now; CommonUtil.WaitMainLibInit(); try { foreach (long str in RoleModule.GetRoleID()) { JavaScriptObject item = new JavaScriptObject(); item.Add("ID", str); item.Add("Name", RoleModule.GetRoleName(str)); item.Add("UserCount", SysUserModule.GetUserListByRole(str).Count); array.Add(item); } } catch (Exception exception) { obj2["Message"] = exception.Message; return(JavaScriptConvert.SerializeObject(obj2)); } obj2["Result"] = true; return(JavaScriptConvert.SerializeObject(obj2)); }
public JObject GetData() { var module = new RoleModule(CurrentUser); var list = new List <RoleMenuFeatureModel>(); var items = module.FeatchAll().ToList(); items.ForEach( t => { list.Add(new RoleMenuFeatureModel { role = t.role, features = new FeatureModel[0], menu = null }); list.AddRange(t.menus.Where(x => !string.IsNullOrWhiteSpace(x.menu.Title))); }); var data = TableRoleDataModel.Model.GetJson(list, TableRoleHeaderModel.Header); return(data); }
public Role EditRole(Role roleToEdit) { if (roleToEdit == null) { return(null); } var listToAdd = new List <RoleModule>(); using (SUPERPEntities context = new SUPERPEntities(false)) { var r = context.Roles.Include("RoleModules").Include("RoleModules.Module").Include("RoleModules.Role").FirstOrDefault(x => x.Id == roleToEdit.Id); if (r == null) { return(null); } context.RoleModules.RemoveRange(r.RoleModules); context.SaveChanges(); r.RoleModules.Clear(); foreach (var rm in roleToEdit.RoleModules) { RoleModule rrm = null; if ((rrm = r.RoleModules.FirstOrDefault(x => x.Id == rm.Id)) == null) { listToAdd.Add(new RoleModule() { Module_id = rm.Module_id, Role_id = rm.Role_id }); } } context.RoleModules.AddRange(listToAdd); r.Label = roleToEdit.Label; context.SaveChanges(); return(r); } }
private void InitRoleFunctions(RoleModule roleModule) { foreach (var function in roleModule.Module.Functions) { var roleFunctions = roleModule.RoleFunctions.Where(rf => rf.Function.FunctionID == function.FunctionID); if (roleFunctions.Count() == 0) { RoleFunction rf = new RoleFunction() { RoleFunctionID = Guid.NewGuid(), RoleModule = roleModule, Function = function, IsActive = false }; roleModule.RoleSystem.IsActive = false; SetParentRoleModuleIsActiveFalse(roleModule); roleModule.IsActive = false; RoleFunctionRepository.Add(rf); RoleFunctionRepository.SaveChanges(); } } }
// Created by PS2019 //To update module protected void UpdateModule(object sender, EventArgs e) { try { RoleModuleModel objRoleModuleModel = new RoleModuleModel(); RoleModule objRoleModule = new RoleModule(); objRoleModuleModel.DeleteRoleMonitor(ddlRoles.SelectedItem.Value); List <int> lstModules = new List <int>(); for (int i = 0; i < cbxRoleModules.Items.Count; i++) { if (cbxRoleModules.Items[i].Selected == true) { lstModules.Add(Convert.ToInt32(cbxRoleModules.Items[i].Value.ToString())); } } objRoleModuleModel.InsertRoleModules(ddlRoles.SelectedItem.Value, lstModules); DisplayEmail.Visible = true; } catch (Exception err) { Console.Write(err); } }
public ActionResult ManageModulesForRole(long?id, long?module, string key) { try { var record = new RoleModule(); record.ModuleId = (long)module; record.RoleId = (long)id; record.Status = 1; var roleModuleBusiness = new RoleModuleBusiness(); roleModuleBusiness.AddNew(record); return(ManageModulesForRole(id, 1)); } catch (FaultException ex) { var exep = Function.GetExeption(ex); var codeExp = exep[1]; string url = "Error/ErrorFunction/" + codeExp; return(RedirectToActionPermanent(url)); } }
/// <summary> /// 保存选择的角色 /// </summary> /// <param name="roleIds">角色数组</param> /// <param name="moduleId">当前模块ID</param> /// <param name="changeUser">修改人ID</param> public void SaveModuleRoles(List <int> roleIds, int moduleId, int changeUser) { using (AuthentContext db = new AuthentContext()) { //先要删除这个模块的角色 var roles = db.RoleModule.Where(rm => rm.ModuleId == moduleId); db.RoleModule.RemoveRange(roles); //再重新保存 List <RoleModule> roleModels = new List <RoleModule>(); foreach (var roleId in roleIds) { RoleModule roleModel = new RoleModule(); roleModel.ModuleId = moduleId; roleModel.RoleId = roleId; roleModel.LastChangeTime = DateTime.Now; roleModel.LastChangeUser = changeUser; roleModels.Add(roleModel); } db.RoleModule.AddRange(roleModels); db.SaveChanges(); } }
public RoleManager(ApplicationDbContext dbContext) : base(dbContext) { _roleModule = new RoleModule(DbContext); }