コード例 #1
0
ファイル: CompPersistence.cs プロジェクト: qiuhoude/mu_server
        public void SaveCompData(KFCompData compData, bool delay = true)
        {
            string sql = string.Format("INSERT INTO t_comp(`type`, boomval, enemytype, enemyset, `bulletin`, crystal, boss, crystal_yestd, boss_yestd, plunderres, plunderres_yestd, bosskilltype, bosskilltype_yestd, bossdamage, boomval_yestd, stronghold, mine, mine_rank) VALUES({0},{1},{2},{3},'{4}',{5},{6},{7},{8},'{9}','{10}',{11},{12},{13},{14},'{15}',{16},{17}) ON DUPLICATE KEY UPDATE boomval={1}, enemytype={2}, enemyset={3}, bulletin='{4}', crystal={5}, boss={6}, crystal_yestd={7}, boss_yestd={8},  plunderres='{9}', plunderres_yestd='{10}', bosskilltype={11}, bosskilltype_yestd={12}, bossdamage={13}, boomval_yestd={14}, stronghold='{15}', mine={16}, mine_rank={17};", new object[]
            {
                compData.CompType,
                compData.BoomValue,
                compData.EnemyCompType,
                compData.EnemyCompTypeSet,
                compData.Bulletin,
                compData.Crystal,
                compData.Boss,
                compData.YestdCrystal,
                compData.YestdBoss,
                compData.FormatPlunderResListString(compData.PlunderResList),
                compData.FormatPlunderResListString(compData.YestdPlunderResList),
                compData.BossKillCompType,
                compData.YestdBossKillCompType,
                compData.BossDamageTop,
                compData.YestdBoomValue,
                compData.FormatStrongholdDictString(compData.StrongholdDict),
                compData.MineRes,
                compData.MineRank
            });

            if (delay)
            {
                this.AddDelayWriteSql(sql);
            }
            else
            {
                this.ExecuteSqlNoQuery(sql);
            }
        }
コード例 #2
0
ファイル: CompPersistence.cs プロジェクト: qiuhoude/mu_server
        private bool LoadCompData(KuaFuData <Dictionary <int, KFCompData> > CompDataDict)
        {
            bool result;

            if (null == CompDataDict)
            {
                result = false;
            }
            else
            {
                try
                {
                    string          strSql = string.Format("SELECT * FROM `t_comp`", new object[0]);
                    MySqlDataReader sdr    = DbHelperMySQL.ExecuteReader(strSql, false);
                    while (sdr != null && sdr.Read())
                    {
                        KFCompData myCompData = new KFCompData();
                        myCompData.InitPlunderResList();
                        myCompData.CompType         = Convert.ToInt32(sdr["type"]);
                        myCompData.BoomValue        = Convert.ToInt32(sdr["boomval"]);
                        myCompData.YestdBoomValue   = Convert.ToInt32(sdr["boomval_yestd"]);
                        myCompData.EnemyCompType    = Convert.ToInt32(sdr["enemytype"]);
                        myCompData.EnemyCompTypeSet = Convert.ToInt32(sdr["enemyset"]);
                        myCompData.Bulletin         = sdr["bulletin"].ToString();
                        myCompData.Crystal          = Convert.ToInt32(sdr["crystal"]);
                        myCompData.BossDamageTop    = Convert.ToInt32(sdr["bossdamage"]);
                        myCompData.Boss             = Convert.ToInt32(sdr["boss"]);
                        myCompData.YestdCrystal     = Convert.ToInt32(sdr["crystal_yestd"]);
                        myCompData.YestdBoss        = Convert.ToInt32(sdr["boss_yestd"]);
                        myCompData.ParsePlunderResListString(sdr["plunderres"].ToString(), myCompData.PlunderResList);
                        myCompData.ParsePlunderResListString(sdr["plunderres_yestd"].ToString(), myCompData.YestdPlunderResList);
                        myCompData.ParseStrongholdDictString(sdr["stronghold"].ToString(), myCompData.StrongholdDict);
                        myCompData.BossKillCompType      = Convert.ToInt32(sdr["bosskilltype"]);
                        myCompData.YestdBossKillCompType = Convert.ToInt32(sdr["bosskilltype_yestd"]);
                        myCompData.MineRes  = Convert.ToInt32(sdr["mine"]);
                        myCompData.MineRank = Convert.ToInt32(sdr["mine_rank"]);
                        CompDataDict.V[myCompData.CompType] = myCompData;
                    }
                    TimeUtil.AgeByNow(ref CompDataDict.Age);
                    if (sdr != null)
                    {
                        sdr.Close();
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteExceptionUseCache(ex.ToString());
                    return(false);
                }
                result = true;
            }
            return(result);
        }