using System; using GameDB; using Sog; using ProtoCSStruct; namespace MysqlHandling { class Simulation { public GameDBOperator m_dbOperator = null; public int m_index; // 用来测试get性能的内存 private DBRoleBase m_RoleBase; private DBRoleData m_RoleData; private DBRoleUnimportanceData m_UnimportanceData; private string m_firebasePushId; public void DBinit(string dbName, string dbIp, string dbUser, string dbPassword, int dbtype, int index) { if(dbtype == 0) { m_dbOperator = new MysqlGameDBOperator(dbName, dbIp, dbUser, dbPassword); } else { m_dbOperator = new MongoGameDBOperator(dbName, dbIp, dbUser, dbPassword); } m_index = index; } public bool Insert(long uid, Role role) { //TraceLog.Debug("Simulation.Insert index {0} uid {1}", m_index, uid); role.m_RoleBase.Uid = uid; return m_dbOperator.InsertRole(1, ref role.m_RoleBase, ref role.m_RoleData, ref role.m_UnimportanceData); } public bool Get(long uid) { bool ret = m_dbOperator.QueryRole(uid, ref m_RoleBase, ref m_RoleData, ref m_UnimportanceData, out m_firebasePushId); TraceLog.Debug("Simulation.Get index {0} uid {1} ret {2}", m_index, uid, ret); return ret; } public bool UpdateBson(long uid, Role role) { //TraceLog.Debug("Simulation.Update index {0} uid {1}", m_index, uid); role.m_RoleBase.Uid = uid; return m_dbOperator.UpdateRole(ref role.m_RoleBase, ref role.m_RoleData, ref role.m_UnimportanceData); } public bool Delete(long uid) { m_dbOperator.DeleteRoleForDBTest(uid); return true; } } }