Ejemplo n.º 1
0
        protected void LoadFilterFromCookies()
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[COOKIE_FILTER_NAME];

            if (cookie == null)
            {
                return;
            }
            string str = cookie.Value;

            byte[]          byteState = System.Convert.FromBase64CharArray(str.ToCharArray(), 0, str.Length);
            MemoryStream    ms        = new MemoryStream(byteState);
            BinaryFormatter bf1       = new BinaryFormatter();

            this.Filter = (MainMonitorFilter)bf1.Deserialize(ms);
        }
Ejemplo n.º 2
0
        protected void SaveFilterToCookies()
        {
            MainMonitorFilter filter = new MainMonitorFilter();

            filter.Categories    = SessionManager.CurrentCategories;
            filter.Shops         = SessionManager.CurrentChannels;
            filter.ChannelType   = rblShopTypes.SelectedIndex;
            filter.Condition     = cbConditions.SelectedIndex;
            filter.PriceType     = rblPriceTypes.SelectedIndex;
            filter.ProductFilter = txtProduct.Text;
            filter.PageSize      = cbPageSize.SelectedIndex;
            MemoryStream    ms  = new MemoryStream();
            BinaryFormatter bf1 = new BinaryFormatter();

            bf1.Serialize(ms, filter);
            string     str   = System.Convert.ToBase64String(ms.ToArray());
            HttpCookie value = new HttpCookie(COOKIE_FILTER_NAME);

            value.Value   = str;
            value.Expires = DateTime.Now.AddDays(90);
            HttpContext.Current.Response.Cookies.Add(value);
        }