/// <summary>
        /// 加载邮件列表
        /// </summary>
        /// <param name="receiver_idx">收件人</param>
        /// <param name="callback"></param>
        public static void LoadMailList(long receiver_idx, ushort spid, DBID db_id, Action <List <MailInfo> > callback)
        {
            string sql = "call SP_MAIL_LIST(" + receiver_idx + ", " + spid + ", " + Time.second_time + ")";

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Query(sql, (reader) =>
            {
                List <MailInfo> list = new List <MailInfo>();
                while (reader.HasRows && reader.Read())
                {
                    int idx           = 0;
                    MailInfo data     = CommonObjectPools.Spawn <MailInfo>();
                    data.mail_idx     = reader.GetInt64(idx++);
                    data.mail_type    = (eMailType)reader.GetByte(idx++);
                    data.spid         = reader.GetUInt16(idx++);
                    data.receiver_idx = reader.GetInt64(idx++);
                    data.sender_idx   = reader.GetInt64(idx++);
                    data.sender_name  = reader.GetString(idx++);
                    data.send_time    = reader.GetInt64(idx++);
                    data.expire_time  = reader.GetInt32(idx++);
                    data.flags        = reader.GetUInt32(idx++);
                    data.subject      = reader.GetString(idx++);
                    //内容
                    long len     = reader.GetBytes(idx, 0, null, 0, int.MaxValue);
                    ByteArray by = DBUtils.AllocDBArray();
                    reader.GetBytes(idx, 0, by.Buffer, 0, (int)len);
                    by.WriteEmpty((int)len);//直接修改m_tail
                    data.bin_mail_content.Read(by);
                    list.Add(data);
                }
                callback(list);
            });
        }
Beispiel #2
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="info"></param>
        public static void SaveCharacterInfo(DBID db_id, PlayerInfoForSS info)
        {
            string sql = ("update `character` set " +
                          "`char_name` = '" + info.char_name + "'," + // 名字
                          "`char_type` = '" + info.char_type + "'," + // 角色类型(男 or 女 )
                          "`ws_id` = '" + info.ws_id + "'," +         //
                          "`ss_id` = '" + info.ss_id + "'," +         //
                          "`fs_id` = '" + info.fs_id + "'," +         //
                          "`pos_x` = '" + info.pos_x + "'," +         //
                          "`pos_y` = '" + info.pos_y + "'," +         //
                          "`scene_type_idx` = '" + info.scene_type_idx + "'," +
                          "`scene_obj_idx` = '" + info.scene_obj_idx + "'," +
                          "`flags` = '" + info.flags + "'," +         // 特殊标记
                          "`model_idx` = '" + info.model_idx + "'," + // 模型ID
                          "`job` = '" + info.job + "'," +             // 职业
                          "`level` = '" + info.level + "'," +         // 角色等级
                          "`exp` = '" + info.exp + "'," +             // 当前经验
                          "`energy` = '" + info.energy + "'," +       // 能量
                          "`gold` = '" + info.gold + "'," +           // 金币(点卷)
                          "`coin` = '" + info.coin + "'," +           // 游戏币(铜币)
                          "`hp` = '" + info.hp + "'," +               // 生命
                          "`hp_max` = '" + info.hp_max + "'," +       // 生命上限
                          "`hurt` = '" + info.hurt + "'," +           // 伤害
                          "`range` = '" + info.range + "'," +         // 攻击范围
                          "`run_speed` = '" + info.run_speed + "'," + // vip等级
                          "`vip_grade` = '" + info.vip_grade + "'," +
                          "`vip_flags` = '" + info.vip_flags + "'," + // vip flags
                          "`time_last_login` = '" + info.time_last_login + "'," +
                          "`time_last_logout` = '" + info.time_last_logout + "'," +
                          "`last_update_time` = now() where `character`.char_index=" + info.char_idx
                          );

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Execute(sql);
        }
 /// <summary>
 /// 批量删除事件
 /// </summary>
 public static void DeleteDBEvent(List <long> list, DBID db_id)
 {
     while (list.Count > 0)
     {
         int    del_count = 0;
         string sql       = "DELETE FROM game_event WHERE game_event.event_idx in( ";
         for (int i = list.Count - 1; i >= 0; i--, del_count++)
         {
             if (del_count != 0)
             {
                 sql += ",";
             }
             sql += list[i];
             list.RemoveAt(i);
             if (del_count >= 100)
             {
                 break;
             }
         }
         sql += ");";
         if (del_count > 0)
         {
             DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Execute(sql);
         }
     }
 }
        /// <summary>
        /// 查询信息
        /// </summary>
        public static void QueryDBEvent(long char_idx, DBID db_id, Action <List <DBEventInfo> > callback)
        {
            List <DBEventInfo> list = new List <DBEventInfo>();
            ByteArray          by   = DBUtils.AllocDBArray();
            string             sql  = "call SP_DB_EVENT_LOAD(" + char_idx + ")";

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Query(sql, (reader) =>
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        DBEventInfo info     = new DBEventInfo();
                        info.event_idx       = reader.GetInt64(0);
                        info.target_char_idx = reader.GetInt64(1);
                        info.source_char_idx = reader.GetInt64(2);
                        info.event_type      = (eDBEventType)reader.GetByte(3);
                        //内容
                        by.Clear();
                        long len = reader.GetBytes(4, 0, null, 0, int.MaxValue);
                        reader.GetBytes(4, 0, by.Buffer, 0, (int)len);
                        by.WriteEmpty((int)len);
                        info.bin_content.Read(by);

                        list.Add(info);
                    }
                }
                callback(list);
            });
        }
Beispiel #5
0
        /// <summary>
        /// 玩家所有物品
        /// </summary>
        public static void LoadItem(long char_idx, DBID db_id, Action <List <ItemInfo> > callback)
        {
            string sql = "call SP_ITEM_LIST(" + char_idx + ")";

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Query(sql, (reader) =>
            {
                List <ItemInfo> list = new List <ItemInfo>();
                while (reader.HasRows && reader.Read())
                {
                    int idx          = 0;
                    ItemInfo data    = CommonObjectPools.Spawn <ItemInfo>();
                    data.item_idx    = reader.GetInt64(idx++);
                    data.char_idx    = reader.GetInt64(idx++);
                    data.type        = (eItemSubType)reader.GetUInt32(idx++);
                    data.bag_type    = (eBagType)reader.GetUInt16(idx++);
                    data.ui_pos      = reader.GetUInt32(idx++);
                    data.number      = reader.GetUInt32(idx++);
                    data.create_time = reader.GetInt64(idx++);
                    //内容
                    long len     = reader.GetBytes(idx, 0, null, 0, int.MaxValue);
                    ByteArray by = DBUtils.AllocDBArray();
                    reader.GetBytes(idx, 0, by.Buffer, 0, (int)len);
                    by.WriteEmpty((int)len);
                    data.bin_content.Read(by);
                    list.Add(data);
                }
                callback(list);
            });
        }
        /// <summary>
        /// 创建邮件
        /// </summary>
        /// <param name="info"></param>
        /// <param name="callback"></param>
        public static void CreateMail(MailInfo info, DBID db_id)
        {
            string sql = "insert into `mail_box` " +
                         "(mail_type,spid,receiver_idx,sender_idx,sender_name,send_time,expire_time,delivery_time,flags,`subject`,bin_mail_content,last_update_time) " +
                         "values (" +
                         (byte)info.mail_type + "," +
                         info.spid + "," +
                         info.receiver_idx + "," +
                         info.sender_idx + ",'" +
                         info.sender_name + "'," +
                         info.send_time + "," +
                         info.expire_time + "," +
                         info.delivery_time + "," +
                         info.flags + ",'" +
                         info.subject + "'," +
                         "@bin_content,now())";

            ByteArray by = DBUtils.AllocDBArray();

            info.bin_mail_content.Write(by);
            List <MySqlParameter> param = new List <MySqlParameter>();
            MySqlParameter        p     = Database.MakeMysqlParam("@bin_content", MySqlDbType.Blob, by.GetBuffer(), by.Available);

            param.Add(p);
            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Execute(sql, param);
        }
Beispiel #7
0
        /// <summary>
        /// 进入游戏
        /// </summary>
        private void OnEnterGame(PacketBase packet)
        {
            gs2ss.EnterGame msg        = packet as gs2ss.EnterGame;
            ClientUID       client_uid = msg.client_uid;
            InterServerID   server_uid = msg.server_uid;

            UnitManager.Instance.AddSession(client_uid);

            if (!UnitManager.Instance.HasUnit(msg.char_idx))
            {
                DBID db_id = new DBID();
                db_id.game_id = ServerConfig.GetDBByAccountIdx(msg.account_idx, eDBType.Game);
                PlayerInfoForSS ss_data = CommonObjectPools.Spawn <PlayerInfoForSS>();
                SQLCharHandle.QueryCharacterInfo(msg.char_idx, db_id, ss_data, is_load =>
                {
                    if (is_load && UnitManager.Instance.HadSession(client_uid))
                    {//读取玩数据,有可能已经退出
                        //创建玩家
                        Player player     = new Player();
                        player.client_uid = client_uid;
                        player.LoadData(ss_data);
                        UnitManager.Instance.AddUnit(player);

                        //告诉gs成功进入游戏
                        ss2gs.EnterGame rep_gs_msg = PacketPools.Get(ss2gs.msg.ENTER_GAME) as ss2gs.EnterGame;
                        rep_gs_msg.server_uid      = server_uid;
                        rep_gs_msg.client_uid      = client_uid;
                        rep_gs_msg.char_idx        = ss_data.char_idx;
                        ServerNetManager.Instance.Send(server_uid.gs_uid, rep_gs_msg);

                        //告诉ws
                        ss2ws.LoginClient rep_ws_msg = PacketPools.Get(ss2ws.msg.LOGIN_CLIENT) as ss2ws.LoginClient;
                        rep_ws_msg.server_uid        = server_uid;
                        rep_ws_msg.client_uid        = client_uid;
                        rep_ws_msg.data.Copy(ss_data);
                        ServerNetManager.Instance.Send2WS(rep_ws_msg);

                        //告诉gl
                        ss2gl.LoginClient rep_gl_msg = PacketPools.Get(ss2gl.msg.LOGIN_CLIENT) as ss2gl.LoginClient;
                        rep_gl_msg.server_uid        = server_uid;
                        rep_gl_msg.data.Copy(ss_data);
                        ServerNetManager.Instance.Send2GL(rep_gl_msg);

                        //告诉客户端角色基础信息
                        ss2c.CharacterInfo rep_msg = PacketPools.Get(ss2c.msg.CHARACTER_INFO) as ss2c.CharacterInfo;
                        rep_msg.data.Copy(ss_data);
                        ServerNetManager.Instance.SendProxy(client_uid, rep_msg, false);

                        //初始化内部逻辑
                        player.OnFirstEnter();
                    }
                    CommonObjectPools.Despawn(ss_data);
                });
            }
        }
Beispiel #8
0
        private void QueryMaxCount(ushort game_db_id)
        {
            DBID db_id = new DBID();

            db_id.game_id = game_db_id;
            SQLCommonHandle.GetServerStartCount(db_id, max_id =>
            {
                if (max_id > m_server_start_count)
                {
                    m_server_start_count = max_id;
                }
            });
        }
        /// <summary>
        /// 修改或插入信息
        /// </summary>
        public static void UpdateCounter(long char_idx, DBID db_id, ByteArray by)
        {
            string sql = "replace into `character_counter`" +
                         "(`char_idx`,`bin_use_count`) " +
                         "values (" +
                         char_idx + "," +
                         "@bin_use_count)";

            List <MySqlParameter> param = new List <MySqlParameter>();
            MySqlParameter        p     = Database.MakeMysqlParam("@bin_use_count", MySqlDbType.Blob, by.GetBuffer(), by.Available);

            param.Add(p);
            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Execute(sql, param);
        }
Beispiel #10
0
        /// <summary>
        /// 服务器启动次数
        /// </summary>
        public static void GetServerStartCount(DBID db_id, Action <int> callback)
        {
            string sql = "call SP_SERVER_START_COUNT";

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).QuerySync(sql, (reader) =>
            {
                int count = 0;
                if (reader.HasRows && reader.Read())
                {
                    count = reader.GetInt32(0);
                }
                callback(count);
            });
        }
Beispiel #11
0
        /// <summary>
        /// 查询角色信息
        /// </summary>
        /// <param name="info"></param>
        /// <param name="callback"></param>
        public static void QueryCharacterInfo(long char_idx, DBID db_id, PlayerInfoForSS data, Action <bool> callback)
        {
            bool   ret = false;
            string sql = "call SP_CHARACTER_BASE(" + char_idx + ")";

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Query(sql, (reader) =>
            {
                if (reader.HasRows && reader.Read())
                {
                    int idx               = 0;
                    data.char_idx         = reader.GetInt64(idx++);
                    data.account_index    = reader.GetInt64(idx++);
                    data.spid             = reader.GetUInt16(idx++);
                    data.char_name        = reader.GetString(idx++);
                    data.char_type        = reader.GetByte(idx++);
                    data.ws_id            = reader.GetUInt16(idx++);
                    data.ss_id            = reader.GetUInt16(idx++);
                    data.fs_id            = reader.GetUInt16(idx++);
                    data.pos_x            = reader.GetInt32(idx++);
                    data.pos_y            = reader.GetInt32(idx++);
                    data.scene_type_idx   = reader.GetUInt32(idx++);
                    data.scene_obj_idx    = reader.GetInt64(idx++);
                    data.flags            = reader.GetUInt32(idx++);
                    data.model_idx        = reader.GetUInt32(idx++);
                    data.job              = reader.GetByte(idx++);
                    data.level            = reader.GetUInt16(idx++);
                    data.exp              = reader.GetUInt32(idx++);
                    data.energy           = reader.GetUInt32(idx++);
                    data.gold             = reader.GetUInt32(idx++);
                    data.coin             = reader.GetUInt32(idx++);
                    data.hp               = reader.GetUInt32(idx++);
                    data.hp_max           = reader.GetUInt32(idx++);
                    data.hurt             = reader.GetUInt32(idx++);
                    data.range            = reader.GetUInt32(idx++);
                    data.run_speed        = reader.GetUInt32(idx++);
                    data.vip_grade        = reader.GetUInt32(idx++);
                    data.vip_flags        = reader.GetUInt32(idx++);
                    data.time_last_login  = reader.GetInt64(idx++);
                    data.time_last_logout = reader.GetInt64(idx++);
                    ret = true;
                }
                else
                {
                    Log.Warning("查询角色失败:" + char_idx);
                }
                callback(ret);
            });
        }
        /// <summary>
        /// 修改已经领取过的邮件
        /// </summary>
        /// <param name="info"></param>
        /// <param name="callback"></param>
        public static void UpdateCharRecvs(long char_idx, MailCharRecvs info, DBID db_id)
        {
            string sql = "replace into `mail_char_recv`" +
                         "(`char_idx`,`bin_mails`) " +
                         "values (" +
                         char_idx + "," +
                         "@bin_mails)";

            ByteArray by = DBUtils.AllocDBArray();

            info.Write(by);
            List <MySqlParameter> param = new List <MySqlParameter>();
            MySqlParameter        p     = Database.MakeMysqlParam("@bin_mails", MySqlDbType.Blob, by.GetBuffer(), by.Available);

            param.Add(p);
            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Execute(sql, param);
        }
        private void QueryMaxCharIdx(ushort game_db_id)
        {
            DBID db_id = new DBID();

            db_id.game_id = game_db_id;
            SQLCharHandle.QueryMaxCharIdx(ServerConfig.net_info.server_realm, db_id, max_id =>
            {
                long next_char_idx = max_id;
                if (next_char_idx == 0)
                {//没有数据,则初始化起始值
                    next_char_idx = ServerConfig.net_info.server_realm;
                    next_char_idx = next_char_idx * GlobalID.INIT_CHAR_IDX;
                }
                m_max_char_idx.Add(game_db_id, next_char_idx);
                Log.Info("next_char_idx " + game_db_id + " :" + next_char_idx);
            });
        }
        /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~game~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
        /// <summary>
        /// 最大角色id
        /// </summary>
        /// <param name="callback"></param>
        public static void QueryMaxCharIdx(ushort ws_id, DBID db_id, Action <long> callback)
        {
            string sql    = "select count(*), max(char_index) from `character` where ws_id = " + ws_id;
            long   max_id = 0;//从这个开始

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Query(sql, (reader) =>
            {
                if (reader.HasRows && reader.Read())
                {
                    int count = reader.GetInt32(0);
                    if (count > 0)
                    {
                        max_id = reader.GetInt64(1);
                    }
                }
                callback(max_id);
            });
        }
        /// <summary>
        /// 添加事件
        /// </summary>
        public static void InsertDBEvent(DBEventInfo info, DBID db_id)
        {
            string sql = "call SP_DB_EVENT_CREATE(" +
                         info.target_char_idx + "," +
                         info.source_char_idx + "," +
                         (byte)info.event_type + "," +
                         "@i_bin_content);";

            ByteArray by = DBUtils.AllocDBArray();

            info.bin_content.Write(by);

            List <MySqlParameter> param = new List <MySqlParameter>();
            MySqlParameter        p     = Database.MakeMysqlParam("@i_bin_content", MySqlDbType.Blob, by.GetBuffer(), by.Available);

            param.Add(p);
            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Execute(sql, param);
        }
Beispiel #16
0
        /// <summary>
        /// 查询需要预加载的角色列表
        /// </summary>
        /// <param name="callback"></param>
        public static void QueryCharForPreload(uint load_max, DBID db_id, Action <List <long> > callback)
        {
            List <long> list = new List <long>();
            string      sql  = "call SP_CHARACTER_FOR_PRELOAD";

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Query(sql, (reader) =>
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        long char_idx = reader.GetInt64(0);
                        list.Add(char_idx);
                    }
                }
                callback(list);
            });
        }
        /// <summary>
        /// 查询信息
        /// </summary>
        public static void QueryCounterList(long char_idx, DBID db_id, Action <bool, ByteArray> callback)
        {
            bool      ret = false;
            ByteArray by  = DBUtils.AllocDBArray();
            string    sql = "call SP_COUNTER_LIST(" + char_idx + ")";

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Query(sql, (reader) =>
            {
                if (reader.HasRows && reader.Read())
                {
                    //内容
                    long len = reader.GetBytes(0, 0, null, 0, int.MaxValue);
                    reader.GetBytes(0, 0, by.Buffer, 0, (int)len);
                    by.WriteEmpty((int)len);
                    ret = true;
                }
                callback(ret, by);
            });
        }
Beispiel #18
0
        public void Start()
        {
            DataManager.Instance.LoadAll();
            DBManager.Instance.Start(ServerConfig.db_info.db_list);
            ServerNetManager.Instance.Connect2WorldServer(ServerConfig.net_info.ws_ip, ServerConfig.net_info.ws_port);

            DBID db_id = new DBID();

            db_id.game_id = 100;

            DBEventInfo e_info = new DBEventInfo();

            e_info.target_char_idx = 10000000002;
            e_info.source_char_idx = 10000000003;
            e_info.event_type      = eDBEventType.Test;
            e_info.bin_content.bin_normal_content.data = "测试了";
            SQLDBEventHandle.InsertDBEvent(e_info, db_id);

            Framework.Instance.MainLoop();
        }
        /// <summary>
        /// 加载玩家已经领取过的邮件列表
        /// </summary>
        /// <param name="char_idx">收件人</param>
        /// <param name="callback"></param>
        public static void LoadCharRecvs(long char_idx, DBID db_id, Action <MailCharRecvs> callback)
        {
            string sql = "call SP_MAIL_GET_CHAR_RECV(" + char_idx + ")";

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Query(sql, (reader) =>
            {
                MailCharRecvs info = new MailCharRecvs();
                if (reader.HasRows && reader.Read())
                {
                    long len = reader.GetBytes(0, 0, null, 0, int.MaxValue);
                    if (len > 0)
                    {
                        ByteArray by = DBUtils.AllocDBArray();
                        reader.GetBytes(0, 0, by.Buffer, 0, (int)len);
                        by.WriteEmpty((int)len);//直接修改m_tail
                        info.Read(by);
                    }
                }
                callback(info);
            });
        }
Beispiel #20
0
        /// <summary>
        /// 创建物品
        /// </summary>
        public static void CreateItem(ItemInfo info, DBID db_id)
        {
            string sql = "insert into `character_all_item` " +
                         "(item_idx, char_idx,type,bag_type,ui_pos,number,create_time,bin_content) " +
                         "values (" +
                         info.item_idx + "," +
                         info.char_idx + "," +
                         (uint)info.type + "," +
                         (ushort)info.bag_type + "," +
                         info.ui_pos + "," +
                         info.number + "," +
                         info.create_time + "," +
                         "@bin_content)";

            ByteArray by = DBUtils.AllocDBArray();

            info.bin_content.Write(by);
            List <MySqlParameter> param = new List <MySqlParameter>();
            MySqlParameter        p     = Database.MakeMysqlParam("@bin_content", MySqlDbType.Blob, by.GetBuffer(), by.Available);

            param.Add(p);
            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Execute(sql, param);
        }
Beispiel #21
0
        /// <summary>
        /// 角色列表
        /// </summary>
        /// <param name="username">登录用户名</param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public static void QueryCharacterList(long account_idx, DBID db_id, Action <List <CharacterLogin> > callback)
        {
            string sql = "call SP_CHARACTER_ENUM(" + account_idx + ")";

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Query(sql, (reader) =>
            {
                List <CharacterLogin> list = new List <CharacterLogin>();
                if (reader.HasRows && reader.Read())
                {
                    int idx             = 0;
                    CharacterLogin data = new CharacterLogin();
                    data.char_idx       = reader.GetInt64(idx++);
                    data.char_name      = reader.GetString(idx++);
                    data.char_type      = reader.GetByte(idx++);
                    data.level          = reader.GetUInt16(idx++);
                    data.wid            = reader.GetUInt16(idx++);
                    data.sid            = reader.GetUInt16(idx++);
                    data.dbid           = reader.GetUInt16(idx++);
                    list.Add(data);
                }
                callback(list);
            });
        }
        /// <summary>
        /// 创号
        /// </summary>
        /// <param name="info"></param>
        /// <param name="callback"></param>
        public static void CreateCharacter(long account_idx, DBID db_id, CreateCharacterInfo info, Action <long> callback)
        {
            string sql = "call SP_CHARACTER_CREATE("
                         + 1 + ","
                         + info.char_idx + ","
                         + account_idx + ","
                         + info.spid + ",'"
                         + info.char_name + "',"
                         + info.char_type + ","
                         + info.ws_id + ","
                         + info.ss_id + ","
                         + info.fs_id
                         + ")";

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Query(sql, (reader) =>
            {
                long result = 0;
                if (reader.HasRows && reader.Read())
                {
                    result = reader.GetInt64(0);
                }
                callback(result);
            });
        }
Beispiel #23
0
        /// <summary>
        /// 查询角色信息
        /// </summary>
        public static void QueryCharacterInfoByName(string char_name, DBID db_id, Action <bool, PlayerInfoByName> callback)
        {
            bool             ret  = false;
            PlayerInfoByName data = new PlayerInfoByName();
            string           sql  = "call SP_CHARACTER_ENUM_BY_NAME('" + char_name + "')";

            DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Query(sql, (reader) =>
            {
                if (reader.HasRows && reader.Read())
                {
                    int idx        = 0;
                    data.char_idx  = reader.GetInt64(idx++);
                    data.char_name = reader.GetString(idx++);
                    data.char_type = reader.GetByte(idx++);
                    data.level     = reader.GetUInt16(idx++);
                    ret            = true;
                }
                else
                {
                    Log.Debug("根据名称查询角色失败:" + char_name);
                }
                callback(ret, data);
            });
        }
 /// <summary>
 /// 修改邮件标记:支持同时修改多行
 /// </summary>
 /// <param name="flags"></param>
 public static void ModifyMailFlags(Dictionary <long, MailInfo> all_mails, List <long> list, DBID db_id)
 {
     while (list.Count > 0)
     {
         int    update_count = 0;
         string sql          = "UPDATE mail_box SET flags = CASE mail_idx ";
         string sql_end      = "";
         for (int i = list.Count - 1; i >= 0; i--, update_count++)
         {
             long     mail_idx = list[i];
             MailInfo mail_info;
             if (all_mails.TryGetValue(mail_idx, out mail_info))
             {
                 sql = sql + " WHEN " + mail_idx + " THEN " + mail_info.flags;
                 if (update_count != 0)
                 {
                     sql_end += ", ";
                 }
                 sql_end += mail_idx.ToString();
                 list.RemoveAt(i);
                 if (update_count >= 10)
                 {
                     break;
                 }
             }
         }
         sql = sql + " END WHERE mail_idx in(" + sql_end + ");";
         if (update_count > 0)
         {
             DBManager.Instance.GetDB(eDBType.Game, db_id.game_id).Execute(sql);
         }
     }
 }