public static int updateWanMoTaData(DBManager dbMgr, int nRoleID, string[] fields, int startIndex) { int ret = -1; using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText = DBWriter.FormatUpdateSQL(nRoleID, fields, startIndex, WanMoTaDBController._fieldNames, "t_wanmota", WanMoTaDBController._fieldTypes, "roleID"); ret = conn.ExecuteNonQuery(cmdText, 0); } return(ret); }
public static bool UpdateMerlinData(DBManager dbMgr, int nRoleID, string[] fields, int nStartIndex) { bool result; if (fields == null || fields.Length != 15 || nStartIndex >= fields.Length) { result = false; } else { bool ret = false; MySQLConnection conn = null; try { conn = dbMgr.DBConns.PopDBConnection(); if (fields[6] != "*") { string endTime = new DateTime(Convert.ToInt64(fields[6]) * 10000L).ToString("yyyy-MM-dd HH:mm:ss"); fields[6] = endTime; } for (int i = 7; i <= 14; i++) { if (fields[i] != "*") { fields[i] = (Convert.ToDouble(fields[i]) * 100.0).ToString(); } } string cmdText = DBWriter.FormatUpdateSQL(nRoleID, fields, nStartIndex, MerlinDBOperate.t_fieldNames, "t_merlin_magic_book", MerlinDBOperate.t_fieldTypes, "roleID"); GameDBManager.SystemServerSQLEvents.AddEvent(string.Format("+SQL: {0}", cmdText), EventLevels.Important); MySQLCommand cmd = new MySQLCommand(cmdText, conn); try { cmd.ExecuteNonQuery(); ret = true; } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("写入数据库失败: {0}", cmdText), null, true); } cmd.Dispose(); cmd = null; } finally { if (null != conn) { dbMgr.DBConns.PushDBConnection(conn); } } result = ret; } return(result); }
/// <summary> /// 更新万魔塔场数据 /// </summary> /// <param name="data"></param> /// <returns></returns> public static int updateWanMoTaData(DBManager dbMgr, int nRoleID, string[] fields, int startIndex) { int ret = -1; MySQLConnection conn = null; string[] fieldNames = { "flushTime", "passLayerCount", "sweepLayer", "sweepReward", "sweepBeginTime" }; byte[] fieldTypes = { 0, 0, 0, 1, 0 }; try { conn = dbMgr.DBConns.PopDBConnection(); string cmdText = DBWriter.FormatUpdateSQL(nRoleID, fields, startIndex, fieldNames, "t_wanmota", fieldTypes, "roleID"); GameDBManager.SystemServerSQLEvents.AddEvent(string.Format("+SQL: {0}", cmdText), EventLevels.Important); MySQLCommand cmd = new MySQLCommand(cmdText, conn); try { cmd.ExecuteNonQuery(); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("写入数据库失败: {0}", cmdText)); } cmd.Dispose(); cmd = null; ret = 0; } finally { if (null != conn) { dbMgr.DBConns.PushDBConnection(conn); } } return(ret); }