internal static void PutDataToSession <T>(SessionKeys key, T data)
 {
     if (HttpContext.get_Current() != null && HttpContext.get_Current().get_Session() != null)
     {
         HttpContext.get_Current().get_Session().set_Item(key.ToString(), data);
     }
 }
 internal static void RemoveDataFromSession(params SessionKeys[] keys)
 {
     if (HttpContext.get_Current() != null && HttpContext.get_Current().get_Session() != null)
     {
         SessionKeys[] sessionKeysArray = keys;
         for (int i = 0; i < (int)sessionKeysArray.Length; i++)
         {
             SessionKeys sessionKey = sessionKeysArray[i];
             HttpContext.get_Current().get_Session().Remove(sessionKey.ToString());
         }
     }
 }
Example #3
0
        /// <summary>
        /// セッション情報の保存
        /// </summary>
        /// <param name="uniqueSessionKey">ユニークセッションキー</param>
        /// <param name="sessionKey">セッションキー</param>
        /// <param name="tempDataModel">一時データ</param>
        protected void SaveSession(string uniqueSessionKey, SessionKeys sessionKey, object tempDataModel)
        {
            string sessionKeyText = sessionKey.ToString();

            if (!(Session[sessionKeyText] is Dictionary <string, object> sessionMap))
            {
                sessionMap = new Dictionary <string, object>();
            }

            sessionMap[uniqueSessionKey] = tempDataModel;

            Session[sessionKeyText] = sessionMap;
        }
 internal static bool GetDataFromSession <T>(SessionKeys key, out T data)
 {
     if (HttpContext.get_Current() != null && HttpContext.get_Current().get_Session() != null)
     {
         object item = HttpContext.get_Current().get_Session().get_Item(key.ToString());
         if (item is T)
         {
             data = (T)item;
             return(true);
         }
     }
     data = default(T);
     return(false);
 }
Example #5
0
        /// <summary>
        /// セッション情報の保存
        /// </summary>
        /// <param name="vm">ビューモデル</param>
        /// <param name="sessionKey">セッションキー</param>
        /// <param name="tempDataModel">一時データ</param>
        protected void SaveSession(ViewModelBase vm, SessionKeys sessionKey, object tempDataModel)
        {
            if (string.IsNullOrEmpty(vm.UniqueSessionKey))
            {
                vm.UniqueSessionKey = Guid.NewGuid().ToString("N");
            }

            string sessionKeyText = sessionKey.ToString();

            if (!(Session[sessionKeyText] is Dictionary <string, object> sessionMap))
            {
                sessionMap = new Dictionary <string, object>();
            }

            sessionMap[vm.UniqueSessionKey] = tempDataModel;

            Session[sessionKeyText] = sessionMap;
        }
Example #6
0
 protected void Put <T>(SessionKeys sessionKey, T item)
 {
     HttpContext.Current.Session.Add(sessionKey.ToString(), item);
 }
Example #7
0
 protected T Get <T>(SessionKeys sessionKey)
 {
     return((T)HttpContext.Current.Session[sessionKey.ToString()]);
 }