Example #1
0
        public static void UpdateRankingAwardCache()
        {
            var       gameCache  = new ShareCacheStruct <GameCache>();
            GameCache levelCache = gameCache.FindKey(LevelRankingAwardCacheKey);

            levelCache.Value = MathUtils.ToJson(LevelRankingAwardCacheList);

            GameCache fightValueCache = gameCache.FindKey(FightValueRankingAwardCacheKey);

            fightValueCache.Value = MathUtils.ToJson(FightValueRankingAwardCacheList);

            GameCache comboCache = gameCache.FindKey(ComboRankingAwardCacheKey);

            comboCache.Value = MathUtils.ToJson(ComboRankingAwardCacheList);
        }
Example #2
0
        public static void InitData()
        {
            VitInit                   = ConfigEnvSet.GetInt("User.VitInit");
            VitMax                    = ConfigEnvSet.GetInt("User.VitMax");
            VitRestore                = ConfigEnvSet.GetInt("User.VitRestore");
            CombatLogCountMax         = ConfigEnvSet.GetInt("User.CombatLogCountMax");
            FriendCountMax            = ConfigEnvSet.GetInt("User.FriendCountMax");
            FriendApplyCountMax       = ConfigEnvSet.GetInt("User.FriendApplyCountMax");
            FriendGiveAwayCountMax    = ConfigEnvSet.GetInt("User.FriendGiveAwayCountMax");
            FriendGiveAwayVitValue    = ConfigEnvSet.GetInt("User.FriendGiveAwayVitValue");
            RepairSignNeedDiamond     = ConfigEnvSet.GetInt("User.RepairSignNeedDiamond");
            MaxMailNum                = ConfigEnvSet.GetInt("User.MaxMailNum");
            OpenTaskSystemUserLevel   = ConfigEnvSet.GetInt("System.OpenTaskSystemUserLevel");
            OpenRankSystemUserLevel   = ConfigEnvSet.GetInt("System.OpenRankSystemLevel");
            InviteFightAwardGold      = ConfigEnvSet.GetInt("User.InviteFightAwardGold");
            InviteFightDiamondWeekMax = ConfigEnvSet.GetInt("User.InviteFightDiamondWeekMax");



            var guildlist = new ShareCacheStruct <GuildsCache>().FindAll();

            foreach (var v in guildlist)
            {
                v.Lv = v.ConvertLevel();
            }
            var gameCache = new ShareCacheStruct <GameCache>();

            GameCache openServiceCache = gameCache.FindKey(OpenServiceDataCacheKey);

            if (openServiceCache == null)
            {
                openServiceCache       = new GameCache();
                openServiceCache.Key   = OpenServiceDataCacheKey;
                openServiceCache.Value = DateTime.Now.ToString();
                gameCache.Add(openServiceCache);
                gameCache.Update();

                IsFirstOpenService = true;
            }
            OpenServiceDate = openServiceCache.Value.ToDateTime();
            OpenServiceDate = new DateTime(OpenServiceDate.Year, 8 /*OpenServiceDate.Month*/, 1, 9, 0, 0);

            //GameCache signStartIDCache = gameCache.FindKey(SignStartIDCacheKey);
            //if (signStartIDCache == null)
            //{
            //    signStartIDCache = new GameCache();
            //    signStartIDCache.Key = SignStartIDCacheKey;
            //    signStartIDCache.Value = "1";
            //    gameCache.Add(signStartIDCache);
            //    gameCache.Update();
            //}
            //SignStartID = signStartIDCache.Value.ToInt();
            SignStartID = GetSignStartID();


            // 加载老用户记录
            var cacheSet = new MemoryCacheStruct <OldUserCache>();

            var    dbProvider = DbConnectionProvider.CreateDbProvider(DbConfig.Log);
            string sql        = "SELECT OpenID,NickName,AvatarUrl,CreateDate FROM OldUserLog";

            using (IDataReader reader = dbProvider.ExecuteReader(CommandType.Text, sql))
            {
                while (reader.Read())
                {
                    OldUserCache olduser = new OldUserCache();
                    olduser.OpenID     = reader["OpenID"].ToString();
                    olduser.NickName   = reader["NickName"].ToString();
                    olduser.AvatarUrl  = reader["AvatarUrl"].ToString();
                    olduser.CreateDate = reader["CreateDate"].ToDateTime();
                    cacheSet.TryAdd(olduser.OpenID, olduser);
                }
            }


            // 排行榜奖励数据
            GameCache levelCache = gameCache.FindKey(LevelRankingAwardCacheKey);

            if (levelCache == null)
            {
                levelCache       = new GameCache();
                levelCache.Key   = LevelRankingAwardCacheKey;
                levelCache.Value = MathUtils.ToJson(LevelRankingAwardCacheList);
                gameCache.Add(levelCache);
                gameCache.Update();
            }
            LevelRankingAwardCacheList = MathUtils.ParseJson <CacheList <UserRankAward> >(levelCache.Value);

            GameCache fightValueCache = gameCache.FindKey(FightValueRankingAwardCacheKey);

            if (fightValueCache == null)
            {
                fightValueCache       = new GameCache();
                fightValueCache.Key   = FightValueRankingAwardCacheKey;
                fightValueCache.Value = MathUtils.ToJson(FightValueRankingAwardCacheList);
                gameCache.Add(fightValueCache);
                gameCache.Update();
            }
            FightValueRankingAwardCacheList = MathUtils.ParseJson <CacheList <UserRankAward> >(fightValueCache.Value);

            GameCache comboCache = gameCache.FindKey(ComboRankingAwardCacheKey);

            if (comboCache == null)
            {
                comboCache       = new GameCache();
                comboCache.Key   = ComboRankingAwardCacheKey;
                comboCache.Value = MathUtils.ToJson(ComboRankingAwardCacheList);
                gameCache.Add(comboCache);
                gameCache.Update();
            }
            ComboRankingAwardCacheList = MathUtils.ParseJson <CacheList <UserRankAward> >(comboCache.Value);
        }