public override string Data()
        {
            StringBuilder            Result     = new StringBuilder("Country|Total Visitors|Is Bot\r");
            List <UserSession>       sessions   = UserSessionManager.Clone;
            List <SessionStatistics> statistics = new List <SessionStatistics>();


            foreach (UserSession session in sessions)
            {
                string            countryCode = String.IsNullOrEmpty(session.CountryCode) ? "ZZ" : session.CountryCode;
                SessionStatistics stats       = statistics.Where(s => s.IsBot == session.IsBot &&
                                                                 s.CountryCode.Equals(countryCode)).FirstOrDefault();

                if (stats == null)
                {
                    stats = new SessionStatistics(countryCode);
                    statistics.Add(stats);
                }

                stats.Count++;
            }

            foreach (SessionStatistics stats in statistics)
            {
                Result.Append(stats.CountryCode + "|");
                Result.Append(stats.Count.ToString() + "|");
                //Result.Append(cpu.Substring(cpu.IndexOf("/") + 1) + "|");
                //Result.Append(SplitText(parts[2], ':') + "|");
                //Result.Append(SplitText(parts[3], ':') + "|");
                //Result.Append(SplitText(parts[4], ':') + "|");
                Result.Append(stats.IsBot ? "Yes" : "No" + "\r");
            }

            return(Result.ToString().Trim());
        }
Пример #2
0
        public override string Data()
        {
            StringBuilder            Result     = new StringBuilder("Country|Total Sales|Value\r");
            List <UserSession>       sessions   = UserSessionManager.Clone;
            List <SessionStatistics> statistics = new List <SessionStatistics>();


            foreach (UserSession session in sessions)
            {
                if (session.CurrentSale <= 0)
                {
                    continue;
                }

                string            countryCode = String.IsNullOrEmpty(session.CountryCode) ? "ZZ" : session.CountryCode;
                SessionStatistics stats       = statistics.Where(s => s.IsBot == session.IsBot &&
                                                                 s.CountryCode.Equals(countryCode)).FirstOrDefault();

                if (stats == null)
                {
                    stats = new SessionStatistics(countryCode);
                    statistics.Add(stats);
                }

                stats.Count++;
                stats.Value += session.CurrentSale;
            }

            foreach (SessionStatistics stats in statistics)
            {
                Result.Append(stats.CountryCode + "|");
                Result.Append(stats.Count.ToString() + "|");
                Result.Append(stats.Value.ToString("G") + "\r");
            }

            return(Result.ToString().Trim());
        }