protected void LoadRoles(int appID) { RoleManager roleManger = new RoleManager(); RoleCollection roles = new RoleCollection(); try { roles = roleManger.GetRoleInApplication(appID); cmbRoles.Items.Clear(); if (roles.Count > 0) { cmbRoles.DataSource = roles; cmbRoles.DataTextField = "RoleName"; cmbRoles.DataValueField = "RoleID"; cmbRoles.DataBind(); cmbRoles.SelectedIndex = 0; } } catch (Exception ex) { uctErrorBox.Visible = true; uctErrorBox.Message = "Có lỗi hệ thống"; this.SaveErrorLog(ex); } }
private void LoadRoles(List <int> appIDs) { RoleManager roleMange = new RoleManager(); RoleCollection roles = new RoleCollection(); CheckBoxList cbList; ListItem listItem; int i = 0; foreach (int appID in appIDs) { roles = roleMange.GetRoleInApplication(appID); cbList = (CheckBoxList)rptTabContent.Items[i].FindControl("cblRoles"); foreach (Role role in roles) { listItem = new ListItem(role.RoleName, role.RoleID.ToString()); listItem.Enabled = true; cbList.Items.Add(listItem); } if (cbList.Items.Count > numberofItemInColumn) { cbList.RepeatColumns = cbList.Items.Count / numberofItemInColumn + 1; } i++; } }
/// <summary> /// Checks the PermissionCollection class to determine if the /// indicated operation is allowed for the person identified by /// their ID number. /// </summary> /// <param name="permissions">The collection of permissions to check. These should be object permissions.</param> /// <param name="personID">The ID number of the user whose security access we are checking.</param> /// <param name="operation">The type of access the user needs to proceed.</param> /// <returns>true/false indicating if the operation is allowed.</returns> static public bool PermissionsOperationAllowed(PermissionCollection permissions, int personID, OperationType operation) { RoleCollection roles; int i; // // Check if the person has direct permission. // if (permissions.ContainsSubjectOperation(SubjectType.Person, personID, operation) == true) { return(true); } // // Now check all roles for the given person. // roles = new RoleCollection(DefaultOrganizationID(), personID); for (i = 0; i < roles.Count; i++) { if (permissions.ContainsSubjectOperation(SubjectType.Role, roles[i].RoleID, operation) == true) { return(true); } } return(false); }
protected override bool ValidateRoleDate(RoleCollection roles, MessageDisplay msgdisp) { bool returnValue = true; for (int i = 0; i < roles.Count; i++) { if (string.IsNullOrEmpty(roles[i].Title) || roles[i].Title.Trim() == string.Empty) { msgdisp.AddError("title", i, Lang_Error.Role_EmptyTitleError); returnValue = false; } for (int j = i + 1; j < roles.Count; j++) { if (i != j) { if (roles[i].RequiredPoint == roles[j].RequiredPoint) { msgdisp.AddError("RequiredPoint", i, string.Format(Lang_Error.Role_DuplicatePointError, i + 1, j + 1)); msgdisp.AddError("RequiredPoint", j, string.Format(Lang_Error.Role_DuplicatePointError, j + 1, i + 1)); returnValue = false; } } } } return(returnValue); }
protected override bool ValidateRoleDate(RoleCollection roles, MessageDisplay msgdisp) { bool returnValue = true; for (int i = 0; i < roles.Count; i++) { if (string.IsNullOrEmpty(roles[i].Title) || roles[i].Title.Trim() == string.Empty) { msgdisp.AddError("title", i, Lang_Error.Role_EmptyTitleError); returnValue = false; } for (int j = i + 1; j < roles.Count; j++) { if (i!=j) { if (roles[i].RequiredPoint == roles[j].RequiredPoint) { msgdisp.AddError("RequiredPoint", i, string.Format(Lang_Error.Role_DuplicatePointError,i+1,j+1)); msgdisp.AddError("RequiredPoint", j, string.Format(Lang_Error.Role_DuplicatePointError, j+1,i+1)); returnValue = false; } } } } return returnValue; }
/// <summary> /// /// </summary> /// <param name="roleCode"></param> /// <returns></returns> public RoleCollection FindRolesByCode(string roleCode, int applicationID) { SqlParameter prmRoleCode = new SqlParameter("@RoleCode", SqlDbType.VarChar, 128); SqlParameter prmApplicationID = new SqlParameter("@ApplicationID", SqlDbType.Int, 4); prmRoleCode.Direction = ParameterDirection.Input; prmApplicationID.Direction = ParameterDirection.Input; prmRoleCode.Value = roleCode; prmApplicationID.Value = applicationID; RoleCollection collection = new RoleCollection(); try { using (IDataReader dr = Database.ExecuteReader("UspFindRolesByCode", CommandType.StoredProcedure, prmRoleCode, prmApplicationID)) { while (dr.Read()) { Role role = Populate(dr); collection.Add(role); } } } catch (Exception ex) { throw ex; } return(collection); }
//绑定角色列表 protected void BindRoleList() { RoleCollection rc = Role.GetRoleCollection(CurrentGroupId); this.roleList.DataSource = rc; this.roleList.DataBind(); }
/// <summary> /// Lay danh sach Role cua mot ung dung /// </summary> /// <param name="applicationID">ID cua Ung dung</param> /// <returns>tra ve danh sach dang RoleCollection</returns> public RoleCollection GetRoleInApplication(int applicationID) { SqlParameter prmApplicationID = new SqlParameter("@AppID", SqlDbType.Int, 4); prmApplicationID.Direction = ParameterDirection.Input; prmApplicationID.Value = applicationID; RoleCollection collection = new RoleCollection(); try { using (IDataReader dr = Database.ExecuteReader("UspGetRoles_In_App", CommandType.StoredProcedure, prmApplicationID)) { while (dr.Read()) { Role role = Populate(dr); collection.Add(role); } } } catch (Exception ex) { throw (ex); } return(collection); }
/// <summary> /// Lấy danh sách Role chứa userName /// </summary> /// <param name="userName">UserName cần lấy danh sách Role</param> /// <returns></returns> public RoleCollection GetRolesOfUser(string userName) { SqlParameter prmUerName = new SqlParameter("@UserName", SqlDbType.VarChar, 128); prmUerName.Direction = ParameterDirection.Input; prmUerName.Value = userName; RoleCollection collection = new RoleCollection(); try { using (IDataReader dr = Database.ExecuteReader("UspGetRolesOfUser", CommandType.StoredProcedure, prmUerName)) { while (dr.Read()) { Role role = Populate(dr); collection.Add(role); } } } catch (Exception ex) { throw ex; } return(collection); }
public static List <PermissionCollection> GetPermissions(this RoleCollection role) { List <PermissionCollection> permissions; switch (role) { case RoleCollection.Admin: permissions = new List <PermissionCollection> { PermissionCollection.ManageConfigurationsData, PermissionCollection.ViewStrategies, PermissionCollection.ManageStrategies }; break; case RoleCollection.FCUser: permissions = new List <PermissionCollection> { PermissionCollection.ViewStrategies }; break; default: permissions = new List <PermissionCollection>(); break; } return(permissions); }
public async Task <Role> CreateRole(int realm, string resume_json) { try { FilterDefinitionBuilder <Realm> builder = Builders <Realm> .Filter; FilterDefinition <Realm> filter = builder.Eq(nameof(Realm.id), realm); IAsyncCursor <Realm> result = await RealmCollection.FindAsync(filter); if (!(await result.AnyAsync())) { _Logger.LogError($"realm {realm} is not exist, cant create role"); return(null); } Role role = new Role(); role.origin_id = IdGenerator.NewIdentity(); role.user_id = _UserId; role.realm_id = realm; role.create_time = TimeUtils.Now; role.resume_json = resume_json; await RoleCollection.InsertOneAsync(role); return(role); } catch (Exception ex) { _Logger.LogError(ex, $"CreateRole Failed! {realm} {resume_json}"); } return(null); }
public RoleCollection GetRolesNotBelongTo() { PSCPortal.Framework.Database database = new PSCPortal.Framework.Database("PSCPortalConnectionString"); RoleCollection result = new RoleCollection(); using (DbConnection connection = database.GetConnection()) { DbCommand command = database.GetCommand(connection); #region SubDomainId DbParameter prId = database.GetParameter(System.Data.DbType.Guid, "@SubDomainId", _id); command.Parameters.Add(prId); #endregion command.CommandText = @"SELECT a.[RoleId], [RoleName], [RoleDescription] FROM dbo.[Role] a inner join SubDomainInRole b on a.RoleId = b.RoleId WHERE SubDomainId!=@SubDomainId" ; command.CommandType = System.Data.CommandType.Text; command.Connection = connection; connection.Open(); DbDataReader reader = command.ExecuteReader(); while (reader.Read()) { Role item = new Role(reader); result.Add(item); } } return(result); }
///// <summary> ///// 绑定组 ///// </summary> //protected void BindGroupList() //{ // labGroupOwn.Visible = true; // groupDDL.Visible = true; // using (DataTable dt = Group.GetGroupList()) // { // this.groupDDL.DataSource = dt; // this.groupDDL.DataTextField = "GroupName"; // this.groupDDL.DataValueField = "GroupID"; // this.groupDDL.DataBind(); // } //} /// <summary> /// 绑定组中的用户组 /// </summary> protected void BindRoleList() { RoleCollection rc = Role.GetRoleCollection(CurrentGroupId); QJVRMS.Business.User user = new QJVRMS.Business.User(new Guid(this.hiUserId.Value)); RoleCollection rcUser = user.Roles; DataTable dt = new DataTable(); dt.Columns.Add("roleId", typeof(Guid)); dt.Columns.Add("roleName", typeof(string)); dt.Columns.Add("chked", typeof(bool)); foreach (Role role in rc) { DataRow newRow = dt.NewRow(); bool chk = false; if (rcUser[role.RoleId] != null) { chk = true; } newRow["roleId"] = role.RoleId; newRow["roleName"] = role.RoleName; newRow["chked"] = chk; dt.Rows.Add(newRow); } this.roleList.DataSource = dt; this.roleList.DataBind(); }
private void LoadRoleList() { RoleManager roleManager = new RoleManager(); RoleCollection roles = new RoleCollection(); try { roles = roleManager.GetRoleInApplication(int.Parse(ucApplicationList.SelectedValue)); dgridRoles.DataSource = roles; dgridRoles.DataBind(); if (roles.Count <= 0) { uctErrorBox.Visible = true; uctErrorBox.Message = "Không có dữ liệu"; } } catch (Exception ex) { uctErrorBox.Visible = true; uctErrorBox.Message = "Hệ thống bị lỗi"; this.SaveErrorLog(ex); } }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List <RoleInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(RoleInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return(CachedEntityCommander.GetCache(cacheKey) as List <RoleInfo>); } else { List <RoleInfo> list = new List <RoleInfo>(); RoleCollection collection = new RoleCollection(); Query qry = new Query(Role.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach (Role role in collection) { RoleInfo roleInfo = new RoleInfo(); LoadFromDAL(roleInfo, role); list.Add(roleInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(RoleInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return(list); } }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <RoleInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <RoleInfo> list = new List <RoleInfo>(); Query q = Role.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); RoleCollection collection = new RoleCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (Role role in collection) { RoleInfo roleInfo = new RoleInfo(); LoadFromDAL(roleInfo, role); list.Add(roleInfo); } pRecordCount = q.GetRecordCount(); return(list); }
protected override void OnSetActive(EventArgs e) { base.OnSetActive(e); if (!this.alreadySetActive) { this.alreadySetActive = true; bool visible = true; RoleCollection installedRoles = RoleManager.GetInstalledRoles(); foreach (Role role in installedRoles) { if ((role.ServerRole == ServerRole.Edge || role.ServerRole == ServerRole.HubTransport || role.ServerRole == ServerRole.Mailbox) && string.IsNullOrEmpty(this.ServerName)) { this.ServerName = NativeHelpers.GetLocalComputerFqdn(false); } if (role.ServerRole == ServerRole.Edge) { visible = false; } } this.commandConnectToServer.Visible = visible; if (string.IsNullOrEmpty(this.ServerName)) { this.commandConnectToServer.Invoke(); } } }
private void ClearCache() { s_AllRoles = null; s_BasicRoles = null; s_LevelRoles = null; s_ManagerRoles = null; s_NormalRoles = null; }
public static void Init(string sqlCnnStr) { //repo = new Repository.Fake.Roles(); repo = new Repository.Sql.Roles(sqlCnnStr); cache = repo.GetAll(); repo.LoadTasks(cache); }
private void PopulateRoles(RoleCollection roleCollection, string fieldName) { if (roleCollection.Count > 0) { string[] value = roleCollection.ConvertAll <string>((Role r) => r.RoleName).ToArray(); base.Fields[fieldName] = string.Join(",", value); } }
/// <summary> /// Checks if the specified role description is already present. /// </summary> /// <param name="roleDescription">The role description.</param> /// <returns>true if the role description is already present, otherwise false.</returns> private static bool CheckIfRoleDescriptionIsPresent(string roleDescription) { // check if the role description is already available. Do that by performing a GetDbCount query on the role entities using a filter for the description. RoleCollection roles = new RoleCollection(); // perform the getdbcount query. int count = roles.GetDbCount((RoleFields.RoleDescription == roleDescription)); return(count > 0); }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List <RoleInfo> pList, RoleCollection pCollection) { foreach (Role role in pCollection) { RoleInfo roleInfo = new RoleInfo(); LoadFromDAL(roleInfo, role); pList.Add(roleInfo); } }
private void Page_Load(object sender, System.EventArgs e) { // If the user doesn't have any access rights to management stuff, the user should // be redirected to the default of the global system. if (!SessionAdapter.HasSystemActionRights()) { // doesn't have system rights. redirect. Response.Redirect("../Default.aspx", true); } // Check if the user has the right systemright if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement)) { // no, redirect to admin default page, since the user HAS access to the admin menu. Response.Redirect("Default.aspx", true); } if (!Page.IsPostBack) { // load the data into the dropdown boxes. RoleCollection allRoles = SecurityGuiHelper.GetAllRoles(); cbxDefaultRoleNewUsers.DataSource = allRoles; cbxDefaultRoleNewUsers.DataTextField = "RoleDescription"; cbxDefaultRoleNewUsers.DataValueField = "RoleID"; cbxDefaultRoleNewUsers.DataBind(); cbxAnonymousUserRole.DataSource = allRoles; cbxAnonymousUserRole.DataTextField = "RoleDescription"; cbxAnonymousUserRole.DataValueField = "RoleID"; cbxAnonymousUserRole.DataBind(); UserTitleCollection userTitles = UserGuiHelper.GetAllUserTitles(); cbxDefaultUserTitleNewUsers.DataSource = userTitles; cbxDefaultUserTitleNewUsers.DataTextField = "UserTitleDescription"; cbxDefaultUserTitleNewUsers.DataValueField = "UserTitleID"; cbxDefaultUserTitleNewUsers.DataBind(); // preselect the current values of the system parameters. SystemDataEntity systemData = CacheManager.GetSystemData(); cbxDefaultRoleNewUsers.SelectedValue = systemData.DefaultRoleNewUser.ToString(); cbxAnonymousUserRole.SelectedValue = systemData.AnonymousRole.ToString(); cbxDefaultUserTitleNewUsers.SelectedValue = systemData.DefaultUserTitleNewUser.ToString(); tbxActiveThreadsThreshold.Text = systemData.HoursThresholdForActiveThreads.ToString(); tbxMinNumberOfNonStickyVisibleThreads.Text = systemData.MinNumberOfNonStickyVisibleThreads.ToString(); tbxMinNumberOfThreadsToFetch.Text = systemData.MinNumberOfThreadsToFetch.ToString(); tbxPageSizeInSearchResults.Text = systemData.PageSizeSearchResults.ToString(); chkSendReplyNotifications.Checked = systemData.SendReplyNotifications; ViewState.Add("ID", systemData.ID); } }
public static void UserEdit(string id) { Guid idUser = new Guid(id); User user = UserList.Where(a => a.Id == idUser).Single(); string groupAdmin = System.Configuration.ConfigurationManager.AppSettings["GroupAdmin"]; PSCDialog.DataShare = RoleCollection.GetRoleCollection(user.Name).Any(r => r.Name == groupAdmin) ? new UserArgs(user, true, true) : new UserArgs(user, true, false); }
public static RoleCollection GetUserRole(string userName, out string error) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown RoleCollection result = null; error = string.Empty; SecurityManagementClient val = (SecurityManagementClient)(object)new SecurityManagementClient(); ((ClientBase <ISecurityManagement>)(object) val).ClientCredentials.Windows.ClientCredential.UserName = Authentication.UserName; ((ClientBase <ISecurityManagement>)(object) val).ClientCredentials.Windows.ClientCredential.Password = Authentication.Password; ((ClientBase <ISecurityManagement>)(object) val).ClientCredentials.Windows.ClientCredential.Domain = Authentication.Domain; GetUserByUserAccountInput val2 = (GetUserByUserAccountInput)(object)new GetUserByUserAccountInput(); if (!userName.Contains("\\")) { userName = DefaultDomain + "\\" + userName; } val2.UserAccount = userName; GetUserByUserAccountOutput val3 = null; try { val3 = val.GetUserByUserAccount(val2); result = val3.User.Roles; return(result); } catch (TimeoutException) { //error = (string)Application.Current.FindResource("WariningMessage_ConnectServiceTimeOutError"); return(result); } catch (FaultException ex2) { if (!ex2.Message.Contains("not found in")) { if (!ex2.Message.Contains("LocalInstance1/SecurityManagement/SecurityManagement")) { error = ex2.Message; return(result); } error = "WariningMessage_ServiceNotEnabledError"; return(result); } error = "WariningMessage_UserNotFoundError"; return(result); } catch (Exception ex3) { error = ex3.Message; return(result); } }
internal static SetupComponentInfoCollection GetRequiredComponents(string roleName, InstallationModes mode) { TaskLogger.LogEnter(new object[] { roleName }); Role roleByName = RoleManager.GetRoleByName(roleName); RoleCollection currentRoles = RoleManager.GetCurrentRoles(); currentRoles.Remove(roleByName); SetupComponentInfoCollection setupComponentInfoCollection = new SetupComponentInfoCollection(); foreach (Role role in currentRoles) { setupComponentInfoCollection.AddRange(role.AllComponents); } SetupComponentInfoCollection allComponents = roleByName.AllComponents; SetupComponentInfoCollection setupComponentInfoCollection2 = new SetupComponentInfoCollection(); if (mode == InstallationModes.BuildToBuildUpgrade) { setupComponentInfoCollection2.AddRange(allComponents); } else { using (List <SetupComponentInfo> .Enumerator enumerator2 = allComponents.GetEnumerator()) { while (enumerator2.MoveNext()) { SetupComponentInfo candidate = enumerator2.Current; bool flag = false; if (candidate.AlwaysExecute) { TaskLogger.Log(Strings.RunningAlwaysToRunComponent(candidate.Name)); flag = true; } else if (setupComponentInfoCollection.Find((SetupComponentInfo sci) => sci.Name == candidate.Name) == null) { TaskLogger.Log(Strings.AddingUniqueComponent(candidate.Name)); flag = true; } else { TaskLogger.Log(Strings.AlreadyConfiguredComponent(candidate.Name)); } if (flag) { setupComponentInfoCollection2.Add(candidate); } } } } TaskLogger.LogExit(); return(setupComponentInfoCollection2); }
public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) { RoleCollection roles = Role.Where(c => c.Name.In(roleNames), Database); UserCollection users = User.Where(c => c.UserName.In(usernames), Database); long[] roleIds = roles.Select(r => r.Id.Value).ToArray(); long[] userIds = users.Select(u => u.Id.Value).ToArray(); UserRoleCollection xrefs = UserRole.Where(c => c.RoleId.In(roleIds) && c.UserId.In(userIds), Database); xrefs.Delete(Database); }
public void RoleCollection_can_construct_ctor0() { // AAA - Arrange, Act, Assert // Arrange var sut = new RoleCollection(); // Act // Assert Assert.That(sut, Is.Not.Null); }
public override void List(Action <string> output = null, Action <string> error = null) { Database userDatabase = ServiceTools.GetUserDatabase(); RoleCollection roles = Role.LoadAll(userDatabase); int num = 1; foreach (Role role in roles) { output($"{num}. {role.Name}\r\n"); } }
internal void Update(ulong[] roles) { if (_roles == null) { _roles = new RoleCollection(Guild, roles); } else { _roles.Update(roles); } }
protected CollectionBase GenerateRoleCollectionFromReader(IDataReader returnData) { RoleCollection colRoles = new RoleCollection(); while (returnData.Read()) { Role newRole = new Role((int)returnData["RoleId"], (string)returnData["RoleName"]); colRoles.Add(newRole); } return(colRoles); }
public override RoleCollection GetAllRoles() { using (SqlQuery query = new SqlQuery()) { query.CommandText = "SELECT * FROM bx_Roles"; using (XSqlDataReader reader = query.ExecuteReader()) { RoleCollection rolegroups = new RoleCollection(reader); return rolegroups; } } }
protected virtual bool ValidateRoleDate(RoleCollection roles, MessageDisplay msgdisp) { Role myMaxRole = My.MaxRole; bool returnValue = true; for (int i = 0; i < roles.Count; i++) { if (string.IsNullOrEmpty(roles[i].Name) || roles[i].Name.Trim() == string.Empty) { msgdisp.AddError("name", i, Lang_Error.Role_EmptyRoleNameError); returnValue = false; } if ( !My.IsOwner && roles[i].IsNew && roles[i].IsManager && roles[i].Level >= myMaxRole.Level) { msgdisp.AddError("level", i, string.Format("您当前的用户组为{0}。因此,您不能添加和{0}同级别或级别更高的用户组",myMaxRole.Name)); returnValue = false; } } return returnValue; }
/// <summary> /// 获取所有管理员用户组(即可以往其中添加成员的用户组) /// </summary> /// <returns></returns> public RoleCollection GetManagerRoles() { if (m_ManagerRoles == null) { RoleCollection roles = GetRoles(delegate(Role role) { return (role.IsManager); }); m_ManagerRoles = roles; } return m_ManagerRoles; }
/// <summary> /// 获取所有非虚拟的用户组(即可以往其中添加成员的用户组) /// </summary> /// <returns></returns> public RoleCollection GetNonVirtualRoles() { if (m_NonVirtualRoles == null) { m_NonVirtualRoles = GetRoles(delegate(Role role) { return (role.IsVirtualRole == false); }); } return m_NonVirtualRoles; }
/// <summary> /// 获取所有管理员用户组(即可以往其中添加成员的用户组) /// </summary> /// <returns></returns> public RoleCollection GetLevelRoles() { if (m_LevelRoles == null) { m_LevelRoles = GetRoles(delegate(Role role) { return (role.IsLevel); }); } return m_LevelRoles; }
/// <summary> /// 获取所有管理员用户组(即可以往其中添加成员的用户组) /// </summary> /// <returns></returns> public RoleCollection GetNormalRoles() { if (m_NormalRoles == null) { m_NormalRoles = GetRoles(delegate(Role role) { return (role.IsNormal); }); } return m_NormalRoles; }
public AfterSaveUserGroups(RoleCollection newUserGroups, RoleCollection oldUserGroups) { NewUserGroups = newUserGroups; OldUserGroups = oldUserGroups; }
/// <summary> /// 获取所有管理员用户组(即可以往其中添加成员的用户组) /// </summary> /// <returns></returns> public RoleCollection GetBasicRoles() { if (m_BasicRoles == null) { m_BasicRoles = GetRoles(delegate(Role role) { return (role.IsBasic); }); } return m_BasicRoles; }
/// <summary> /// Adds the specified roles,adding the Role objects into the RoleCollection. /// </summary> /// <param name="roles">The roles.</param> public void Add(RoleCollection roles) { foreach (Role role in roles) this.Add(role); }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List<RoleInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(RoleInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return CachedEntityCommander.GetCache(cacheKey) as List< RoleInfo>; } else { List< RoleInfo> list =new List< RoleInfo>(); RoleCollection collection=new RoleCollection(); Query qry = new Query(Role.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach(Role role in collection) { RoleInfo roleInfo= new RoleInfo(); LoadFromDAL(roleInfo,role); list.Add(roleInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(RoleInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return list; } }
/// <summary> /// 获取指定条件的用户组(推荐使用匿名委托来指定条件) /// </summary> /// <param name="resolver"></param> /// <returns></returns> public RoleCollection GetRoles(RoleResolver resolver) { RoleCollection roles = new RoleCollection(); foreach (Role role in Roles) { if (resolver(role)) roles.Add(role); } return roles; }
public RoleCollection GetAllRoles(string userName) { //TODO RoleCollection collection = new RoleCollection(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = "SP_Frank_TEST"; SqlParameter ColumnParam = command.Parameters.Add("@UserAccount", System.Data.SqlDbType.VarChar); ColumnParam.Value = userName; command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Role role = new Role(); role.RoleName = reader["Role_Name"].ToString(); collection.Add(role); } } reader.Close(); return collection; } }
public void UpdateRoles(string userName, RoleCollection roleCollection) { using (TransactionScope _ts = new TransactionScope()) { using (SqlConnection connection = new SqlConnection(connectionString)) { UserCollection collection = new UserCollection(); collection = Query(userName); User user = collection[0]; SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = "SP_DEL_Table"; SqlParameter ColumnParam = command.Parameters.Add("@value1", System.Data.SqlDbType.VarChar); ColumnParam.Value = "System_Roles_R_User"; SqlParameter ColumnParam1 = command.Parameters.Add("@value2", System.Data.SqlDbType.VarChar); ColumnParam1.Value = "1"; SqlParameter ColumnParam2 = command.Parameters.Add("@value2", System.Data.SqlDbType.VarChar); ColumnParam2.Value = user.UserID; command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); command.ExecuteNonQuery(); foreach (Role role in roleCollection) { using (SqlConnection connection2 = new SqlConnection(connectionString)) { SqlCommand command2 = new SqlCommand(); command2.Connection = connection2; command.CommandText = "SP_INS_Table"; SqlParameter _param = command.Parameters.Add("@value1", System.Data.SqlDbType.VarChar); _param.Value = "System_Roles_R_User"; SqlParameter _param2 = command.Parameters.Add("@value2", System.Data.SqlDbType.VarChar); _param2.Value = "1,2"; SqlParameter _param3 = command.Parameters.Add("@value3", System.Data.SqlDbType.VarChar); _param3.Value = user.UserID.ToString()+","+role.ID.ToString(); command2.CommandType = System.Data.CommandType.StoredProcedure; connection2.Open(); command2.ExecuteNonQuery(); } } } _ts.Complete(); } }
public RoleCollection QueryRoles(string userName, string roleName) { //TODO Maybe not useful RoleCollection collection = new RoleCollection(); //using (SqlConnection connection = new SqlConnection(connectionString)) //{ // SqlCommand command = new SqlCommand(); // command.Connection = connection; // command.CommandText = "SP_SEL_Table"; // SqlParameter _param = command.Parameters.Add("@value1", System.Data.SqlDbType.VarChar); // _param.Value = "Users"; // SqlParameter _param2 = command.Parameters.Add("@value2", System.Data.SqlDbType.VarChar); // _param2.Value = "2"; // SqlParameter _param3 = command.Parameters.Add("@value3", System.Data.SqlDbType.VarChar); // _param3.Value = userName; // SqlParameter _param4 = command.Parameters.Add("@order_by1", System.Data.SqlDbType.VarChar); // _param4.Value = "2"; // SqlParameter _param5 = command.Parameters.Add("@order_by2", System.Data.SqlDbType.TinyInt); // _param5.Value = 0; // command.CommandType = System.Data.CommandType.StoredProcedure; // connection.Open(); // SqlDataReader reader = command.ExecuteReader(); // if (reader.HasRows) // { // while (reader.Read()) // { // User user = new User(); // user.UserID = Convert.ToInt32(reader["ID"]); // user.UserName = reader["UserAccount"].ToString(); // user.EntityRelationID = Convert.ToInt32(reader["EntityRelationID"]); // user.Enable = Convert.ToInt32(reader["Enable"]); // collection.Add(user); // } // } return collection; //} }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<RoleInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< RoleInfo> list = new List< RoleInfo>(); Query q = Role .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); RoleCollection collection=new RoleCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (Role role in collection) { RoleInfo roleInfo = new RoleInfo(); LoadFromDAL(roleInfo, role); list.Add(roleInfo); } pRecordCount=q.GetRecordCount(); return list; }
/// <summary> /// 获取所有用户组,但排除掉指定的用户组 /// </summary> /// <param name="exceptRoleIds"></param> /// <returns></returns> public RoleCollection GetRoles(params Role[] exceptRoles) { RoleCollection roles = new RoleCollection(); foreach (Role role in Roles) { bool isExcept = false; foreach (Role exceptRole in exceptRoles) { if (role == exceptRole) { isExcept = true; break; } } if (isExcept == false) roles.Add(role); } return roles; }
public BeforeSaveUserGroups(RoleCollection newUserGroups, RoleCollection oldUserGroups) { NewUserGroups = newUserGroups; OldUserGroups = oldUserGroups; }
/// <summary> /// 获取给后台作为自动加入的用户组列表。例如:作为任务奖励自动加入用户组,那么只能在这些用户组里面选择 /// </summary> /// <returns></returns> public RoleCollection GetRolesForAutoAdd() { RoleCollection roles = new RoleCollection(); foreach (Role r in Roles) { if ((r.Type & RoleType.Normal) == RoleType.Normal && (r.Type & RoleType.Virtual) != RoleType.Virtual && (r.Type & RoleType.System) != RoleType.System ) { roles.Add(r); } } return roles; }
/// <summary> /// Checks if the specified role description is already present. /// </summary> /// <param name="roleDescription">The role description.</param> /// <returns>true if the role description is already present, otherwise false.</returns> private static bool CheckIfRoleDescriptionIsPresent(string roleDescription) { // check if the role description is already available. Do that by performing a GetDbCount query on the role entities using a filter for the description. RoleCollection roles = new RoleCollection(); // perform the getdbcount query. int count = roles.GetDbCount((RoleFields.RoleDescription == roleDescription)); return (count > 0); }
public RoleSettings() { string iconPath = Globals.GetRelativeUrl(SystemDirecotry.Assets_RoleIcon); Roles = new RoleCollection(); Roles.Add(Role.Everyone); Roles.Add(Role.Guests); Roles.Add(Role.Users); Roles.Add(Role.ForumBannedUsers); Roles.Add(Role.FullSiteBannedUsers); Roles.Add(Role.NewUsers); Roles.Add(Role.EmailNotProvedUsers); Roles.Add(Role.RealnameNotProvedUsers); //Roles.Add(Role.InviteLessUsers); Roles.Add(Role.JackarooModerators); Roles.Add(Role.Moderators); Roles.Add(Role.CategoryModerators); Roles.Add(Role.SuperModerators); Roles.Add(Role.Administrators); Roles.Add(Role.Owners); Roles.Add(Role.NoLevel); LevelLieOn = LevelLieOn.Post; /*-----------------------默认图标------------------------*/ Role.CategoryModerators.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips10.gif"); Role.Administrators.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips10.gif"); Role.SuperModerators.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips10.gif"); Role.Owners.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips10.gif"); Role.Moderators.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips9.gif"); Role.JackarooModerators.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips8.gif"); /*-------------------默认等级用户组------------------*/ Role levelRole = new Role(); levelRole.Name = "新手上路"; levelRole.RequiredPoint = 0; levelRole.RoleID = new Guid(new byte[] { 74, 115, 163, 71, 186, 53, 83, 71, 183, 179, 236, 16, 210, 32, 146, 103 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips1.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "侠客"; levelRole.RequiredPoint = 50; levelRole.RoleID = new Guid(new byte[] { 248, 152, 64, 183, 181, 77, 53, 77, 182, 73, 89, 85, 162, 252, 146, 41 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips2.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "圣骑士"; levelRole.RequiredPoint = 200; levelRole.RoleID = new Guid(new byte[] { 29, 40, 140, 204, 235, 17, 207, 73, 174, 43, 138, 98, 96, 82, 219, 68 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips3.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "精灵"; levelRole.RequiredPoint = 500; levelRole.RoleID = new Guid(new byte[] { 26, 191, 38, 123, 38, 152, 103, 71, 171, 98, 16, 19, 63, 224, 29, 77 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips4.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "精灵王"; levelRole.RequiredPoint = 1000; levelRole.RoleID = new Guid(new byte[] { 92, 96, 198, 205, 96, 80, 220, 66, 172, 38, 16, 150, 6, 184, 0, 251 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips5.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "风云使者"; levelRole.RequiredPoint = 5000; levelRole.RoleID = new Guid(new byte[] { 165, 75, 133, 177, 234, 6, 16, 66, 162, 12, 235, 64, 5, 68, 248, 140 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips6.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "光明使者"; levelRole.RequiredPoint = 10000; levelRole.RoleID = new Guid(new byte[] { 185, 185, 243, 95, 132, 73, 233, 67, 128, 221, 168, 188, 74, 206, 151, 196 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips7.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "天使"; levelRole.RequiredPoint = 50000; levelRole.RoleID = new Guid(new byte[] { 164, 254, 210, 237, 225, 87, 214, 77, 171, 96, 92, 245, 221, 54, 78, 154 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips8.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "法老"; levelRole.RequiredPoint = 100000; levelRole.RoleID = new Guid(new byte[] { 188, 159, 219, 20, 145, 63, 6, 67, 184, 52, 226, 115, 211, 207, 90, 98 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips9.gif"); levelRole.IsNew = false; Roles.Add(levelRole); /*-----------------------end-------------------------*/ Roles.Sort(); }
public bool SaveSettings() { MessageDisplay msdDisplay = CreateMessageDisplay("name", "title", "requiredPoint", "level"); RoleCollection tempRoles = new RoleCollection(); RoleSettings settings = SettingManager.CloneSetttings<RoleSettings>(AllSettings.Current.RoleSettings); Role temp; Guid[] oldRoleids = _Request.GetList<Guid>("roleid", Method.Post, new Guid[00]); foreach (Guid r in oldRoleids) { temp = settings.GetRole(r); if (AllSettings.Current.BackendPermissions.Can(My, BackendPermissions.ActionWithTarget.Setting_Roles_Manager, temp)) { temp = temp == null ? CreateRole() : temp.Clone(); //不采用克隆的话可能会有些属性丢失掉 temp.Name = _Request.Get("Name." + r, Method.Post); temp.Title = _Request.Get("title." + r, Method.Post); temp.RequiredPoint = _Request.Get<int>("RequiredPoint." + r, Method.Post, 0); temp.Color = _Request.Get("Color." + r, Method.Post); temp.IconUrlSrc = _Request.Get("IconUrl." + r, Method.Post); temp.StarLevel = _Request.Get<int>("StarLevel." + r, Method.Post, 0); temp.Level = _Request.Get<int>("Level." + r, Method.Post, 0); temp.IsNew = _Request.Get<bool>("isnew." + r, Method.Post, false); temp.CanLoginConsole = _Request.Get<bool>("CanLoginConsole." + r, Method.Post, false) && temp.IsManager; temp.RoleID = r; if (temp.IsLevel) temp.Name = temp.Title; } else { if (temp == null) continue; } tempRoles.Add(temp); } //Nonsupport Javascript if (_Request.Get("newroleid", Method.Post, "").Contains("{0}")) { Role r = CreateRole(); r.Name = _Request.Get("name.new.{0}", Method.Post); r.Title = _Request.Get("title.new.{0}", Method.Post); r.StarLevel = _Request.Get<int>("starlevel.new.{0}", Method.Post, 0); r.RequiredPoint = _Request.Get<int>("RequiredPoint.new.{0}", Method.Post, 0); r.Color = _Request.Get("color.new.{0}", Method.Post); r.IconUrlSrc = _Request.Get("IconUrl.new.{0}", Method.Post); r.Level = _Request.Get<int>("Level.new.{0}", Method.Post, 0); r.CanLoginConsole = _Request.Get<bool>("CanLoginConsole.new.{0}", Method.Post, false) && r.IsManager; if (r.IsLevel) r.Name = r.Title; if (!string.IsNullOrEmpty(r.Name)) tempRoles.Add(r); } else { int[] newroleid = _Request.GetList<int>("newroleid", Method.Post, new int[0]); foreach (int i in newroleid) { Role r = CreateRole(); r.Name = _Request.Get("name.new." + i, Method.Post); r.Title = _Request.Get("title.new." + i, Method.Post); r.StarLevel = _Request.Get<int>("starlevel.new." + i, Method.Post, 0); r.RequiredPoint = _Request.Get<int>("RequiredPoint.new." + i, Method.Post, 0); r.Color = _Request.Get("color.new." + i, Method.Post); r.IconUrlSrc = _Request.Get("IconUrl.new." + i, Method.Post); r.Level = _Request.Get<int>("Level.new." + i, Method.Post, 0); r.CanLoginConsole = _Request.Get<bool>("CanLoginConsole.new." + i, Method.Post, false) && r.IsManager; if (r.IsLevel) r.Name = r.Title; tempRoles.Add(r); } } if (ValidateRoleDate(tempRoles, msdDisplay)) { foreach (Role r in tempRoles) { settings.SetRole(r); } if (BeforeSaveSettings(settings)) { SettingManager.SaveSettings(settings); m_RoleList = null; return true; } } m_RoleList = tempRoles; msdDisplay.AddError(new DataNoSaveError()); return false; }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List< RoleInfo> pList, RoleCollection pCollection) { foreach (Role role in pCollection) { RoleInfo roleInfo = new RoleInfo(); LoadFromDAL(roleInfo, role ); pList.Add(roleInfo); } }
public static void ConvertRoles() { RoleCollection newRoles = new RoleCollection(); string sql = @" --�����û������ݵĴ����� IF EXISTS(SELECT * FROM sysobjects WHERE [type]=N'TR' AND [name]=N'bx_UserRoles_AfterUpdate') DROP TRIGGER bx_UserRoles_AfterUpdate; --GO "; using (SqlConnection connection = new SqlConnection(Settings.Current.IConnectionString)) { connection.Open(); SqlCommand command = new SqlCommand(sql, connection); command.CommandTimeout = 60; try { command.ExecuteNonQuery(); } catch (Exception ex) { CreateLog(ex); throw new Exception("ɾ��������bx_UserRoles_AfterUpdateʧ��" + ex.Message + sql); } finally { connection.Close(); } } Guid vipRoleID = new Guid(new byte[] { 152, 198, 223, 228, 218, 198, 221, 78, 191, 59, 129, 195, 81, 168, 105, 207 }); //�����ο͡�everyone sql = @" IF EXISTS (SELECT * FROM sysobjects WHERE [type] = N'U' AND [name] = N'Max_Roles') AND EXISTS (SELECT * FROM [sysobjects] WHERE [type]='U' AND [name]='Max_UsersInRoles') BEGIN IF NOT EXISTS (SELECT [name] FROM syscolumns WHERE id = object_id('Max_Roles') AND [name] = 'NewRoleID') ALTER TABLE Max_Roles add [NewRoleID] uniqueidentifier NOT NULL DEFAULT(NEWID()); SELECT * FROM Max_Roles WHERE RoleID > 0; IF EXISTS (SELECT * FROM sysobjects WHERE [type] = N'U' AND [name] = N'bbsMax_PointLevels') SELECT * FROM bbsMax_PointLevels WHERE RequireRoleID = 0; END ELSE SELECT -9999 AS RoleID; "; using (SqlConnection connection = new SqlConnection(Settings.Current.IConnectionString)) { connection.Open(); SqlCommand command = new SqlCommand(sql, connection); command.CommandTimeout = 60; try { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { #region ������ int roleID = (int)reader["RoleID"]; //Max_Roles������ڣ��˳��û���ת�� if (roleID == -9999) return; Guid newRoleID = (Guid)reader["NewRoleID"]; string roleName = (string)reader["RoleName"]; string logoUrl = (string)reader["LogoUrl"]; string displayColor = (string)reader["DisplayColor"]; Role role; switch (roleID) { case 1: role = Role.Owners.Clone();//Role.CreateManagerRole(); //role.RoleID = newRoleID; role.Title = roleName; break; case 2: role = Role.Administrators.Clone(); //role.RoleID = newRoleID; role.Title = roleName; break; case 3: role = Role.SuperModerators.Clone(); //role.RoleID = newRoleID; role.Title = roleName; break; case 5: role = Role.CreateNormalRole(); role.RoleID = vipRoleID; role.Name = roleName; role.Title = roleName; break; default: if (roleID > 8) { role = Role.CreateNormalRole(); role.RoleID = newRoleID; role.Name = roleName; } else continue; break; } newRoles.Set(role); #endregion } if (reader.NextResult()) { while (reader.Read()) { Role role = Role.CreateLevelRole(); role.RequiredPoint = (int)reader["RequirePoints"]; role.RoleID = Guid.NewGuid(); role.Name = (string)reader["LevelName"]; role.Title = role.Name; role.StarLevel = (int)reader["Stars"]; newRoles.Add(role); } } newRoles.Sort(); } sql = @" UPDATE bx_Settings SET [Value] = @RolesString WHERE TypeName = 'MaxLabs.bbsMax.Settings.RoleSettings' AND [Key] = 'Roles'; IF @@ROWCOUNT = 0 INSERT INTO bx_Settings ([Key], [Value], [TypeName]) VALUES ('Roles', @RolesString, 'MaxLabs.bbsMax.Settings.RoleSettings'); IF EXISTS (SELECT * FROM [sysobjects] WHERE [type]='U' AND [name]='Max_UsersInRoles') BEGIN truncate table [bx_UserRoles]; UPDATE Max_Roles SET NewRoleID = @NewRoleID1 WHERE RoleID = 1; UPDATE Max_Roles SET NewRoleID = @NewRoleID2 WHERE RoleID = 2; UPDATE Max_Roles SET NewRoleID = @NewRoleID3 WHERE RoleID = 3; UPDATE Max_Roles SET NewRoleID = @NewRoleID5 WHERE RoleID = 5; INSERT INTO [bx_UserRoles] ([UserID] ,[RoleID] ,[BeginDate] ,[EndDate]) SELECT u.UserID,--(<UserID, int,> r.NewRoleID,--,<RoleID, uniqueidentifier,> u.EnabledDate,--,<BeginDate, datetime,> u.ExpiresDate--,<EndDate, datetime,>) FROM Max_UsersInRoles u WITH (NOLOCK) INNER JOIN Max_Roles r WITH (NOLOCK) ON u.RoleID = r.RoleID WHERE u.RoleID IN (1,2,3,5) OR u.RoleID > 8; DROP TABLE Max_UsersInRoles; END DROP TABLE Max_Roles; "; command.CommandTimeout = 3600; command.CommandText = sql; command.Parameters.AddWithValue("@NewRoleID1", Role.Owners.RoleID); command.Parameters.AddWithValue("@NewRoleID2", Role.Administrators.RoleID); command.Parameters.AddWithValue("@NewRoleID3", Role.SuperModerators.RoleID); command.Parameters.AddWithValue("@NewRoleID5", vipRoleID); SqlParameter param = new SqlParameter("@RolesString", SqlDbType.NText); param.Value = newRoles.GetValue(); command.Parameters.Add(param); command.ExecuteNonQuery(); } catch (Exception ex) { CreateLog(ex); throw new Exception("�����û�������ʧ��" + ex.Message + sql); } finally { connection.Close(); } } }
/// <summary> /// Checks the PermissionCollection class to determine if the /// indicated operation is allowed for the person identified by /// their ID number. /// </summary> /// <param name="permissions">The collection of permissions to check. These should be object permissions.</param> /// <param name="personID">The ID number of the user whose security access we are checking.</param> /// <param name="operation">The type of access the user needs to proceed.</param> /// <returns>true/false indicating if the operation is allowed.</returns> public static bool PermissionsOperationAllowed(PermissionCollection permissions, int personID, OperationType operation) { RoleCollection roles; int i; // // Check if the person has direct permission. // if (permissions.ContainsSubjectOperation(SubjectType.Person, personID, operation) == true) return true; // // Now check all roles for the given person. // roles = new RoleCollection(DefaultOrganizationID(), personID); for (i = 0; i < roles.Count; i++) { if (permissions.ContainsSubjectOperation(SubjectType.Role, roles[i].RoleID, operation) == true) return true; } return false; }
/// <summary> /// Initial User /// </summary> /// <param name="UserID"></param> /// <param name="UserAccount"></param> /// <param name="RoleID"></param> public static void InitUserData(int UserID, string UserAccount, RoleCollection RoleID) { System.Web.HttpContext.Current.Session["UserID"] = UserID; System.Web.HttpContext.Current.Session["UserAccount"] = UserAccount; System.Web.HttpContext.Current.Session["RoleID"] = RoleID; }
/// <summary> /// Gets the collection of roles of a specified right. /// </summary> /// <param name="right">The right.</param> /// <returns></returns> public RoleCollection GetRoles(Right right) { RoleCollection roles = new RoleCollection(); //Checking whether that specified right is in each and every Role-Right-assignment object of RoleRightAssignments collection. //If it is there,find the role of that Role-Right-Assignment object and add that to RoleCollection-roles. foreach (RoleRightAssignment rra in this.RoleRightAssignments) { if (rra.Right.Id == right.Id) roles.Add(rra.Role); } //returns the RoleCollection. return roles; }
public void loadRoleCombo() { this.RoleList = RoleCollection.Current; this.CurrentRole = this.RoleList.FirstOrDefault(); }