Пример #1
0
        /// <summary>
        /// Gets a list of the roles that a specified user is in for the configured applicationName.
        /// </summary>
        /// <param name="username">The user to return a list of roles for.</param>
        /// <returns>A string array containing the names of all the roles that the specified user
        ///  is in for the configured applicationName.</returns>
        public string[] GetRolesForUser(string username)
        {
            // Find the user.
            var user = GetSpecificUser(username);

            if (user != null)
            {
                // If a role has been assigned to the user.
                if (user.RoleID != null)
                {
                    long roleID = user.RoleID.Value;

                    Nequeo.DataAccess.CloudInteraction.Data.Extension.Role roleExt = new Nequeo.DataAccess.CloudInteraction.Data.Extension.Role();
                    Nequeo.DataAccess.CloudInteraction.Data.Role[]         roles   = roleExt.Select.SelectDataEntitiesPredicate(u => (u.RoleID == roleID));

                    // Add to the collection the roles.
                    List <string> rolesForUser = new List <string>();
                    foreach (Nequeo.DataAccess.CloudInteraction.Data.Role role in roles)
                    {
                        rolesForUser.Add(role.RoleName);
                    }

                    // Return the array of roles for user.
                    return(rolesForUser.ToArray());
                }
                else
                {
                    return(new string[0]);
                }
            }
            else
            {
                throw new ProviderException("User username : "******" does not exist.");
            }
        }
Пример #2
0
        /// <summary>
        /// Get the specific role for the current application.
        /// </summary>
        /// <param name="roleID">The roleID.</param>
        /// <returns>The role; else null.</returns>
        private Nequeo.DataAccess.CloudInteraction.Data.Role GetSpecificRole(long roleID)
        {
            // Get the role data.
            Nequeo.DataAccess.CloudInteraction.Data.Extension.Role roleExt = new Nequeo.DataAccess.CloudInteraction.Data.Extension.Role();
            Nequeo.DataAccess.CloudInteraction.Data.Role           role    =
                roleExt.Select.SelectDataEntity(
                    u =>
                    (u.RoleID == roleID)
                    );

            // Return the role.
            return(role);
        }
Пример #3
0
        /// <summary>
        /// Get the specific role for the current application.
        /// </summary>
        /// <param name="roleName">The rolename.</param>
        /// <returns>The role; else null.</returns>
        private Nequeo.DataAccess.CloudInteraction.Data.Role GetSpecificRole(string roleName)
        {
            // Get the role data.
            Nequeo.DataAccess.CloudInteraction.Data.Extension.Role roleExt = new Nequeo.DataAccess.CloudInteraction.Data.Extension.Role();
            Nequeo.DataAccess.CloudInteraction.Data.Role           role    =
                roleExt.Select.SelectDataEntity(
                    u =>
                    (u.RoleName == roleName) &&
                    (u.ApplicationName == ApplicationName)
                    );

            // Return the role.
            return(role);
        }
Пример #4
0
        /// <summary>
        /// Gets a list of all the roles for the configured applicationName.
        /// </summary>
        /// <returns>A string array containing the names of all the roles stored in the data source
        ///  for the configured applicationName.</returns>
        public string[] GetAllRoles()
        {
            Nequeo.DataAccess.CloudInteraction.Data.Extension.Role roleExt = new Nequeo.DataAccess.CloudInteraction.Data.Extension.Role();
            Nequeo.DataAccess.CloudInteraction.Data.Role[]         roles   = roleExt.Select.SelectDataEntitiesPredicate(u => (u.ApplicationName == ApplicationName));

            // Add to the collection the roles.
            List <string> rolesCol = new List <string>();

            foreach (Nequeo.DataAccess.CloudInteraction.Data.Role role in roles)
            {
                rolesCol.Add(role.RoleName);
            }

            // Return the array of roles for user.
            return(rolesCol.ToArray());
        }