Пример #1
0
 private async Task Activity_OnEndSessionAsync(object sender, Core.SessionInfo session)
 {
     using (await padlock.WriterLockAsync())
     {
         Session = null;
     }
 }
Пример #2
0
        public async Task BeginSession_SetsProperty()
        {
            var sink = new PiwikSink(defaultOptions);

            var session = new Core.SessionInfo()
            {
                FirstVisit      = new DateTimeOffset(2000, 2, 3, 4, 5, 6, TimeSpan.FromHours(7)),
                LastVisit       = new DateTimeOffset(2001, 7, 8, 9, 0, 1, TimeSpan.FromHours(2)),
                UniqueVisitorId = "unique ID",
                UserId          = "*****@*****.**",
                VisitsCount     = 5
            };

            await telemetryProvider.Activity.BeginSessionAsync(session);

            //  MD5 hash of a unique visitor ID, truncated to 16 chars.
            var visitorIdHash = "72027364e9fc12df";

            Assert.IsNotNull(sink.Session);
            Assert.AreEqual(session.FirstVisit.Value, sink.Session.FirstVisit.Value);
            Assert.AreEqual(session.LastVisit.Value, sink.Session.LastVisit.Value);
            Assert.AreEqual(visitorIdHash, sink.Session.UniqueVisitorId);
            Assert.AreEqual(session.UserId, sink.Session.UserId);
            Assert.AreEqual(session.VisitsCount, sink.Session.VisitsCount);
        }
Пример #3
0
        public async Task EndSession_ResetsSession()
        {
            var sink = new PiwikSink(defaultOptions);

            var session = new Core.SessionInfo();

            await telemetryProvider.Activity.BeginSessionAsync(session);

            Assert.IsNotNull(sink.Session);

            await telemetryProvider.Activity.EndSessionAsync(session);

            Assert.IsNull(sink.Session);
        }
Пример #4
0
 public void WriteSessionInfo(Core.SessionInfo session)
 {
     try
     {
         if (!string.IsNullOrEmpty(Global.Config.StorageService))
         {
             WebRequest request = HttpWebRequest.Create(Global.Config.StorageService.Replace("{0}", "session"));
             request.Method = "POST";
             //request.GetRequestStream();
             WebResponse response = request.GetResponse();
             //response.GetResponseStream();
         }
         else
         {
             _localStorage.WriteSessionInfo(session);
         }
     }
     catch (Exception ex) { TraceLogger.Instance.WriteException(ex); throw; }
 }
Пример #5
0
        private async Task Activity_OnBeginSessionAsync(object sender, Core.SessionInfo session)
        {
            string visitorIdHash = null;

            if (!string.IsNullOrEmpty(session.UniqueVisitorId))
            {
                visitorIdHash = Hex
                                .ToHexString(DigestUtilities.CalculateDigest("MD5", Encoding.UTF8.GetBytes(session.UniqueVisitorId)))
                                .Substring(0, 16);
            }

            using (await padlock.WriterLockAsync())
            {
                Session = new Api.PiwikSessionInfo()
                {
                    FirstVisit      = session.FirstVisit,
                    LastVisit       = session.LastVisit,
                    VisitsCount     = session.VisitsCount,
                    UniqueVisitorId = visitorIdHash,
                    UserId          = session.UserId
                };
            }
        }
Пример #6
0
 public void WriteSessionInfo(Core.SessionInfo session)
 {
 }
Пример #7
0
 public void WriteSessionInfo(Core.SessionInfo session)
 {
     throw new NotImplementedException();
 }