/// <summary> /// Load users in the id list /// </summary> /// <param name="idList">List of user ids</param> private void ParseUserIdList(string idList) { // VALIDATE THE INPUT if (string.IsNullOrEmpty(idList)) { throw new ArgumentNullException("idList"); } if (!Regex.IsMatch(idList, "^\\d+(,\\d+)*$")) { throw new ArgumentException("Id list can only be a comma delimited list of integer.", "idList"); } // PARSE THE LIST OF INTEGERS if (idList.Contains(",")) { ICriteria criteria = NHibernateHelper.CreateCriteria <User>(); criteria.Add(Restrictions.Eq("Store", AbleContext.Current.Store)); criteria.Add(Restrictions.In("Id", AlwaysConvert.ToIntArray(idList))); _UserList = UserDataSource.LoadForCriteria(criteria); } else { ICriteria criteria = NHibernateHelper.CreateCriteria <User>(); criteria.Add(Restrictions.Eq("Store", AbleContext.Current.Store)); criteria.Add(Restrictions.Eq("Id", AlwaysConvert.ToInt(idList))); _UserList = UserDataSource.LoadForCriteria(criteria); } }
private void InitAnonUserStatus() { // GET COUNT OF ANONYMOUS USERS ICriteria criteria = NHibernateHelper.CreateCriteria <User>() .Add(Restrictions.Eq("IsAnonymous", true)) .Add(Restrictions.IsNull("Affiliate")); int anonUserCount = UserDataSource.CountForCriteria(criteria); AnonymousUserCount.Text = anonUserCount.ToString(); criteria = NHibernateHelper.CreateCriteria <User>(1, 0, "LastActivityDate") .Add(Restrictions.Eq("IsAnonymous", true)) .Add(Restrictions.IsNull("Affiliate")) .Add(Restrictions.IsNotNull("LastActivityDate")); IList <User> anonUsers = UserDataSource.LoadForCriteria(criteria); if (anonUsers != null && anonUsers.Count > 0) { OldestAnonUser.Text = GetElapsedDays(anonUsers[0].LastActivityDate.Value).ToString() + " days @ " + anonUsers[0].LastActivityDate.ToString(); } else { OldestAnonUser.Text = "n/a"; } criteria = NHibernateHelper.CreateCriteria <User>() .Add(Restrictions.Eq("IsAnonymous", true)) .Add(Restrictions.IsNotNull("Affiliate")); int anonAffiliateUserCount = UserDataSource.CountForCriteria(criteria); AffiliateAnonymousUserCount.Text = anonAffiliateUserCount.ToString(); criteria = NHibernateHelper.CreateCriteria <User>(1, 0, "LastActivityDate") .Add(Restrictions.Eq("IsAnonymous", true)) .Add(Restrictions.IsNotNull("Affiliate")) .Add(Restrictions.IsNotNull("LastActivityDate")); anonUsers = UserDataSource.LoadForCriteria(criteria); if (anonUsers != null && anonUsers.Count > 0) { OldestAffAnonUser.Text = GetElapsedDays(anonUsers[0].LastActivityDate.Value).ToString() + " days @ " + anonUsers[0].LastActivityDate.ToString(); } else { OldestAffAnonUser.Text = "n/a"; } }