Esempio n. 1
0
        public void TrackMultipleRequests(TransitStatsRequest[] requests)
        {
            using (SnCore.Data.Hibernate.Session.OpenConnection())
            {
                ISession session = SnCore.Data.Hibernate.Session.Current;

                ManagedStats stats = new ManagedStats(session);
                foreach (TransitStatsRequest request in requests)
                {
                    try
                    {
                        stats.Track(request);
                        SnCore.Data.Hibernate.Session.Flush();
                    }
                    catch (Exception ex)
                    {
                        EventLogManager.WriteEntry(string.Format("Error tracking {0} from {1}.\n{2}",
                                                                 (request.RequestUri != null) ? request.RequestUri.ToString() : "an unknown url",
                                                                 (request.RefererUri != null) ? request.RefererUri.ToString() : "an unknown referer",
                                                                 ex.Message),
                                                   EventLogEntryType.Warning);
                    }
                }
            }
        }
Esempio n. 2
0
        public void TrackMultipleRequests(TransitStatsRequest[] requests)
        {
            using (SnCore.Data.Hibernate.Session.OpenConnection())
            {
                ISession session = SnCore.Data.Hibernate.Session.Current;

                ManagedStats stats = new ManagedStats(session);
                foreach (TransitStatsRequest request in requests)
                {
                    try
                    {
                        stats.Track(request);
                        SnCore.Data.Hibernate.Session.Flush();
                    }
                    catch (Exception ex)
                    {
                        EventLogManager.WriteEntry(string.Format("Error tracking {0} from {1}.\n{2}",
                            (request.RequestUri != null) ? request.RequestUri.ToString() : "an unknown url",
                            (request.RefererUri != null) ? request.RefererUri.ToString() : "an unknown referer",
                            ex.Message),
                            EventLogEntryType.Warning);
                    }
                }
            }
        }
Esempio n. 3
0
 public void TestTrack()
 {
     ManagedStats stats = new ManagedStats(Session);
     TransitStatsSummary summary1 = stats.GetSummary();
     string uri = string.Format("http://localhost/uri/{0}", Guid.NewGuid());
     string query = string.Format("q={0}", Guid.NewGuid());
     HttpRequest request = new HttpRequest(null, uri, query);
     TransitStatsRequest statsrequest = new TransitStatsRequest(request, null, null);
     stats.Track(statsrequest);
     TransitStatsSummary summary2 = stats.GetSummary();
     Assert.AreEqual(summary1.TotalHits + 1, summary2.TotalHits);
     Assert.AreEqual(summary1.Yearly[summary1.Yearly.Count - 1].Total + 1, summary2.Yearly[summary2.Yearly.Count - 1].Total);
     Assert.AreEqual(summary1.Monthly[summary1.Monthly.Count - 1].Total + 1, summary2.Monthly[summary2.Monthly.Count - 1].Total);
     Assert.AreEqual(summary1.Weekly[summary1.Weekly.Count - 1].Total + 1, summary2.Weekly[summary2.Weekly.Count - 1].Total);
     Assert.AreEqual(summary1.Daily[summary1.Daily.Count - 1].Total + 1, summary2.Daily[summary2.Daily.Count - 1].Total);
 }
Esempio n. 4
0
        public void TestTrack()
        {
            ManagedStats        stats        = new ManagedStats(Session);
            TransitStatsSummary summary1     = stats.GetSummary();
            string              uri          = string.Format("http://localhost/uri/{0}", Guid.NewGuid());
            string              query        = string.Format("q={0}", Guid.NewGuid());
            HttpRequest         request      = new HttpRequest(null, uri, query);
            TransitStatsRequest statsrequest = new TransitStatsRequest(request, null, null);

            stats.Track(statsrequest);
            TransitStatsSummary summary2 = stats.GetSummary();

            Assert.AreEqual(summary1.TotalHits + 1, summary2.TotalHits);
            Assert.AreEqual(summary1.Yearly[summary1.Yearly.Count - 1].Total + 1, summary2.Yearly[summary2.Yearly.Count - 1].Total);
            Assert.AreEqual(summary1.Monthly[summary1.Monthly.Count - 1].Total + 1, summary2.Monthly[summary2.Monthly.Count - 1].Total);
            Assert.AreEqual(summary1.Weekly[summary1.Weekly.Count - 1].Total + 1, summary2.Weekly[summary2.Weekly.Count - 1].Total);
            Assert.AreEqual(summary1.Daily[summary1.Daily.Count - 1].Total + 1, summary2.Daily[summary2.Daily.Count - 1].Total);
        }