public static void Visit(string visitorId)
        {
            var visitor = VisitorList.FirstOrDefault(x => x.Id == visitorId);

            if (visitor == null)
            {
                VisitorList.Add(new Visitor
                {
                    Id            = visitorId,
                    FirstVisitAt  = DateTime.Now,
                    LatestVisitAt = DateTime.Now
                });
            }
            else
            {
                visitor.LatestVisitAt = DateTime.Now;
            }
        }
示例#2
0
        /// <summary>
        /// This method called when the request arrives.
        /// </summary>
        /// <param name="visitorId">visitor identity</param>
        public static void Visit(string visitorId)
        {
            var visitor = VisitorList.FirstOrDefault(x => x.Id == visitorId);
            var d       = DateTime.Now;

            if (visitor == null)
            {
                VisitorList.Add(new Visitor
                {
                    Id            = visitorId,
                    FirstVisitAt  = d,
                    LatestVisitAt = d,
                    ExpiredAt     = d.AddSeconds(ViCounterSettings.ActivityDuration)
                });
            }
            else
            {
                visitor.LatestVisitAt = d;
                visitor.ExpiredAt     = d.AddSeconds(ViCounterSettings.ActivityDuration);
            }
        }