Пример #1
0
        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";
            }
        }