コード例 #1
0
        internal static async Task <NotificationAction> GetScheduledNotification()
        {
            var value = await CookieProperty.Get(COOKIE_KEY);

            if (value.IsEmpty())
            {
                return(null);
            }

            CookieProperty.Remove(COOKIE_KEY);

            return(JsonConvert.DeserializeObject <NotificationAction>(value));
        }
コード例 #2
0
        internal static NotificationAction GetScheduledNotification()
        {
            var value = CookieProperty.Get(COOKIE_KEY).GetAlreadyCompletedResult();

            if (value.IsEmpty())
            {
                return(null);
            }

            CookieProperty.Remove(COOKIE_KEY);

            return(JsonConvert.DeserializeObject <NotificationAction>(value));
        }
コード例 #3
0
        static Dictionary <string, string> ReadAllSortExpressionSettings()
        {
            var cookie = CookieProperty.Get(LIST_CONTAINERS_SORT_EXPRESSION_COOKIE_NAME);

            if (cookie.IsEmpty())
            {
                return(new Dictionary <string, string>());
            }

            var items    = cookie.Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries).Trim();
            var settings = items.Select(a => a.Split('=').Trim().ToArray()).Where(x => x.Length == 2).ToArray();

            return(settings.ToDictionary(a => a[0], a => a[1]));
        }
コード例 #4
0
        public IUser LoadUser(System.Security.Principal.IPrincipal principal)
        {
            var userId = ApplicationEventManager.GetCurrentUserId(principal);

            if (userId == null)
            {
                var cookieValue = CookieProperty.Get <string>(".ASPXAUTH", defaultValue: null);
                if (cookieValue.HasValue())
                {
                    userId = FormsAuthentication.Decrypt(cookieValue).Name;
                }
            }

            if (userId == null)
            {
                return(null);               // throw new Exception("There is no current user logged in.");
            }
            return(Database.Get <IUser>(userId));
        }
コード例 #5
0
        /// <summary>
        /// Removes the notification actions from the current set of specified actions, and schedules them in the next request through the cookie.
        /// </summary>
        internal static void ScheduleForNextRequest(List <object> actions)
        {
            var notificationActions = actions.OfType <NotificationAction>().ToList();

            if (notificationActions.None())
            {
                return;
            }

            notificationActions.Do(a => actions.Remove(a));

            var json = JsonConvert.SerializeObject(new NotificationAction
            {
                Notify   = notificationActions.Select(x => x.Notify).ToLinesString(),
                Obstruct = notificationActions.First().Obstruct,
                Style    = notificationActions.First().Style
            });

            CookieProperty.Set(COOKIE_KEY, json);
        }
コード例 #6
0
        internal void SetSortExpressionInCookie(string newSortExpression)
        {
            try
            {
                var items = ReadAllSortExpressionSettings();

                if (items.ContainsKey(SortExpressionKey))
                {
                    items.Remove(SortExpressionKey);
                }

                // Add it to the end of the list:
                items.Add(SortExpressionKey, newSortExpression);

                CookieProperty.Set(LIST_CONTAINERS_SORT_EXPRESSION_COOKIE_NAME, CreateNewCookieValue(items));
            }
            catch
            {
                // Problem with cookie. Ignore.
            }
        }
コード例 #7
0
 public static void SetOriginalUrl(string value) => CookieProperty.Set("Impersonation.Original.Url", value);
コード例 #8
0
 public static async Task <string> GetOriginalUrl() => (await CookieProperty.Get("Impersonation.Original.Url")).Or("~/");
コード例 #9
0
 static void SetImpersonationToken(string value) => CookieProperty.Set("Impersonation.Token", value);
コード例 #10
0
 public T Get <T>() => CookieProperty.Get <T>();