예제 #1
0
        /// <summary>
        /// Gets a collection of all the users in the data source in pages of data.
        /// </summary>
        /// <param name="pageIndex">The index of the page of results to return. <paramref name="pageIndex"/> is zero-based.</param>
        /// <param name="pageSize">The size of the page of results to return.</param>
        /// <param name="totalRecords">The total number of matched users.</param>
        /// <returns>
        /// A <see cref="T:System.Web.Security.MembershipUserCollection"/> collection that contains a page of <paramref name="pageSize"/><see cref="T:System.Web.Security.MembershipUser"/> objects beginning at the page specified by <paramref name="pageIndex"/>.
        /// </returns>
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            MembershipUserCollection membershipUsers = new MembershipUserCollection();

            UserService UserService = new CMS.UserService();

            int counter    = 0;
            int startIndex = pageSize * pageIndex;
            int endIndex   = startIndex + pageSize - 1;

            foreach (Rock.CMS.User user
                     in UserService.Queryable().Where(u =>
                                                      u.ApplicationName == applicationName))
            {
                if (counter >= startIndex && counter <= endIndex)
                {
                    membershipUsers.Add(GetUserFromModel(user));
                }

                counter++;
            }

            totalRecords = counter;
            return(membershipUsers);
        }
예제 #2
0
        /// <summary>
        /// Gets a collection of membership users where the user name contains the specified user name to match.
        /// </summary>
        /// <param name="usernameToMatch">The user name to search for.</param>
        /// <param name="pageIndex">The index of the page of results to return. <paramref name="pageIndex"/> is zero-based.</param>
        /// <param name="pageSize">The size of the page of results to return.</param>
        /// <param name="totalRecords">The total number of matched users.</param>
        /// <returns>
        /// A <see cref="T:System.Web.Security.MembershipUserCollection"/> collection that contains a page of <paramref name="pageSize"/><see cref="T:System.Web.Security.MembershipUser"/> objects beginning at the page specified by <paramref name="pageIndex"/>.
        /// </returns>
        public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            MembershipUserCollection membershipUsers = new MembershipUserCollection();

            UserService UserService = new CMS.UserService();

            int counter    = 0;
            int startIndex = pageSize * pageIndex;
            int endIndex   = startIndex + pageSize - 1;

            foreach (Rock.CMS.User user
                     in UserService.Queryable().Where(u =>
                                                      u.ApplicationName == applicationName &&
                                                      u.Username.ToLower().StartsWith(usernameToMatch.ToLower())))
            {
                if (counter >= startIndex && counter <= endIndex)
                {
                    membershipUsers.Add(GetUserFromModel(user));
                }

                counter++;
            }

            totalRecords = counter;
            return(membershipUsers);
        }
예제 #3
0
        /// <summary>
        /// Gets the number of users currently accessing the application.
        /// </summary>
        /// <returns>
        /// The number of users currently accessing the application.
        /// </returns>
        public override int GetNumberOfUsersOnline()
        {
            UserService UserService = new CMS.UserService();

            TimeSpan onlineSpan  = new TimeSpan(0, System.Web.Security.Membership.UserIsOnlineTimeWindow, 0);
            DateTime compareTime = DateTime.Now.Subtract(onlineSpan);

            return(UserService.Queryable().Where(u =>
                                                 u.ApplicationName == applicationName &&
                                                 u.LastActivityDate > compareTime).Count());
        }