public void AddRange(ModulePermissionCollection modulePermissions)
 {
     foreach (ModulePermissionInfo permission in modulePermissions)
     {
         Add(permission);
     }
 }
        private object GetModulePermissionsCallBack(CacheItemArgs cacheItemArgs)
        {
            int         tabID = (int)cacheItemArgs.ParamList[0];
            IDataReader dr    = dataProvider.GetModulePermissionsByTabID(tabID);
            Dictionary <int, ModulePermissionCollection> dic = new Dictionary <int, ModulePermissionCollection>();

            try
            {
                ModulePermissionInfo obj;
                while (dr.Read())
                {
                    obj = CBO.FillObject <ModulePermissionInfo>(dr, false);
                    if (dic.ContainsKey(obj.ModuleID))
                    {
                        dic[obj.ModuleID].Add(obj);
                    }
                    else
                    {
                        ModulePermissionCollection collection = new ModulePermissionCollection();
                        collection.Add(obj);
                        dic.Add(obj.ModuleID, collection);
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            finally
            {
                CBO.CloseDataReader(dr, true);
            }
            return(dic);
        }
 public void AddRange(ModulePermissionCollection modulePermissions)
 {
     foreach (ModulePermissionInfo permission in modulePermissions)
     {
         Add(permission);
     }
 }
        public virtual ModulePermissionCollection GetModulePermissions(int moduleID, int tabID)
        {
            bool bFound = false;
            Dictionary <int, ModulePermissionCollection> dicModulePermissions = GetModulePermissions(tabID);
            ModulePermissionCollection modulePermissions = null;

            bFound = dicModulePermissions.TryGetValue(moduleID, out modulePermissions);
            if (!bFound)
            {
                modulePermissions = new ModulePermissionCollection(CBO.FillCollection(dataProvider.GetModulePermissionsByModuleID(moduleID, -1), typeof(ModulePermissionInfo)), moduleID);
            }
            return(modulePermissions);
        }
 public bool CompareTo(ModulePermissionCollection objModulePermissionCollection)
 {
     if (objModulePermissionCollection.Count != this.Count)
     {
         return(false);
     }
     InnerList.Sort(new CompareModulePermissions());
     objModulePermissionCollection.InnerList.Sort(new CompareModulePermissions());
     for (int i = 0; i <= this.Count - 1; i++)
     {
         if (objModulePermissionCollection[i].ModulePermissionID != this[i].ModulePermissionID || objModulePermissionCollection[i].AllowAccess != this[i].AllowAccess)
         {
             return(false);
         }
     }
     return(true);
 }
 public static bool HasModulePermission(ModulePermissionCollection objModulePermissions, string permissionKey)
 {
     bool hasPermission = Null.NullBoolean;
     if (permissionKey.Contains(","))
     {
         foreach (string permission in permissionKey.Split(','))
         {
             if (provider.HasModulePermission(objModulePermissions, permission))
             {
                 hasPermission = true;
                 break;
             }
         }
     }
     else
     {
         hasPermission = provider.HasModulePermission(objModulePermissions, permissionKey);
     }
     return hasPermission;
 }
 public virtual void SaveModulePermissions(ModuleInfo objModule)
 {
     if (objModule.ModulePermissions != null)
     {
         ModulePermissionCollection modulePermissions = ModulePermissionController.GetModulePermissions(objModule.ModuleID, objModule.TabID);
         if (!modulePermissions.CompareTo(objModule.ModulePermissions))
         {
             dataProvider.DeleteModulePermissionsByModuleID(objModule.ModuleID);
             foreach (ModulePermissionInfo objModulePermission in objModule.ModulePermissions)
             {
                 if (objModule.InheritViewPermissions && objModulePermission.PermissionKey == "VIEW")
                 {
                     dataProvider.DeleteModulePermission(objModulePermission.ModulePermissionID);
                 }
                 else
                 {
                     dataProvider.AddModulePermission(objModule.ModuleID, objModulePermission.PermissionID, objModulePermission.RoleID, objModulePermission.AllowAccess, objModulePermission.UserID, UserController.GetCurrentUserInfo().UserID);
                 }
             }
         }
     }
 }
 public bool CompareTo(ModulePermissionCollection objModulePermissionCollection)
 {
     if (objModulePermissionCollection.Count != this.Count)
     {
         return false;
     }
     InnerList.Sort(new CompareModulePermissions());
     objModulePermissionCollection.InnerList.Sort(new CompareModulePermissions());
     for (int i = 0; i <= this.Count - 1; i++)
     {
         if (objModulePermissionCollection[i].ModulePermissionID != this[i].ModulePermissionID || objModulePermissionCollection[i].AllowAccess != this[i].AllowAccess)
         {
             return false;
         }
     }
     return true;
 }
 public ModulePermissionCollection(ModulePermissionCollection modulePermissions)
 {
     AddRange(modulePermissions);
 }
Exemplo n.º 10
0
 public virtual bool HasModulePermission(ModulePermissionCollection objModulePermissions, string permissionKey)
 {
     return(PortalSecurity.IsInRoles(objModulePermissions.ToString(permissionKey)));
 }
 public ModulePermissionCollection(ModulePermissionCollection modulePermissions)
 {
     AddRange(modulePermissions);
 }