Ejemplo n.º 1
0
        protected object GetInternal(string key, bool slide = true, bool slideAsync = true)
        {
            var data   = HttpContext.Current.GetCacheItem(key);
            var result = data;

            if (slide)
            {
                var expire = UnlockedExtensions.GetNextTimeout(configuration.SessionTimeout);
                var prefix = GetSessionItemPrefix();
                SlideInternal(prefix, (int)expire.TotalSeconds, slideAsync);
            }
            return(result);
        }
        //public override void OnActionExecuted(ActionExecutedContext filterContext)
        //{
        //	base.OnActionExecuted(filterContext);
        //}

        //public override void OnResultExecuting(ResultExecutingContext filterContext)
        //{
        //	base.OnResultExecuting(filterContext);
        //}

        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            if (UnlockedStateStoreConfiguration.Instance.Disabled)
            {
                return;
            }
            if (Usage == UnlockedStateUsage.ReadWrite)
            {
                //var session = filterContext.HttpContext.GetContextItem(UNLOCKED_STATE_OBJECT_KEY);
                if (UnlockedStateStore.Items.Count > 0)
                {
                    //filterContext.StartSessionIfNew();
                    //var store = (IUnlockedStateStore)filterContext.GetContextItem(UNLOCKED_STATE_STORE_KEY);
                    // store.UpdateContext();
                    var expire = UnlockedExtensions.GetNextTimeout(UnlockedStateStore.Configuration.SessionTimeout);
                    UnlockedStateStore.Set(UnlockedExtensions.UNLOCKED_STATE_STORE_KEY, UnlockedStateStore.Items, expire,
                                           RunAsync);
                }
            }
            base.OnResultExecuted(filterContext);
            //UnlockedStateStore.Dispose();
        }
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     if (UnlockedStateStoreConfiguration.Instance.Disabled)
     {
         return;
     }
     if (Usage != UnlockedStateUsage.Disabled)
     {
         // filterContext.StartSessionIfNew();
         if (UnlockedStateStore.Configuration.AutoManageSessionCookie)
         {
             UnlockedExtensions.StartSessionIfNewWithCustomCookie(UnlockedStateStore.Configuration.CookieName);
         }
         var session =
             (Dictionary <string, object>)
             UnlockedStateStore.Get(UnlockedExtensions.UNLOCKED_STATE_STORE_KEY, true, true,
                                    UnlockedStateStoreConfiguration.Instance.PreferSlaveForRead) ??
             new Dictionary <string, object>(UnlockedExtensions.DEFAULT_ITEM_COUNT);
         UnlockedStateStore.Items = session;
         //filterContext.SetContextItem(UnlockedExtensions.UNLOCKED_STATE_OBJECT_KEY, session);
         filterContext.SetContextItem(UnlockedExtensions.UNLOCKED_STATE_STORE_KEY, UnlockedStateStore);
     }
     base.OnActionExecuting(filterContext);
 }
Ejemplo n.º 4
0
        public void Abondon(bool async = false)
        {
            var prefix = UnlockedExtensions.GetSessionItemKey(string.Empty, configuration.CookieName);

            UnlockedExtensions.EndSessionWithCustomCookie(configuration.CookieName);
        }
Ejemplo n.º 5
0
        protected string GetSessionItemPrefix()
        {
            var prefix = UnlockedExtensions.GetSessionItemKey(string.Empty, configuration.CookieName);

            return(prefix);
        }
Ejemplo n.º 6
0
        protected string GetSessionItemKey(string keyName)
        {
            var redisKey = UnlockedExtensions.GetSessionItemKey(keyName, configuration.CookieName);

            return(redisKey);
        }