public override void OnActionExecuted(ActionExecutedContext filterContext) { try { var url = filterContext.RequestContext.HttpContext.Request.Url.AbsoluteUri; var login = filterContext.RequestContext.HttpContext.User.Identity.Name; var address = filterContext.RequestContext.HttpContext.Request.UserHostAddress; var pageTracking = new PageTracking(login, url, address); var repository = SmartServiceLocator<IRepository>.GetService(); //repository.OfType<PageTracking>().EnsurePersistent(pageTracking); //This was saving an item, even though the item had validation errors and ensurepersistent was *NOT* called } catch { // do nothing, problem with tracking } base.OnActionExecuted(filterContext); }
public override void OnActionExecuted(ActionExecutedContext filterContext) { try { var emulation = (bool?)filterContext.HttpContext.Session[StaticIndexes.EmulationKey] ?? false; var url = filterContext.RequestContext.HttpContext.Request.Url.AbsoluteUri; var login = filterContext.RequestContext.HttpContext.User.Identity.Name; var address = filterContext.RequestContext.HttpContext.Request.UserHostAddress; var pageTracking = new PageTracking(login, url, address, emulation); var repository = SmartServiceLocator<IRepository>.GetService(); repository.OfType<PageTracking>().EnsurePersistent(pageTracking); } catch { // do nothing, problem with tracking } base.OnActionExecuted(filterContext); }
public static PageTracking PageTracking(int? count) { var rtValue = new PageTracking(); rtValue.LoginId = "LoginId" + count.Extra(); return rtValue; }