Example #1
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            try
            {
                var visit = new Models.Visit()
                {
                    StartTime = DateTime.UtcNow,
                    IpAddress = filterContext.HttpContext.Request.UserHostAddress,
                    Website   = Website,
                    Location  = filterContext.HttpContext.Request.RawUrl,
                    UserAgent = filterContext.HttpContext.Request.UserAgent,
                    Referrer  = (null != filterContext.HttpContext.Request.UrlReferrer) ? filterContext.HttpContext.Request.UrlReferrer.AbsoluteUri : null
                };

                db = new Database.AnalyticsDb(NameOrConnectionString);
                db.Analytics_Visits.Add(visit);
                db.SaveChanges();

                VisitId = visit.Id;
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
        }
Example #2
0
        public ReportController(string nameOrConnectionString, string siteName)
        {
            Database.ConnectionHolder.NameOrConnectionString = nameOrConnectionString;

            NameOrConnectionString = nameOrConnectionString;
            SiteName = siteName;

            db = new Database.AnalyticsDb(NameOrConnectionString);
        }