Esempio n. 1
0
        /// <summary>
        /// Updates the list access.
        /// </summary>
        /// <param name="ListId">The list id.</param>
        /// <param name="ListAccess">The list access.</param>
        public static void UpdateListAccess(int ListId, DataTable ListAccess)
        {
            if (!CanAdmin(ListId))
            {
                throw new AccessDeniedException();
            }

            using (DbTransaction tran = DbTransaction.Begin())
            {
                DBListInfo.DeleteListAccessByList(ListId);

                foreach (DataRow row in ListAccess.Rows)
                {
                    int  PrincipalId = (int)row["PrincipalId"];
                    byte AllowLevel  = (byte)row["AllowLevel"];
                    if (AllowLevel < 1 || AllowLevel > 3)
                    {
                        throw new ArgumentOutOfRangeException("AllowLevel", AllowLevel, "should be > 0 and < 3");
                    }
                    DBListInfo.CreateListAccess(ListId, PrincipalId, AllowLevel);
                }

                tran.Commit();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the list accesses as DataTable.
        /// </summary>
        /// <param name="ListId">The list id.</param>
        /// <returns>ListAccessId, PrincipalId, AllowLevel</returns>
        public static DataTable GetListAccessesDT(int ListId)
        {
            if (!CanAdmin(ListId))
            {
                throw new AccessDeniedException();
            }

            return(DBListInfo.GetListAccessesDT(ListId));
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the list accesses as IDataReader.
        /// </summary>
        /// <param name="ListId">The list id.</param>
        /// <returns>ListAccessId, PrincipalId, AllowLevel</returns>
        public static IDataReader GetListAccesses(int ListId)
        {
            if (!CanAdmin(ListId))
            {
                throw new AccessDeniedException();
            }

            return(DBListInfo.GetListAccesses(ListId));
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the security for user.
        /// </summary>
        /// <param name="ListId">The list id.</param>
        /// <param name="UserId">The user id.</param>
        /// <returns></returns>
        public static int GetSecurityForUser(int listId, int userId)
        {
            int    retVal = 0;
            string key    = string.Format(CultureInfo.InvariantCulture,
                                          "_list_{0}_usr_{1}",
                                          listId, userId);

            if (HttpContext.Current == null || HttpContext.Current.Items[key] == null)
            {
                retVal = DBListInfo.GetSecurityForUser(listId, userId);

                if (HttpContext.Current != null)
                {
                    HttpContext.Current.Items[key] = retVal;
                }
            }
            else
            {
                retVal = (int)HttpContext.Current.Items[key];
            }

            return(retVal);
        }
Esempio n. 5
0
 /// <summary>
 /// Deletes the list access by PrincipalId.
 /// </summary>
 /// <param name="listId">The list id.</param>
 /// <param name="principalId">The principal id.</param>
 public static void DeleteListAccess(int listId, int principalId)
 {
     DBListInfo.DeleteListAccess(listId, principalId);
 }
Esempio n. 6
0
 /// <summary>
 /// Deletes the list access by list.
 /// </summary>
 /// <param name="ListId">The list id.</param>
 public static void DeleteListAccessByList(int ListId)
 {
     DBListInfo.DeleteListAccessByList(ListId);
 }
Esempio n. 7
0
 /// <summary>
 /// Creates the list access.
 /// </summary>
 /// <param name="ListId">The list id.</param>
 /// <param name="PrincipalId">The principal id.</param>
 /// <param name="AllowLevel">The allow level.</param>
 /// <returns></returns>
 public static int CreateListAccess(int ListId, int PrincipalId, byte AllowLevel)
 {
     return(DBListInfo.CreateListAccess(ListId, PrincipalId, AllowLevel));
 }
Esempio n. 8
0
 /// <summary>
 /// Gets the list access.
 /// </summary>
 /// <param name="ListAccessId">The list access id.</param>
 /// <returns>ListId, PrincipalId, AllowLevel</returns>
 public static IDataReader GetListAccess(int ListAccessId)
 {
     return(DBListInfo.GetListAccess(ListAccessId));
 }