public int insertTradeFreqLog(DBManager dbMgr, string[] fields) { int ret = -1; MySQLConnection conn = null; try { string strTableName = "t_trademoney_freq_log"; int type = Convert.ToInt32(fields[0]); int count = Convert.ToInt32(fields[1]); long updatetTick = Convert.ToInt64(fields[2]); int serverID = Convert.ToInt32(fields[3]); string userID = fields[4]; int roleID = Convert.ToInt32(fields[5]); string roleName = fields[6]; int inputMoney = Convert.ToInt32(fields[7]); int usedMoney = Convert.ToInt32(fields[8]); int currMoney = Convert.ToInt32(fields[9]); int onlineSec = Convert.ToInt32(fields[10]); int level = Convert.ToInt32(fields[11]); long regTick = Convert.ToInt64(fields[12]); string ip = fields[13]; DateTime updateTime = new DateTime(updatetTick * 10000L); DateTime regTime = new DateTime(regTick * 10000L); conn = dbMgr.DBConns.PopDBConnection(); string cmdText = string.Format("INSERT INTO {0} (dayid, roleid, zoneid, userid, rname, type, count, updatetime, \r\n level, regtime, online_minute, inputmoney, usedmoney, currmoney, ip\r\n ) VALUES({1}, {2}, {3}, '{4}', '{5}', {6}, {7}, '{8}',\r\n {9}, '{10}', {11}, {12}, {13}, {14}, '{15}')", new object[] { strTableName, Global.GetOffsetDay(updateTime), roleID, serverID, userID, roleName, type, count, updateTime.ToString("yyyy-MM-dd HH:mm:ss"), level, regTime.ToString("yyyy-MM-dd HH:mm:ss"), onlineSec / 60, inputMoney, usedMoney, currMoney, ip }); MySQLCommand cmd = new MySQLCommand(cmdText, conn); try { ret = cmd.ExecuteNonQuery(); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("写入数据库失败: {0}", cmdText)); } cmd.Dispose(); cmd = null; } finally { if (null != conn) { dbMgr.DBConns.PushDBConnection(conn); } } return(ret); }
public int insertTradeNumLog(DBManager dbMgr, string[] fields) { int ret = -1; MySQLConnection conn = null; try { string strTableName = "t_trademoney_num_log"; int type = Convert.ToInt32(fields[0]); int money = Convert.ToInt32(fields[1]); long updatetTick = Convert.ToInt64(fields[2]); int serverID = Convert.ToInt32(fields[3]); string userID = fields[4]; int roleID = Convert.ToInt32(fields[5]); string roleName = fields[6]; int inputMoney = Convert.ToInt32(fields[7]); int usedMoney = Convert.ToInt32(fields[8]); int currMoney = Convert.ToInt32(fields[9]); int onlineSec = Convert.ToInt32(fields[10]); int level = Convert.ToInt32(fields[11]); long regTick = Convert.ToInt64(fields[12]); string ip = fields[13]; string userID2 = fields[14]; int roleID2 = Convert.ToInt32(fields[15]); string roleName2 = fields[16]; int inputMoney2 = Convert.ToInt32(fields[17]); int usedMoney2 = Convert.ToInt32(fields[18]); int currMoney2 = Convert.ToInt32(fields[19]); int onlineSec2 = Convert.ToInt32(fields[20]); int level2 = Convert.ToInt32(fields[21]); long regTick2 = Convert.ToInt64(fields[22]); string ip2 = fields[23]; DateTime updateTime = new DateTime(updatetTick * 10000L); conn = dbMgr.DBConns.PopDBConnection(); string cmdText = string.Format("INSERT INTO {0} (type, money, updatetime, zoneid, \r\n userid1, roleid1, rname1, inputmoney1, usedmoney1, currmoney1,online_minute1, ip1\r\n , userid2, roleid2, rname2, inputmoney2, usedmoney2, currmoney2, online_minute2, ip2) \r\n VALUES({1}, {2}, '{3}', {4},\r\n '{5}', {6}, '{7}', {8}, {9}, {10}, {11}, '{12}', \r\n '{13}', {14}, '{15}', {16}, {17}, {18}, {19}, '{20}')", new object[] { strTableName, type, money, updateTime.ToString("yyyy-MM-dd HH:mm:ss"), serverID, userID, roleID, roleName, inputMoney, usedMoney, currMoney, onlineSec / 60, ip, userID2, roleID2, roleName2, inputMoney2, usedMoney2, currMoney2, onlineSec2 / 60, ip2 }); MySQLCommand cmd = new MySQLCommand(cmdText, conn); try { ret = cmd.ExecuteNonQuery(); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("写入数据库失败: {0}", cmdText)); } cmd.Dispose(); cmd = null; } finally { if (null != conn) { dbMgr.DBConns.PushDBConnection(conn); } } return(ret); }
public int insertItemLog(DBManager dbMgr, string[] fields) { int ret = -1; MySQLConnection conn = null; try { string strTableName = "t_log_" + DateTime.Now.ToString("yyyyMMdd"); conn = dbMgr.DBConns.PopDBConnection(); this.ConformTableColumns(conn, strTableName); string cmdText; if (fields.Length >= 10 && !string.IsNullOrEmpty(fields[9])) { cmdText = string.Format("INSERT INTO {0} (DBId, ObjName, optFrom, currEnvName, tarEnvName, optType, optTime, optAmount, zoneID, optSurplus, extData) VALUES({1}, '{2}', '{3}', '{4}', '{5}', '{6}', now(), {7}, {8}, {9}, '{10}')", new object[] { strTableName, fields[0], fields[1], fields[2], fields[3], fields[4], fields[5], fields[6], fields[7], fields[8], fields[9] }); } else { cmdText = string.Format("INSERT INTO {0} (DBId, ObjName, optFrom, currEnvName, tarEnvName, optType, optTime, optAmount, zoneID, optSurplus, extData) VALUES({1}, '{2}', '{3}', '{4}', '{5}', '{6}', now(), {7}, {8}, {9}, NULL)", new object[] { strTableName, fields[0], fields[1], fields[2], fields[3], fields[4], fields[5], fields[6], fields[7], fields[8] }); } MySQLCommand cmd = new MySQLCommand(cmdText, conn); cmd = new MySQLCommand(cmdText, conn); try { ret = cmd.ExecuteNonQuery(); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("写入数据库失败: {0}", cmdText)); } cmd.Dispose(); cmd = null; } finally { if (null != conn) { dbMgr.DBConns.PushDBConnection(conn); } } return(ret); }