Example #1
0
        /// <summary>
        /// When overridden in a derived class, returns the number of profiles in which
        /// the last activity date occurred on or before the specified date.
        /// </summary>
        /// <param name="authenticationOption">One of the System.Web.Profile.ProfileAuthenticationOption values, specifying
        /// whether anonymous, authenticated, or both types of profiles are returned.</param>
        /// <param name="userInactiveSinceDate">A System.DateTime that identifies which user profiles are considered inactive.
        /// If the System.Web.Profile.ProfileInfo.LastActivityDate of a user profile
        /// occurs on or before this date and time, the profile is considered inactive.</param>
        /// <returns>The number of profiles in which the last activity date occurred on or before
        /// the specified date.</returns>
        public int GetNumberOfInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
        {
            int inactiveCount = 0;

            // Get all inactive profiles.
            Nequeo.DataAccess.CloudInteraction.Data.Profile[]             profiles   = GetInactiveProfiles(userInactiveSinceDate);
            IEnumerable <Nequeo.DataAccess.CloudInteraction.Data.Profile> profileCol = null;

            // Select the authentication option
            switch (authenticationOption)
            {
            case ProfileAuthenticationOption.Anonymous:
                profileCol = profiles.Where(u => u.IsAnonymous == true);
                break;

            case ProfileAuthenticationOption.Authenticated:
                profileCol = profiles.Where(u => u.IsAnonymous == false);
                break;

            default:
                profileCol = profiles.AsEnumerable();
                break;
            }

            // Return the inactive profiles..
            if (profileCol != null)
            {
                inactiveCount = profileCol.Count();
            }

            // The number of inactive profiles.
            return(inactiveCount);
        }
        public int GetNumberOfInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption oAuthenticationOption, DateTime dUserInactiveSinceDate)
        {
            #region VARIBLES

            System.Web.Profile.ProfileProvider oSitecoreSqlProfileProvider;
            int iNumberOfInactiveProfiles;

            #endregion

            //Sitecore.Diagnostics.Log.Info("GenProfileProviderService.GetNumberOfInactiveProfiles", this);

            oSitecoreSqlProfileProvider = ProfileManager.Providers[DefaultProviderName];
            iNumberOfInactiveProfiles   = 0;

            if (oSitecoreSqlProfileProvider != null)
            {
                iNumberOfInactiveProfiles = oSitecoreSqlProfileProvider.GetNumberOfInactiveProfiles(oAuthenticationOption, dUserInactiveSinceDate);
                Sitecore.Diagnostics.Log.Info(string.Format("GenProfileProviderService.GetNumberOfInactiveProfiles, Profiles:{0}", iNumberOfInactiveProfiles), this);
            }
            else
            {
                Sitecore.Diagnostics.Log.Warn("GenProfileProviderService.GetNumberOfInactiveProfiles, Unable to find SqlProfileProvider", this);
            }

            return(iNumberOfInactiveProfiles);
        }
Example #3
0
        /// <summary>
        /// Get a collection of profiles.
        /// </summary>
        /// <param name="authenticationOption">Current authentication option setting.</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRecords">Total records found (output).</param>
        /// <returns>Collection of profiles.</returns>
        public override System.Web.Profile.ProfileInfoCollection GetAllProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords)
        {
            IObjectScope objScope         = ORM.GetNewObjectScope();
            const string queryAllProfiles = @"SELECT * FROM EmployeeProfileExtent AS o";

            return(QueryProfileInfos(objScope, queryAllProfiles, null, pageIndex, pageSize, out totalRecords));
        }
        /// <summary>
        /// *Note Currently not supported -- Get the number of inactive profiles based upon an inactivity date.
        /// </summary>
        public override int GetNumberOfInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
        {
            int inactiveProfiles = 0;

            GetProfileInfo(authenticationOption, null, userInactiveSinceDate, 0, 0, out inactiveProfiles);

            return(inactiveProfiles);
        }
 /// <summary>
 /// *Note Currently not supported -- Get a collection of profiles.
 /// </summary>
 public override System.Web.Profile.ProfileInfoCollection GetAllProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords)
 {
     return(GetProfileInfo(
                authenticationOption,
                null,
                null,
                pageIndex,
                pageSize,
                out totalRecords
                ));
 }
Example #6
0
        /// <summary>
        /// Get the number of inactive profiles based upon an inactivity date.
        /// </summary>
        /// <param name="authenticationOption">Current authentication option setting.</param>
        /// <param name="userInactiveSinceDate">Inactivity date for deletion.</param>
        /// <returns>Number of profiles.</returns>
        public override int GetNumberOfInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
        {
            IObjectScope objScope       = ORM.GetNewObjectScope();
            const string queryOnlineNum = @"ELEMENT (SELECT COUNT(*) FROM EmployeeProfileExtent AS o WHERE o.Employee.LastActivityDate > $1)";
            TimeSpan     onlineSpan     = new TimeSpan(0, System.Web.Security.Membership.UserIsOnlineTimeWindow, 0);
            DateTime     compareTime    = DateTime.Now.Subtract(onlineSpan);
            IQuery       oqlQuery       = objScope.GetOqlQuery(queryOnlineNum);

            using (IQueryResult result = oqlQuery.Execute(compareTime))
                return((int)result[0]);
        }
 /// <summary>
 /// Deletes profiles that have been inactive since the specified date.
 /// </summary>
 /// <param name="authenticationOption">Current authentication option setting.</param>
 /// <param name="userInactiveSinceDate">Inactivity date for deletion.</param>
 /// <returns>Number of records deleted.</returns>
 public override int DeleteInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
 {
     try
     {
         DB.ExecuteSQL("Delete from Profile where UpdatedOn < '" + userInactiveSinceDate + "'");
         return(1);
     }
     catch
     {
         return(0);
     }
 }
Example #8
0
        /// <summary>
        /// When overridden in a derived class, deletes all user-profile data for profiles
        /// in which the last activity date occurred before the specified date.
        /// </summary>
        /// <param name="authenticationOption">One of the System.Web.Profile.ProfileAuthenticationOption values, specifying
        /// whether anonymous, authenticated, or both types of profiles are deleted.</param>
        /// <param name="userInactiveSinceDate">A System.DateTime that identifies which user profiles are considered inactive.
        /// If the System.Web.Profile.ProfileInfo.LastActivityDate value of a user profile
        /// occurs on or before this date and time, the profile is considered inactive.</param>
        /// <returns>The number of profiles deleted from the data source.</returns>
        public int DeleteInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
        {
            int deleteCount = 0;

            // Get all inactive profiles.
            Nequeo.DataAccess.CloudInteraction.Data.Profile[]             profiles   = GetInactiveProfiles(userInactiveSinceDate);
            IEnumerable <Nequeo.DataAccess.CloudInteraction.Data.Profile> profileCol = null;

            // Select the authentication option
            switch (authenticationOption)
            {
            case ProfileAuthenticationOption.Anonymous:
                profileCol = profiles.Where(u => u.IsAnonymous == true);
                break;

            case ProfileAuthenticationOption.Authenticated:
                profileCol = profiles.Where(u => u.IsAnonymous == false);
                break;

            default:
                profileCol = profiles.AsEnumerable();
                break;
            }

            List <string> usernames = new List <string>();

            // Return the username.
            if (profileCol != null)
            {
                if (profileCol.Count() > 0)
                {
                    // Get the list of inactive user profiles.
                    foreach (Nequeo.DataAccess.CloudInteraction.Data.Profile profile in profileCol)
                    {
                        usernames.Add(profile.Username);
                    }

                    // Delete the specified user profiles.
                    if (usernames.Count > 0)
                    {
                        deleteCount = DeleteProfiles(usernames.ToArray());
                    }
                }
            }

            // The number of profiles deleted.
            return(deleteCount);
        }
Example #9
0
        /// <summary>
        /// Deletes profiles that have been inactive since the specified date.
        /// </summary>
        /// <param name="authenticationOption">Current authentication option setting.</param>
        /// <param name="userInactiveSinceDate">Inactivity date for deletion.</param>
        /// <returns>Number of records deleted.</returns>
        public override int DeleteInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
        {
            IObjectScope objScope = ORM.GetNewObjectScope();

            objScope.Transaction.Begin();

            int          deleteCounter         = 0;
            const string queryInactiveProfiles =
                @"SELECT * FROM EmployeeProfileExtent AS o WHERE o.Employee.LastActivityDate <= $1";
            IQuery oqlQuery = objScope.GetOqlQuery(queryInactiveProfiles);

            using (IQueryResult result = oqlQuery.Execute(userInactiveSinceDate))
            {
                foreach (object p in result)
                {
                    objScope.Remove(p);
                    deleteCounter++;
                }
            }
            objScope.Transaction.Commit();
            return(deleteCounter);
        }
Example #10
0
        /// <summary>
        /// Get a collection of profiles based upon a user name matching string and inactivity date.
        /// </summary>
        /// <param name="authenticationOption">Current authentication option setting.</param>
        /// <param name="userNameToMatch">Characters representing user name to match (L to R).</param>
        /// <param name="userInactiveSinceDate">Inactivity date for deletion.</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRecords">Total records found (output).</param>
        /// <returns>Collection of profiles.</returns>
        public override System.Web.Profile.ProfileInfoCollection FindInactiveProfilesByUserName(System.Web.Profile.ProfileAuthenticationOption authenticationOption, string userNameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
        {
            IObjectScope objScope = ORM.GetNewObjectScope();
            const string queryInactiveProfilesByUserName =
                @"SELECT * FROM EmployeeProfileExtent AS o WHERE o.Employee.Name LIKE $1 AND o.Employee.LastActivityDate <= $2";
            ProfileInfoCollection pic = new ProfileInfoCollection();
            IQuery query = objScope.GetOqlQuery(queryInactiveProfilesByUserName);

            using (IQueryResult result = query.Execute(userNameToMatch + '*', userInactiveSinceDate))
            {
                totalRecords = result.Count;
                int counter    = 0;
                int startIndex = pageSize * pageIndex;
                int endIndex   = startIndex + pageSize - 1;

                foreach (object res in result)
                {
                    if (counter >= startIndex)
                    {
                        EmployeeProfile ep = res as EmployeeProfile;
                        pic.Add(new ProfileInfo(ep.Employee.Name, false, ep.Employee.LastActivityDate, ep.LastUpdatedDate, 0));
                    }
                    if (counter >= endIndex)
                    {
                        break;
                    }
                    counter += 1;
                }
            }
            return(pic);
        }
        public System.Web.Profile.ProfileInfoCollection FindProfilesByUserName(out int iTotalRecords, int iPageIndex, int iPageSize, System.Web.Profile.ProfileAuthenticationOption oAuthenticationOption, string sUsernameToMatch)
        {
            #region VARIBLES

            System.Web.Profile.ProfileProvider oSitecoreSqlProfileProvider;
            ProfileInfoCollection oUserProfiles;

            #endregion

            Sitecore.Diagnostics.Log.Info("GenProfileProviderService.FindProfilesByUserName", this);


            oSitecoreSqlProfileProvider = ProfileManager.Providers[DefaultProviderName];
            oUserProfiles = null;
            iTotalRecords = 0;
            if (oSitecoreSqlProfileProvider != null)
            {
                oUserProfiles = oSitecoreSqlProfileProvider.FindProfilesByUserName(oAuthenticationOption, sUsernameToMatch, iPageIndex, iPageSize, out iTotalRecords);
                if (oUserProfiles != null)
                {
                    Sitecore.Diagnostics.Log.Info(string.Format("GenProfileProviderService.FindProfilesByUserName, UserProfiles:{0}", oUserProfiles.Count), this);
                }
            }
            else
            {
                Sitecore.Diagnostics.Log.Warn("GenProfileProviderService.FindProfilesByUserName, Unable to find SqlProfileProvider", this);
            }

            return(oUserProfiles);
        }
 public override int GetNumberOfInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
 {
     throw new NotImplementedException();
 }
        public System.Web.Profile.ProfileInfoCollection GetAllInactiveProfiles(out int iTotalRecords, int iPageIndex, int iPageSize, System.Web.Profile.ProfileAuthenticationOption oAuthenticationOption, DateTime dUserInactiveSinceDate)
        {
            #region VARIBLES

            System.Web.Profile.ProfileProvider oSitecoreSqlProfileProvider;
            ProfileInfoCollection oInactiveProfiles;

            #endregion

            Sitecore.Diagnostics.Log.Info("GenProfileProviderService.GetAllInactiveProfiles", this);


            oSitecoreSqlProfileProvider = ProfileManager.Providers[DefaultProviderName];
            oInactiveProfiles           = null;
            iTotalRecords = 0;
            if (oSitecoreSqlProfileProvider != null)
            {
                oInactiveProfiles = oSitecoreSqlProfileProvider.GetAllInactiveProfiles(oAuthenticationOption, dUserInactiveSinceDate, iPageIndex, iPageSize, out iTotalRecords);
                if (oInactiveProfiles != null)
                {
                    Sitecore.Diagnostics.Log.Info(string.Format("GenProfileProviderService.GetAllInactiveProfiles, InactiveProfiles:{0}", oInactiveProfiles.Count), this);
                }
            }
            else
            {
                Sitecore.Diagnostics.Log.Warn("GenProfileProviderService.GetAllInactiveProfiles, Unable to find SqlProfileProvider", this);
            }

            return(oInactiveProfiles);
        }
 public override ProfileInfoCollection GetAllProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords)
 {
     throw new NotImplementedException();
 }
Example #15
0
        /// <summary>
        /// When overridden in a derived class, retrieves user profile data for all profiles
        /// in the data source.
        /// </summary>
        /// <param name="authenticationOption">One of the System.Web.Profile.ProfileAuthenticationOption values, specifying
        /// whether anonymous, authenticated, or both types of profiles are returned.</param>
        /// <param name="pageIndex">The index of the page of results to return.</param>
        /// <param name="pageSize">The size of the page of results to return.</param>
        /// <param name="totalRecords">When this method returns, contains the total number of profiles.</param>
        /// <returns>A System.Web.Profile.ProfileInfoCollection containing user-profile information
        /// for all profiles in the data source.</returns>
        public System.Web.Profile.ProfileInfoCollection GetAllProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption,
                                                                       int pageIndex, int pageSize, out int totalRecords)
        {
            ProfileInfoCollection profileInfoCol = new ProfileInfoCollection();

            Nequeo.DataAccess.CloudInteraction.Data.Extension.Profile profile = new Nequeo.DataAccess.CloudInteraction.Data.Extension.Profile();

            // Get all the profiles for the match.
            long profilesMatched = 0;
            int  skipNumber      = (pageIndex * pageSize);

            // Get the current set on data.
            IQueryable <Data.Profile> profileData = null;

            // Select the authentication option
            switch (authenticationOption)
            {
            case ProfileAuthenticationOption.Anonymous:
                profileData = profile.Select.QueryableProvider().
                              Where(u =>
                                    (u.ApplicationName == ApplicationName) && (u.IsAnonymous == true)).
                              OrderBy(u => u.Username).
                              Take(pageSize).
                              Skip(skipNumber);

                profilesMatched = profile.Select.GetRecordCount(u => (u.ApplicationName == ApplicationName) && (u.IsAnonymous == true));
                totalRecords    = Int32.Parse(profilesMatched.ToString());
                break;

            case ProfileAuthenticationOption.Authenticated:
                profileData = profile.Select.QueryableProvider().
                              Where(u =>
                                    (u.ApplicationName == ApplicationName) && (u.IsAnonymous == false)).
                              OrderBy(u => u.Username).
                              Take(pageSize).
                              Skip(skipNumber);

                profilesMatched = profile.Select.GetRecordCount(u => (u.ApplicationName == ApplicationName) && (u.IsAnonymous == false));
                totalRecords    = Int32.Parse(profilesMatched.ToString());
                break;

            default:
                // Get all the profiles for the match.
                profilesMatched = profile.Select.GetRecordCount(
                    u =>
                    (u.ApplicationName == ApplicationName));

                // Get the total number of uses.
                totalRecords = Int32.Parse(profilesMatched.ToString());

                // Get the current set on data.
                profileData = profile.Select.QueryableProvider().
                              Where(u =>
                                    (u.ApplicationName == ApplicationName)).
                              OrderBy(u => u.Username).
                              Take(pageSize).
                              Skip(skipNumber);
                break;
            }

            // For each profile found.
            if (profileData != null)
            {
                foreach (Data.Profile item in profileData)
                {
                    // Create the membership user.
                    System.Web.Profile.ProfileInfo profileUser =
                        new System.Web.Profile.ProfileInfo(
                            item.Username,
                            item.IsAnonymous.Value,
                            item.LastActivityDate.Value,
                            item.LastUpdatedDate.Value,
                            0);

                    // Add the profile to the collection.
                    profileInfoCol.Add(profileUser);
                }
            }

            // Return the collection of profile users.
            return(profileInfoCol);
        }
Example #16
0
 public System.Web.Profile.ProfileInfoCollection FindProfilesByUserName(System.Web.Profile.ProfileAuthenticationOption authenticationOption, string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
 {
     return(profileProvider.FindProfilesByUserName(authenticationOption, usernameToMatch, pageIndex, pageSize, out totalRecords));
 }
Example #17
0
        /// <summary>
        /// Get a collection of profiles based upon a user name matching string.
        /// </summary>
        /// <param name="authenticationOption">Current authentication option setting.</param>
        /// <param name="userNameToMatch">Characters representing user name to match (L to R).</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRecords">Total records found (output).</param>
        /// <returns>Collection of profiles.</returns>
        public override System.Web.Profile.ProfileInfoCollection FindProfilesByUserName(System.Web.Profile.ProfileAuthenticationOption authenticationOption, string userNameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            IObjectScope objScope = ORM.GetNewObjectScope();
            const string queryProfilesByUserName = @"SELECT * FROM EmployeeProfileExtent AS o WHERE o.Employee.Name LIKE $1";

            return(QueryProfileInfos(objScope, queryProfilesByUserName, userNameToMatch + '*', pageIndex, pageSize, out totalRecords));
        }
Example #18
0
 public int GetNumberOfInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, System.DateTime userInactiveSinceDate)
 {
     return(profileProvider.GetNumberOfInactiveProfiles(authenticationOption, userInactiveSinceDate));
 }
Example #19
0
 public System.Web.Profile.ProfileInfoCollection GetAllProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords)
 {
     return(profileProvider.GetAllProfiles(authenticationOption, pageIndex, pageSize, out totalRecords));
 }
Example #20
0
 public System.Web.Profile.ProfileInfoCollection GetAllInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, System.DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
 {
     return(profileProvider.GetAllInactiveProfiles(authenticationOption, userInactiveSinceDate, pageIndex, pageSize, out totalRecords));
 }
Example #21
0
        /// <summary>
        /// Get a collection of profiles based upon an inactivity date.
        /// </summary>
        /// <param name="authenticationOption">Current authentication option setting.</param>
        /// <param name="userInactiveSinceDate">Inactivity date for deletion.</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRecords">Total records found (output).</param>
        /// <returns>Collection of profiles.</returns>
        public override System.Web.Profile.ProfileInfoCollection GetAllInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
        {
            IObjectScope objScope = ORM.GetNewObjectScope();
            const string queryAllInactiveProfiles = @"SELECT * FROM EmployeeProfileExtent AS o WHERE o.Employee.LastActivityDate <= $1";

            return(QueryProfileInfos(objScope, queryAllInactiveProfiles, userInactiveSinceDate, pageIndex, pageSize, out totalRecords));
        }
 /// <summary>
 /// *Note Currently not supported -- Get a collection of profiles based upon a user name matching string.
 /// </summary>
 public override System.Web.Profile.ProfileInfoCollection FindProfilesByUserName(System.Web.Profile.ProfileAuthenticationOption authenticationOption, string userNameToMatch, int pageIndex, int pageSize, out int totalRecords)
 {
     return(GetProfileInfo(
                authenticationOption,
                userNameToMatch,
                null,
                pageIndex,
                pageSize,
                out totalRecords
                ));
 }
 /// <summary>
 /// *Note Currently not supported -- Get a collection of profiles based upon an inactivity date.
 /// </summary>
 public override System.Web.Profile.ProfileInfoCollection GetAllInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
 {
     return(GetProfileInfo(
                authenticationOption,
                null,
                userInactiveSinceDate,
                pageIndex,
                pageSize,
                out totalRecords
                ));
 }
 public override ProfileInfoCollection FindInactiveProfilesByUserName(System.Web.Profile.ProfileAuthenticationOption authenticationOption, string usernameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
 {
     throw new NotImplementedException();
 }