Exemple #1
0
    /// <summary>
    /// Fill statistics boundaries (from - to)
    /// </summary>
    private void FillStatisticsBoundaries()
    {
        // Fill statistics boundaries
        string statCodeName = drpDeleteObjects.SelectedValue;

        String where = GenerateWhereCondition(statCodeName);

        // Add 'AND' if where condition applied
        if (!String.IsNullOrEmpty(where))
        {
            where = " AND " + where;
        }

        // Select data from current site and filter by codename
        string boundariesWhere = "HitsStatisticsID IN (SELECT StatisticsID FROM Analytics_Statistics WHERE StatisticsSiteID =" + SiteContext.CurrentSiteID + @where + ") ";

        // Set interval text for no records
        lblIntervalInfo.Text = "-";

        DataSet ds = HitsDayInfoProvider.GetStatisticsBoundaries(boundariesWhere);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            DateTime dtFrom = ValidationHelper.GetDateTime(ds.Tables[0].Rows[0]["DateFrom"], DateTimeHelper.ZERO_TIME);
            DateTime dtTo   = ValidationHelper.GetDateTime(ds.Tables[0].Rows[0]["DateTo"], DateTimeHelper.ZERO_TIME);
            if ((dtFrom != DateTimeHelper.ZERO_TIME) && (dtTo != DateTimeHelper.ZERO_TIME))
            {
                lblIntervalInfo.Text = dtFrom.ToString("d") + "  -  " + dtTo.ToString("d");
            }
        }
    }
Exemple #2
0
        /// <summary>
        /// Gets number of visitors for the last week based on statistics with given staticstics type.
        /// </summary>
        /// <param name="siteId">ID of the site</param>
        /// <param name="statisticsCode">Statistics code</param>
        /// <exception cref="ArgumentException"><paramref name="statisticsCode"/> is null or empty.</exception>
        /// <returns>Visitors count</returns>
        private int GetVisitCount(int siteId, string statisticsCode)
        {
            if (string.IsNullOrEmpty(statisticsCode))
            {
                throw new ArgumentException("statisticsCode");
            }

            var statistics = StatisticsInfoProvider.GetStatistics()
                             .OnSite(siteId)
                             .Column("StatisticsID")
                             .WhereEquals("StatisticsCode", statisticsCode);

            var hits = HitsDayInfoProvider.GetHitsDays()
                       .WhereIn("HitsStatisticsID", statistics)
                       .WhereGreaterThan("HitsStartTime", DateTime.Now.AddDays(-7).Date)
                       .Column(new AggregatedColumn(AggregationType.Sum, "HitsCount"));

            int count = 0;

            if (!DataHelper.DataSourceIsEmpty(hits))
            {
                count = ValidationHelper.GetInteger(hits.Tables[0].Rows[0][0], 0);
            }

            return(count);
        }