public static bool ReplaceBuyBoCai(BuyBoCai2SDB data) { int ret = -1; try { using (MyDbConnection3 conn = new MyDbConnection3(false)) { string sql = string.Format("REPLACE INTO t_bocai_buy_history(rid, RoleName, ZoneID, UserID, ServerID, BuyNum, BuyValue, IsSend, IsWin, BocaiType, DataPeriods, UpdateTime)VALUES({0},'{1}',{2},'{3}',{4}, {5},'{6}', {7}, {8}, {9}, {10}, '{11}');", new object[] { data.m_RoleID, data.m_RoleName, data.ZoneID, data.strUserID, data.ServerId, data.BuyNum, data.strBuyValue, data.IsSend, data.IsWin, data.BocaiType, data.DataPeriods, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); ret = conn.ExecuteNonQuery(sql, 0); } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } return(ret > -1); }
public static void SelectBuyBoCai(int bocaiType, long DataPeriods, out List <BuyBoCai2SDB> dList, bool isNoSend) { MySQLConnection conn = null; DBManager dbMgr = DBManager.getInstance(); dList = null; try { conn = dbMgr.DBConns.PopDBConnection(); string sql; if (isNoSend) { sql = string.Format("SELECT `rid`,`RoleName`,`ZoneID`,`UserID`,`ServerID`,`BuyNum`,`BuyValue`,`IsSend`,`IsWin` FROM t_bocai_buy_history WHERE `BocaiType`={0} AND `DataPeriods`={1} AND `IsSend`={2};", bocaiType, DataPeriods, 0); } else { sql = string.Format("SELECT `rid`,`RoleName`,`ZoneID`,`UserID`,`ServerID`,`BuyNum`,`BuyValue`,`IsSend`,`IsWin` FROM t_bocai_buy_history WHERE `BocaiType`={0} AND `DataPeriods`={1};", bocaiType, DataPeriods); } MySQLCommand cmd = new MySQLCommand(sql, conn); MySQLDataReader reader = cmd.ExecuteReaderEx(); dList = new List <BuyBoCai2SDB>(); while (reader.Read()) { BuyBoCai2SDB Item = new BuyBoCai2SDB { m_RoleName = reader["RoleName"].ToString(), strUserID = reader["UserID"].ToString(), strBuyValue = reader["BuyValue"].ToString(), m_RoleID = Convert.ToInt32(reader["rid"].ToString()), ZoneID = Convert.ToInt32(reader["ZoneID"].ToString()), ServerId = Convert.ToInt32(reader["ServerID"].ToString()), BuyNum = Convert.ToInt32(reader["BuyNum"].ToString()), IsSend = (Convert.ToInt32(reader["IsSend"].ToString()) > 0), IsWin = (Convert.ToInt32(reader["IsWin"].ToString()) > 0), BocaiType = bocaiType, DataPeriods = DataPeriods }; dList.Add(Item); } GameDBManager.SystemServerSQLEvents.AddEvent(string.Format("+SQL: {0}", sql), EventLevels.Important); cmd.Dispose(); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } finally { if (null != conn) { dbMgr.DBConns.PushDBConnection(conn); } } }
private void updateBuy(GameServerClient client, int nID, byte[] cmdParams, int count) { string msgStr = "false"; try { BuyBoCai2SDB Data = DataHelper.BytesToObject <BuyBoCai2SDB>(cmdParams, 0, count); msgStr = BoCaiDBOperator.ReplaceBuyBoCai(Data).ToString(); } catch (Exception ex) { LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true); } client.sendCmd(nID, msgStr); }