예제 #1
0
 /// <summary>
 ///  判别是否有对应的角色权限
 /// </summary>
 /// <param name="code">角色代码</param>
 /// <returns></returns>
 public bool HasRole(string code)
 {
     if (RoleList != null)
     {
         return(RoleList.Contains(code));
     }
     return(false);
 }
        public AccessLevel GetApplicationAccess(SecureSession session, Application application, RoleList roleList, int versionNumber)
        {
            string resourceString;
            string userId = session.AuthenticatedUser == null ? string.Empty : session.AuthenticatedUser.Id;
            string formName = string.Format("Test_Data.ApplicationPermissions.FORM-{0}-USER-{1}.json", application.FormId.PadLeft(2, '0'), userId);
            if (AssemblyResourceReader.TryReadAsString(formName, out resourceString))
            {
                var applicationEntitlements = JsonConvert.DeserializeObject<ApplicationEntitlementList>(resourceString);
                applicationEntitlements = new ApplicationEntitlementList(applicationEntitlements.Where(e => e.ProductId == application.FormId && e.ProductVersion == application.FormVersion && e.StateName == application.WorkflowState && roleList.Contains(e.RoleId)));
                return applicationEntitlements.Max(e => e.AccessLevel);
            }

            return AccessLevel.NoAccess;
        }
예제 #3
0
 public void RemoveRole(Role role)
 {
     //避免多线程同时修改list.
     lock (RoleList)
     {
         if (!RoleList.Contains(role))
         {
             return;
         }
         RoleTempData roleTempData = role.roleTempData;
         roleTempData.room   = null;
         roleTempData.status = EnumRoleStatus.None;
         roleTempData.Camp   = 1;
         RoleList.Remove(role);
         //如果玩家当前是房主,那么退出的时候更新房主信息。
         if (roleTempData.isOwner)
         {
             UpdateOwner();
             roleTempData.isOwner = false;
         }
     }
 }