예제 #1
0
        /// <summary>
        /// 从数据库恢复到缓存
        /// </summary>
        public static void TryRecoverFromDb()
        {
            var cache  = new ShareCacheStruct <tb_gamelevelinfo>();
            var filter = new DbDataFilter();

            cache.TryRecoverFromDb(filter);
        }
예제 #2
0
        /// <summary>
        /// 获取我的战绩列表
        /// </summary>
        /// <returns></returns>
        public static List <CombatGainInfoSD> GetCombatGainList(int _userid)
        {
            List <CombatGainInfoSD> _CombatGainList = new List <CombatGainInfoSD>();
            //取指定userid最近一天的一次房间结算OVER的记录
            var          cacheSettable = new ShareCacheStruct <tb_TableMoneyLog>();
            var          cacheRank     = new GameDataCacheSet <tb_Rank>();
            DbDataFilter filter1       = new DbDataFilter();

            cacheRank.TryRecoverFromDb(filter1);
            tb_Rank rank = cacheRank.FindKey(_userid.ToString());

            if (rank == null || !rank.records.Any())
            {
                return(_CombatGainList);
            }
            List <Record> records = rank.records.OrderByDescending(w => w.CreateDate).Take(10).ToList();

            foreach (var record in records)
            {
                CombatGainInfoSD _tempGain = new CombatGainInfoSD();
                _tempGain.tablenum     = record.MatchCode;
                _tempGain._starttime   = record.CreateDate.ToString("yyyy-MM-dd HH:mm:ss");
                _tempGain._tableRecord = new List <CombatTableRecordSD>();
                //找到同桌的人
                var          cacheSettable2 = new ShareCacheStruct <tb_TableMoneyLog>();
                DbDataFilter filter         = new DbDataFilter();
                filter.Condition = "MatchCode=@MatchCode";
                filter.Parameters.Add("MatchCode", record.MatchCode);
                cacheSettable2.TryRecoverFromDb(filter);
                List <tb_TableMoneyLog> tablemoneylog2list = cacheSettable2.FindAll((r) => { return(r.MatchCode == record.MatchCode && r._isover); });

                if (tablemoneylog2list.Any())
                {
                    foreach (var moneylog2 in tablemoneylog2list)
                    {
                        CombatTableRecordSD _combatTable = new CombatTableRecordSD();
                        _combatTable.userid     = moneylog2.UserID;
                        _combatTable._username  = tb_UserEx.GetUserNameByUserID(moneylog2.UserID);
                        _combatTable._winorlost = (int)moneylog2.AddorReduceMoney;
                        _tempGain._tableRecord.Add(_combatTable);
                    }
                }
                _CombatGainList.Add(_tempGain);
                //_lastCount++;
                //if (_lastCount >= 10) break;//暂时只取10条
            }

            return(_CombatGainList);
        }
예제 #3
0
        static void doFrom_UserRanking(object parm)
        {
            ZyGames.Framework.Model.SchemaTable schema = ZyGames.Framework.Model.EntitySchemaSet.Get <UserRanking>();
            int max = int.Parse(parm as string);

            ConsoleLog.showNotifyInfo("########" + typeof(UserRanking).ToString() + "######## From Start:" + max);
            int Step  = 1000;
            var cache = new ShareCacheStruct <UserRanking>();

            for (int i = 0; i < max; i += Step)
            {
                var filter = new ZyGames.Framework.Net.DbDataFilter(0);
                filter.Condition = "where UserID>=@Key1 and UserID<@Key2";
                filter.Parameters.Add("Key1", i);
                filter.Parameters.Add("Key2", i + Step);
                cache.TryRecoverFromDb(filter);
                ConsoleLog.showNotifyInfo("UserRanking:    " + i + "     load");
            }
            ConsoleLog.showNotifyInfo("########" + typeof(UserRanking).ToString() + "######## From End");
        }
예제 #4
0
        public static tb_Notice GetLastNotice()
        {
            var notice        = new tb_Notice();
            var cacheSettable = new ShareCacheStruct <tb_Notice>();

            cacheSettable.ReLoad();

            notice = cacheSettable.Find(w => w.isStart == 1);
            if (notice == null)
            {
                SchemaTable    schema   = EntitySchemaSet.Get <tb_Notice>();
                DbBaseProvider provider = DbConnectionProvider.CreateDbProvider(schema);
                DbDataFilter   filter   = new DbDataFilter(0);
                filter.Condition = provider.FormatFilterParam("isStart");
                filter.Parameters.Add("isStart", 1);
                cacheSettable.TryRecoverFromDb(filter);//从数据库中恢复数据
                notice = cacheSettable.Find(w => w.isStart == 1);
            }
            return(notice);
        }
예제 #5
0
        static void doFrom_Model_share <T>(object parm, string key = "UserID") where T : ShareEntity, new()
        {
            string typeName = typeof(T).ToString();

            ZyGames.Framework.Model.SchemaTable schema = ZyGames.Framework.Model.EntitySchemaSet.Get <T>();
            int max = int.Parse(parm as string);

            ConsoleLog.showNotifyInfo("########" + typeName + "######## From Start:" + max);
            int Step  = 1000;
            var cache = new ShareCacheStruct <T>();

            for (int i = 0; i < max; i += Step)
            {
                var filter = new ZyGames.Framework.Net.DbDataFilter(0);
                filter.Condition = "where " + key + " >=@Key1 and " + key + " <@Key2";
                filter.Parameters.Add("Key1", i);
                filter.Parameters.Add("Key2", i + Step);
                cache.TryRecoverFromDb(filter);
                ConsoleLog.showNotifyInfo(typeName + ":" + i + " load");
            }
            ConsoleLog.showNotifyInfo("########" + typeName + "######## From End");
        }
예제 #6
0
 void LoadAuthoFromDb()
 {
     var cache = new ShareCacheStruct<Authority>();
     cache.TryRecoverFromDb(new ZyGames.Framework.Net.DbDataFilter(0));
 }
예제 #7
0
        public override bool TakeAction()
        {
            var iemiCache = new ShareCacheStruct <IemiEntity>();


            var cache = new PersonalCacheStruct <GameUser>();


            var entity = iemiCache.FindKey(_pid);

            if (entity == null)
            {
                var filter = new DbDataFilter();
                filter.Condition = "IEMI = @IEMI";
                filter.Parameters.Add("IEMI", _pid);
                iemiCache.TryRecoverFromDb(filter, _pid);

                entity = iemiCache.FindKey(_pid);
            }

            if (entity == null)
            {
                Console.WriteLine("1004-------------IemiEntity Is Null");

                entity      = new IemiEntity();
                entity.IEMI = _pid;

                _user = new GameUser()
                {
                    UserId    = (int)cache.GetNextNo(),
                    IEMI      = _pid,
                    Searching = false,
                    RivalId   = -1
                };

                entity.UserId = _user.UserId;


                iemiCache.AddOrUpdate(entity);

                cache.AddOrUpdate(_user);

                Current.Bind(_user);
            }
            else
            {
                int userId = entity.UserId;

                _user = cache.FindKey(userId.ToString());

                if (_user == null)
                {
                    var filter = new DbDataFilter();
                    filter.Condition = "UserId = @UserId";
                    filter.Parameters.Add("UserId", userId);
                    var ii = cache.TryRecoverFromDb(filter, userId.ToString());

                    Console.WriteLine(string.Format("1004-------------UserId:{0},IEMI:{1}", userId, entity.IEMI));
                }

                if (cache.TryFindKey(entity.UserId.ToString(), out _user, entity.UserId.ToString()) == ZyGames.Framework.Model.LoadingStatus.Success)
                {
                    Current.Bind(_user);
                }
                else
                {
                }
            }


            return(true);
        }
예제 #8
0
        void LoadAuthoFromDb()
        {
            var cache = new ShareCacheStruct <Authority>();

            cache.TryRecoverFromDb(new ZyGames.Framework.Net.DbDataFilter(0));
        }
예제 #9
0
        /// <summary>
        ///    一桌完统计数据
        /// </summary>
        /// <param name="guid">桌号</param>
        /// <param name="gameover">是否结束了</param>
        /// <param name="numpertable">一桌有多少人</param>
        public static void SetRateDataByTableNum(string _guid, bool gameover, int numpertable)
        {
            _pos2Rate1 = new List <CommonPosValSD>();
            _pos2Rate2 = new List <CommonPosValSD>();
            _pos2Rate3 = new List <CommonPosValSD>();
            _pos2Rate4 = new List <CommonPosValSD>();
            if (!gameover)
            {
                return;
            }
            var cacheSet = new ShareCacheStruct <tb_TableMoneyLog>();
            //if (cacheSet.Count == 0)
            //{
            DbDataFilter filter = new DbDataFilter();

            filter.Condition = "_guid = @guid";
            filter.Parameters.Add("guid", _guid);
            cacheSet.TryRecoverFromDb(filter);
            //}
            List <tb_TableMoneyLog> _tmList = cacheSet.FindAll();

            if (_tmList == null || !_tmList.Any())
            {
                return;
            }
            for (int _pos = 1; _pos <= numpertable; _pos++)
            {
                var _moneylist1 = _tmList.FindAll((money) => { return(money._pos == _pos && money._bullrate == 1); });
                if (_moneylist1.Count != 0)
                {
                    _pos2Rate1.Add(new CommonPosValSD()
                    {
                        pos = _pos, val = _moneylist1.Count
                    });
                }

                var _moneylist2 = _tmList.FindAll((money) => { return(money._pos == _pos && money._bullrate == 2); });
                if (_moneylist2.Count != 0)
                {
                    _pos2Rate2.Add(new CommonPosValSD()
                    {
                        pos = _pos, val = _moneylist2.Count
                    });
                }

                var _moneylist3 = _tmList.FindAll((money) => { return(money._pos == _pos && money._bullrate == 3); });
                if (_moneylist3.Count != 0)
                {
                    _pos2Rate3.Add(new CommonPosValSD()
                    {
                        pos = _pos, val = _moneylist3.Count
                    });
                }

                var _moneylist4 = _tmList.FindAll((money) => { return(money._pos == _pos && money._bullrate == 4); });
                if (_moneylist4.Count != 0)
                {
                    _pos2Rate4.Add(new CommonPosValSD()
                    {
                        pos = _pos, val = _moneylist4.Count
                    });
                }
            }

            //写入排行信息
            _tmList = cacheSet.FindAll((t_user) => { return(t_user._guid == _guid && t_user._isover); });
            foreach (tb_TableMoneyLog moneylog in _tmList)
            {
                var          cacheSetRank = new GameDataCacheSet <tb_Rank>();
                DbDataFilter filter1      = new DbDataFilter();
                //filter1.Condition = "UserId=@UserId";
                //filter.Parameters.Add("UserId", moneylog.UserID);

                var userRank = new tb_Rank();
                userRank = cacheSetRank.FindKey(moneylog.UserID.ToString());
                if (userRank == null)
                {
                    cacheSetRank.TryRecoverFromDb(filter1);
                    tb_Rank rank = new tb_Rank()
                    {
                        UserID = moneylog.UserID
                    };
                    if (moneylog._win)
                    {
                        rank.ScoreWin++;
                    }
                    else
                    {
                        rank.ScoreLost++;
                    }
                    rank.records.Add(new Record()
                    {
                        ItemId = cacheSetRank.GetNextNo(), MatchCode = moneylog.MatchCode, Money = moneylog.AddorReduceMoney
                    });
                    cacheSetRank.Add(rank);
                }
                else
                {
                    userRank = cacheSetRank.FindKey(moneylog.UserID.ToString());
                    userRank.ModifyLocked(() => {
                        if (moneylog._win)
                        {
                            userRank.ScoreWin++;
                        }
                        else
                        {
                            userRank.ScoreLost++;
                        }
                        if (userRank.records == null)
                        {
                            userRank.records = new CacheList <Record>();
                        }
                        userRank.records.Add(new Record()
                        {
                            ItemId = cacheSetRank.GetNextNo(), MatchCode = moneylog.MatchCode, Money = moneylog.AddorReduceMoney
                        });
                        cacheSetRank.Update();
                    });
                }
                // if(userRank.)
                //tb_Rank _temprank = cacheSetRank.Find((rank) => { return rank.UserID == moneylog.UserID; });
                //if (_temprank == null)
                //{
                //    _temprank = new tb_Rank();
                //    _temprank.UserID = moneylog.UserID;
                //    _temprank.ScoreLost = 0;
                //    _temprank.ScoreWin = 0;
                //}
                //_temprank.CreateDate = DateTime.Now;
                //if (moneylog._win) _temprank.ScoreWin++;
                //else _temprank.ScoreLost++;
                //cacheSetRank.AddOrUpdate(_temprank);
            }
        }