Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Response.End();
            base.Response.End();
            ITransaction transaction = CallBLL.redisHelper.CreateTransaction();

            CallBLL.redisHelper.GetDatabase().CreateBatch(null).Execute();
            List <string> stringKeysByPattern      = CallBLL.redisHelper.GetStringKeysByPattern("*online*");
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Add("A1", "A11111");
            dictionary.Add("B1", "B11111");
            CallBLL.redisHelper.StringSet("DictTest:dict", JsonHandle.ObjectToJson(dictionary), FileCacheHelper.get_RedisExpiryDay());
            RedisDemoObject obj2 = new RedisDemoObject {
                Id   = 1,
                Name = "123"
            };

            CallBLL.redisHelper.StringSet <RedisDemoObject>("test1:RedisDemoObject", obj2, FileCacheHelper.get_RedisExpiryDay());
            RedisDemoObject obj3 = CallBLL.redisHelper.StringGet <RedisDemoObject>("test1:RedisDemoObject");
            string          str  = "select * from cz_stat_online";
            Dictionary <string, cz_stat_online> dictionary2 = new Dictionary <string, cz_stat_online>();
            DataTable table = DbHelperSQL.Query(str, null).Tables[0];

            foreach (DataRow row in table.Rows)
            {
                cz_stat_online _online = new cz_stat_online();
                _online.set_id(int.Parse(row["id"].ToString()));
                _online.set_u_name(row["u_name"].ToString());
                _online.set_u_type(row["u_type"].ToString());
                _online.set_u_flag(row["u_flag"].ToString());
                _online.set_first_time(new DateTime?(DateTime.Parse(row["first_time"].ToString())));
                _online.set_last_time(new DateTime?(DateTime.Parse(row["last_time"].ToString())));
                _online.set_ip(row["ip"].ToString());
                _online.set_is_out(new int?(int.Parse(row["is_out"].ToString())));
                CallBLL.redisHelper.HashSet <cz_stat_online>("useronline:list", _online.get_u_name(), _online);
            }
            long           num      = CallBLL.redisHelper.HashLength("useronline:list");
            cz_stat_online _online2 = CallBLL.redisHelper.HashGet <cz_stat_online>("useronline:list", "yt668833");
            cz_stat_online _online3 = new cz_stat_online();

            _online3.set_u_name("fgs_1111111111111111111111");
            if (CallBLL.redisHelper.HashExists("useronline:list", "fgs_1111111111111111111111"))
            {
                CallBLL.redisHelper.HashDelete("list", "useronlinefgs_1111111111111111111111");
            }
            _online3.set_u_flag("zj");
            CallBLL.redisHelper.HashSet <cz_stat_online>("useronline:list", _online3.get_u_name(), _online3);
            List <cz_stat_online> list2 = CallBLL.redisHelper.HashValues <cz_stat_online>("useronline:list");
            bool flag2 = transaction.Execute(0);
        }
Example #2
0
        public void MemberPageBase_Load(object sender, EventArgs e)
        {
            DateTime       now;
            cz_stat_online _online;
            cz_stat_online _online2;

            if (HttpContext.Current.Session["user_name"] == null)
            {
                HttpContext.Current.Response.Write("<script>top.location.href='/'</script>");
                HttpContext.Current.Response.End();
            }
            string str = this.get_children_name();

            if (FileCacheHelper.get_RedisStatOnline().Equals(1))
            {
                if (HttpContext.Current.Request.Path.ToLower().IndexOf("resetpasswd.aspx") > 0)
                {
                    now     = DateTime.Now;
                    _online = new cz_stat_online();
                    _online.set_u_name((str == "") ? HttpContext.Current.Session["user_name"].ToString() : str);
                    _online.set_is_out(0);
                    _online.set_u_type(HttpContext.Current.Session["user_type"].ToString());
                    _online.set_ip(LSRequest.GetIP());
                    _online.set_first_time(new DateTime?(now));
                    _online.set_last_time(new DateTime?(now));
//                    CallBLL.redisHelper.HashGet<cz_stat_online>("useronline:list", (str == "") ? HttpContext.Current.Session["user_name"].ToString() : str, _online);
                }
//                if (CallBLL.redisHelper.HashExists("useronline:list", (str == "") ? HttpContext.Current.Session["user_name"].ToString() : str))
//                {
//                    _online2 = CallBLL.redisHelper.HashGet<cz_stat_online>("useronline:list", (str == "") ? HttpContext.Current.Session["user_name"].ToString() : str);
//                    if ((_online2 != null) && _online2.get_is_out().Equals(1))
//                    {
//                        HttpContext.Current.Session.Abandon();
//                        HttpContext.Current.Response.Write("<script>top.location.href='/'</script>");
//                        HttpContext.Current.Response.End();
//                    }
//                }
                if (PageBase.IsNeedPopBrower((str == "") ? HttpContext.Current.Session["user_name"].ToString() : str))
                {
                    HttpContext.Current.Session.Abandon();
                    HttpContext.Current.Response.Write("<script>top.location.href='/'</script>");
                    HttpContext.Current.Response.End();
                }
            }
            else if (FileCacheHelper.get_RedisStatOnline().Equals(2))
            {
                RedisClient client;
                if (HttpContext.Current.Request.Path.ToLower().IndexOf("resetpasswd.aspx") > 0)
                {
                    now     = DateTime.Now;
                    _online = new cz_stat_online();
                    _online.set_u_name((str == "") ? HttpContext.Current.Session["user_name"].ToString() : str);
                    _online.set_is_out(0);
                    _online.set_u_type(HttpContext.Current.Session["user_type"].ToString());
                    _online.set_ip(LSRequest.GetIP());
                    _online.set_first_time(new DateTime?(now));
                    _online.set_last_time(new DateTime?(now));
                    using (client = new RedisClient(RedisConnectSplit.get_RedisIP(), RedisConnectSplit.get_RedisPort(), RedisConnectSplit.get_RedisPassword(), (long)FileCacheHelper.get_GetRedisDBIndex()))
                    {
                        client.ConnectTimeout = int.Parse(RedisConnectSplit.get_RedisConnectTimeout());
                        client.SetEntryInHash("useronline:list", (str == "") ? HttpContext.Current.Session["user_name"].ToString() : str, JsonHandle.ObjectToJson(_online));
                    }
                }
                using (client = new RedisClient(RedisConnectSplit.get_RedisIP(), RedisConnectSplit.get_RedisPort(), RedisConnectSplit.get_RedisPassword(), (long)FileCacheHelper.get_GetRedisDBIndex()))
                {
                    client.ConnectTimeout = int.Parse(RedisConnectSplit.get_RedisConnectTimeout());
                    if (client.HashContainsEntry("useronline:list", (str == "") ? HttpContext.Current.Session["user_name"].ToString() : str))
                    {
                        _online2 = JsonHandle.JsonToObject <cz_stat_online>(client.GetValueFromHash("useronline:list", (str == "") ? HttpContext.Current.Session["user_name"].ToString() : str)) as cz_stat_online;
                        if ((_online2 != null) && _online2.get_is_out().Equals(1))
                        {
                            HttpContext.Current.Session.Abandon();
                            HttpContext.Current.Response.Write("<script>top.location.href='/'</script>");
                            HttpContext.Current.Response.End();
                        }
                    }
                }
                if (PageBase.IsNeedPopBrower((str == "") ? HttpContext.Current.Session["user_name"].ToString() : str))
                {
                    HttpContext.Current.Session.Abandon();
                    HttpContext.Current.Response.Write("<script>top.location.href='/'</script>");
                    HttpContext.Current.Response.End();
                }
            }
            else if (base.IsUserOut((str == "") ? HttpContext.Current.Session["user_name"].ToString() : str) || PageBase.IsNeedPopBrower((str == "") ? HttpContext.Current.Session["user_name"].ToString() : str))
            {
                HttpContext.Current.Session.Abandon();
                HttpContext.Current.Response.Write("<script>top.location.href='/'</script>");
                HttpContext.Current.Response.End();
            }
            string str3 = HttpContext.Current.Session["user_name"].ToString();

            this.UserCurrentSkin = (HttpContext.Current.Session[str3 + "lottery_session_user_info"] as agent_userinfo_session).get_u_skin();
            this.ForcedModifyPassword();
            this.AgentCurrentLottery();
            this.RedirectReport();
            this.IsOpenLottery();
            if (((((HttpContext.Current.Request.Path.ToLower().IndexOf("fgs_list") > -1) || (HttpContext.Current.Request.Path.ToLower().IndexOf("gd_list") > -1)) || ((HttpContext.Current.Request.Path.ToLower().IndexOf("zd_list") > -1) || (HttpContext.Current.Request.Path.ToLower().IndexOf("dl_list") > -1))) || ((HttpContext.Current.Request.Path.ToLower().IndexOf("hy_list") > -1) || (HttpContext.Current.Request.Path.ToLower().IndexOf("child_list") > -1))) || (HttpContext.Current.Request.Path.ToLower().IndexOf("filluser_list") > -1))
            {
                CookieHelper.SetCookie("userreturnbackurl", HttpContext.Current.Request.ServerVariables["Path_Info"] + "?" + HttpContext.Current.Request.ServerVariables["Query_String"]);
            }
        }