예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var tc = new ItemController();
                rptItemList.DataSource = tc.GetItems(ModuleId);
                rptItemList.DataBind();

                StatisticsInfo statics = OnlineUsersController.GetStatistics(PortalId, true);

                lblUserOnline.Text = "Tổng lượng truy cập: " + statics.OnlineTotalCount.ToString();
                lblUserAccess.Text = "Khách đang online: " + statics.AnonymousUserCount.ToString();
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
예제 #2
0
        public static StatisticsInfo GetStatistics(int portalID, bool IncludeHost)
        {
            StatisticsInfo statistics = new StatisticsInfo();
            IDataReader    reader     = null;

            try
            {
                reader = _GetStatistics(portalID, IncludeHost);
                if (reader.Read())
                {
                    statistics.AnonymousUserCount = reader.GetInt32(0);
                }
                reader.NextResult();

                if (reader.Read())
                {
                    statistics.OnlineUserCount = reader.GetInt32(0);
                }
                reader.NextResult();

                if (reader.Read())
                {
                    statistics.OnlineUserInfo.UserId      = reader.GetInt32(0);
                    statistics.OnlineUserInfo.UserName    = reader.GetString(1);
                    statistics.OnlineUserInfo.DisplayName = reader.GetString(2);
                    statistics.OnlineUserInfo.FirstName   = reader.GetString(3);
                    statistics.OnlineUserInfo.LastName    = reader.GetString(4);
                    statistics.OnlineUserInfo.FullName    = reader.GetString(5);
                    statistics.OnlineUserInfo.TabID       = DotNetNuke.Common.Utilities.Null.NullInteger;
                    statistics.OnlineUserInfo.TabName     = DotNetNuke.Common.Utilities.Null.NullString;
                    statistics.OnlineUserInfo.TabIsSecure = DotNetNuke.Common.Utilities.Null.NullBoolean;
                }
                reader.NextResult();

                if (reader.Read())
                {
                    statistics.MembershipCount = reader.GetInt32(0);
                }
                reader.NextResult();


                if (reader.Read())
                {
                    statistics.MembershipTodayCount = reader.GetInt32(0);
                }
                reader.NextResult();

                if (reader.Read())
                {
                    statistics.MembershipYesterdayCount = reader.GetInt32(0);
                }

                reader.Close();
                reader.Dispose();
                reader = null;

                statistics.OnlineTotalCount = statistics.AnonymousUserCount + statistics.OnlineUserCount;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (reader != null)
                {
                    reader.Dispose();
                    reader = null;
                }
            }
            return(statistics);
        }