Exemplo n.º 1
0
        /// <summary>
        /// 创建帐号
        /// </summary>
        /// <param name="account">帐号</param>
        /// <param name="password">密码</param>
        public void Create(string account, string password)
        {
            AccountModle accountModle = new AccountModle(ID.Add_Get(), account, password);

            accDic.Add(account, accountModle);
            MysqlPeer.Instance.AddAccount(accountModle);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取在线玩家的ID
        /// </summary>
        /// <param name="clientPeer">客户端连接对象</param>
        /// <returns></returns>
        public int GetOnlineID(ClientPeer clientPeer)
        {
            string       account      = Client_accDic[clientPeer];
            AccountModle accountModle = accDic[account];

            return(accountModle.ID);
        }
Exemplo n.º 3
0
        public AccountModle GetAccountModleByAcc(string account)
        {
            if (IsAccontExist(account) && OpenConnection())
            {
                string       query        = string.Format("select * from account where account = '{0}';", account);
                AccountModle accountModle = null;

                MySqlCommand    sqlCommand      = new MySqlCommand(query, SqlConnection);
                MySqlDataReader mySqlDataReader = sqlCommand.ExecuteReader();


                while (mySqlDataReader.Read())
                {
                    int    id  = AccountCache.Instance.ID.Add_Get();
                    string pwd = mySqlDataReader["password"] + "";
                    accountModle = new AccountModle(id, account, pwd);
                }

                mySqlDataReader.Close();
                CloseConnection();

                return(accountModle);
            }
            return(null);
            //throw new Exception("该帐号的数据在数据库中不存在GetAccountModleByAcc()");
        }
Exemplo n.º 4
0
 /// <summary>
 /// 判断帐号是否已经存在
 /// </summary>
 public bool IsExist(string account)
 {
     if (!accDic.ContainsKey(account))
     {
         AccountModle accountModle = MysqlPeer.Instance.GetAccountModleByAcc(account);
         if (accountModle != null)
         {
             accDic.Add(account, accountModle);
         }
     }
     return(accDic.ContainsKey(account));
 }
Exemplo n.º 5
0
        /// <summary>
        /// 增加账号数据
        /// </summary>
        /// <param name="data"></param>
        public void AddAccount(AccountModle accountModle)
        {
            string query = string.Format("insert into account (account,password) values('{0}','{1}');", accountModle.Account, accountModle.PassWord);

            if (this.OpenConnection())
            {
                //如果数据库打开成功
                MySqlCommand sqlCommand = new MySqlCommand(query, SqlConnection);

                sqlCommand.ExecuteNonQuery();

                CloseConnection();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 判断帐号密码是否匹配
        /// </summary>
        /// <param name="account"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool isMatch(string account, string password)
        {
            AccountModle accountModle = accDic[account];

            return(accountModle.PassWord == password);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取在线玩家的ID
        /// </summary>
        /// <param name="account">在线玩家帐号</param>
        /// <returns></returns>
        public int GetOnlineID(string account)
        {
            AccountModle accountModle = accDic[account];

            return(accountModle.ID);
        }