Exemplo n.º 1
0
        private void Verificate_Wifi()
        {
            //int userId = GetInt("uid");
            int    sellerId  = GetInt("sellerid");
            string pwd       = GetString("pwd");
            var    user_wifi = new UserWifi()
            {
                Pwd      = pwd,
                SellerId = sellerId
            };
            var          item = GeneralHelper.GetUserWifiItem(pwd, sellerId);
            JsonTransfer jt   = new JsonTransfer();

            if (item != null)
            {
                var data = new
                {
                    expir = item.Expiry.GetUnixTime()
                };

                jt.AddSuccessParam();
                jt.Add("data", data);
            }
            else
            {
                jt.Add("status", 0);
                jt.Add("message", "密码错误");
            }

            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
Exemplo n.º 2
0
        public static UserWifi GetUserWifiItem(int userId, int sellerId)
        {
            UserWifi uw                      = null;
            string   commandText             = @"select * from userwifi where userId = ?userId and sellerId = ?sellerId";
            List <MySqlParameter> parameters = new List <MySqlParameter>();

            parameters.Add(new MySqlParameter("?userId", userId));
            parameters.Add(new MySqlParameter("?sellerId", sellerId));
            try
            {
                using (var conn = Utility.ObtainConn(Utility._gameDbConn))
                {
                    //MySqlDataReader reader = MySqlHelper.ExecuteReader(GlobalConfig.DbConn, CommandType.Text, commandText, parameters.ToArray());
                    MySqlDataReader reader = MySqlHelper.ExecuteReader(conn, CommandType.Text, commandText, parameters.ToArray());
                    while (reader.Read())
                    {
                        uw          = new UserWifi();
                        uw.Id       = reader.GetInt32(0);
                        uw.SellerId = (int)reader["SellerId"];
                        uw.Pwd      = reader["Pwd"].ToString();
                        uw.UserId   = (int)reader["UserId"];
                        uw.Expiry   = (DateTime)reader["Expiry"];
                    }
                }
            }
            catch (System.Exception ex)
            {
                throw;
            }
            return(uw);
        }
Exemplo n.º 3
0
        internal static void GenerateWifi(UserWifi user_wifi)
        {
            string connectionString = GlobalConfig.DbConn;

            string commandText = @"INSERT INTO userwifi 
	                                ( 
	                                SellerId, 
	                                Pwd,
	                                UserId,
                                    Expiry
	                                )
	                                VALUES
	                                ( 
	                                ?SellerId, 
	                                ?Pwd,
	                                ?UserId,
                                    ?Expiry
	                                )"    ;


            List <MySqlParameter> parameters = new List <MySqlParameter>();

            parameters.Add(new MySqlParameter("?SellerId", user_wifi.SellerId));
            parameters.Add(new MySqlParameter("?Pwd", user_wifi.Pwd));
            parameters.Add(new MySqlParameter("?UserId", user_wifi.UserId));
            parameters.Add(new MySqlParameter("?Expiry", user_wifi.Expiry));


            MySqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, commandText, parameters.ToArray());
        }
Exemplo n.º 4
0
        internal static void UpdateWifi(UserWifi user_wifi)
        {
            string commandText = @"UPDATE userwifi SET
                                        SellerId = ?SellerId,
                                        Pwd = ?Pwd,
                                        UserId = ?UserId,
                                        Expiry = ?Expiry
                                    WHERE
                                        Id = ?Id";

            List <MySqlParameter> parameters = new List <MySqlParameter>();

            parameters.Add(new MySqlParameter("?Id", user_wifi.Id));
            parameters.Add(new MySqlParameter("?SellerId", user_wifi.SellerId));
            parameters.Add(new MySqlParameter("?Pwd", user_wifi.Pwd));
            parameters.Add(new MySqlParameter("?UserId", user_wifi.UserId));
            parameters.Add(new MySqlParameter("?Expiry", user_wifi.Expiry));

            MySqlHelper.ExecuteNonQuery(GlobalConfig.DbConn, CommandType.Text, commandText, parameters.ToArray());
        }
Exemplo n.º 5
0
        private void Generate_Wifi()
        {
            int userId    = GetInt("uid");
            int sellerId  = GetInt("sellerid");
            var random    = new Random();
            var pwd       = random.Next(100000, 999999).ToString();
            var user_wifi = new UserWifi()
            {
                Pwd      = pwd,
                SellerId = sellerId,
                UserId   = userId,
                Expiry   = DateTime.Now.AddDays(1)
            };
            var item = GeneralHelper.GetUserWifiItem(userId, sellerId);

            if (item == null)
            {
                GeneralHelper.GenerateWifi(user_wifi);
            }
            else
            {
                user_wifi.Id = item.Id;
                GeneralHelper.UpdateWifi(user_wifi);
            }

            var data = new
            {
                pwd   = user_wifi.Pwd,
                expir = user_wifi.Expiry.GetUnixTime()
            };

            //JsonTransfer jt = new JsonTransfer();
            //jt.AddSuccessParam();
            //Response.Write(DesEncrypt(jt).ToLower());
            //Response.End();
            //返回信息
            ReturnCorrectData(data);
        }