Beispiel #1
0
        public LadderRefreshExchangeResponse RefreshExchange(Guid managerId)
        {
            var entity = GetLadderManager(managerId);

            entity.RefreshTimes++;
            var mallDirect = new MallDirectFrame(managerId, EnumConsumeSourceType.RefreshLadderExchange,
                                                 entity.RefreshTimes);
            var checkCode = mallDirect.Check();

            if (checkCode != MessageCode.Success)
            {
                return(ResponseHelper.Create <LadderRefreshExchangeResponse>(checkCode));
            }
            var equipmentProperties = "";
            var equipmentItemcode   = "";

            entity.ExchangeIds         = CacheFactory.LadderCache.GetExchanges(out equipmentItemcode, out equipmentProperties);
            entity.ExchangedIds        = "";
            entity.EquipmentProperties = equipmentProperties;
            entity.EquipmentItems      = equipmentItemcode;
            using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
            {
                transactionManager.BeginTransaction();
                checkCode = mallDirect.Save(Guid.NewGuid().ToString(), transactionManager.TransactionObject);
                if (checkCode != MessageCode.Success)
                {
                    transactionManager.Rollback();
                    return(ResponseHelper.Create <LadderRefreshExchangeResponse>(checkCode));
                }
                if (!LadderManagerMgr.Update(entity, transactionManager.TransactionObject))
                {
                    transactionManager.Rollback();
                    return(ResponseHelper.Create <LadderRefreshExchangeResponse>(MessageCode.NbUpdateFail));
                }
                transactionManager.Commit();
            }
            var response = ResponseHelper.CreateSuccess <LadderRefreshExchangeResponse>();

            response.Data              = new LadderRefreshExchangeEntity();
            response.Data.ExchangeIds  = entity.ExchangeIds;
            response.Data.ManagerPoint = mallDirect.RemainPoint;
            response.Data.RefreshPoint =
                CacheFactory.MallCache.GetDirectPoint(EnumConsumeSourceType.RefreshLadderExchange,
                                                      entity.RefreshTimes + 1);
            response.Data.Honor = entity.Honor;
            if (DateTime.Now.Hour >= 21)
            {
                response.Data.ExchangeRefreshTick = ShareUtil.GetTimeTick(DateTime.Today.AddDays(1).AddHours(21));
            }
            else
            {
                response.Data.ExchangeRefreshTick = ShareUtil.GetTimeTick(DateTime.Today.AddHours(21));
            }

            response.Data.AllEquipmentProperties =
                CacheFactory.LadderCache.AnalysisProperties(entity.EquipmentProperties);
            response.Data.LadderCoin = entity.LadderCoin;
            return(response);
        }
Beispiel #2
0
 MessageCode Tran_SaveExchange(DbTransaction transaction, LadderManagerEntity ladderManager, ItemPackageFrame package, LadderExchangerecordEntity ladderExchangerecord)
 {
     if (!LadderManagerMgr.Update(ladderManager, transaction))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!package.Save(transaction))
     {
         return(MessageCode.NbUpdateFail);
     }
     if (!LadderExchangerecordMgr.Insert(ladderExchangerecord, transaction))
     {
         return(MessageCode.NbUpdateFail);
     }
     return(MessageCode.Success);
 }
Beispiel #3
0
        public LadderManagerResponse GetManagerInfo(Guid managerId)
        {
            var manager = GetLadderManager(managerId);

            if (string.IsNullOrEmpty(manager.ExchangeIds) || CheckExchangeRefresh(manager.RefreshDate))
            {
                var equipmentProperties = "";
                var equipmentItemcode   = "";
                manager.ExchangeIds         = CacheFactory.LadderCache.GetExchanges(out equipmentItemcode, out equipmentProperties);
                manager.RefreshDate         = DateTime.Today.AddHours(21);//每天21点刷新
                manager.RefreshTimes        = 0;
                manager.ExchangedIds        = "";
                manager.EquipmentProperties = equipmentProperties;
                manager.EquipmentItems      = equipmentItemcode;
                LadderManagerMgr.Update(manager);
            }
            var season = CacheFactory.SeasonCache.GetCurrentSeason();

            season.StartTick = ShareUtil.GetTimeTick(season.Startdate);
            season.EndTick   = ShareUtil.GetTimeTick(season.Enddate.Date.AddDays(1).AddSeconds(-1));
            season.NowTick   = ShareUtil.GetTimeTick(DateTime.Now);
            var response = ResponseHelper.CreateSuccess <LadderManagerResponse>();

            response.Data        = manager;
            response.Data.Season = season;
            if (DateTime.Now.Hour >= 21)
            {
                response.Data.ExchangeRefreshTick =
                    ShareUtil.GetTimeTick(DateTime.Today.AddDays(1).AddHours(21));
            }
            else
            {
                response.Data.ExchangeRefreshTick =
                    ShareUtil.GetTimeTick(DateTime.Today.AddHours(21));
            }
            var rankEntity = RankLadderThread.Instance.GetMyRank(managerId, (int)EnumRankType.LadderRank);

            if (rankEntity != null)
            {
                response.Data.MyRank        = rankEntity.Rank;
                response.Data.YesterdayRank = rankEntity.YesterdayRank;
            }
            else
            {
                response.Data.MyRank        = -1;
                response.Data.YesterdayRank = -1;
            }
            response.Data.WinRate      = ManagerUtil.GetWinRate(managerId, EnumMatchType.Ladder);
            response.Data.RefreshPoint =
                CacheFactory.MallCache.GetDirectPoint(EnumConsumeSourceType.RefreshLadderExchange, manager.RefreshTimes + 1);
            response.Data.AllEquipmentProperties =
                CacheFactory.LeagueCache.AnalysisProperties(manager.EquipmentProperties);
            if (LadderCore.Instance._ManagerMatchCD.ContainsKey(managerId))
            {
                response.Data.CDTick = ShareUtil.GetTimeTick(_ManagerMatchCD[managerId]);
            }
            else
            {
                response.Data.CDTick = ShareUtil.GetTimeTick(DateTime.Now);
            }
            return(response);
        }