Exemple #1
0
        /// <summary>
        /// 设置排名信息
        /// </summary>
        /// <returns></returns>
        public MessageCode SetRank()
        {
            if (IsActivity)//有活动才更新排名
            {
                PenaltykickManagerMgr.SetRank();
                //return MessageCode.NbUpdateFail;
            }
            var rankList = PenaltykickManagerMgr.GetRank();
            var dic      = new ConcurrentDictionary <Guid, PenaltyKickRankEntity>();

            foreach (var item in rankList)
            {
                if (!dic.ContainsKey(item.ManagerId))
                {
                    dic.TryAdd(item.ManagerId, item);
                }
            }
            _rankDic = dic;
            return(MessageCode.Success);
        }
Exemple #2
0
        private MessageCode SendPrize(PenaltykickSeasonEntity seasonInfo)
        {
            if (seasonInfo.Idx == 0)
            {
                return(MessageCode.Success);
            }
            PenaltykickManagerMgr.SetRank();
            var prizeList = PenaltykickManagerMgr.GetNotPrize(seasonInfo.Idx);

            seasonInfo.IsPrize   = true;
            seasonInfo.PrizeTime = DateTime.Now;
            foreach (var item in prizeList)
            {
                if (item.IsPrize || item.TotalScore < 500)
                {
                    continue;
                }
                item.IsPrize = true;
                //排名奖励
                var prize = CacheFactory.AdCache.GetPrize(3, item.Rank);
                if (prize == null || prize.Count == 0)
                {
                    continue;
                }
                //邮件
                var mail = new MailBuilder(item.Rank, item.ManagerId);
                foreach (var p in prize)
                {
                    switch (p.ItemType)
                    {
                    case 3:    //暂时只有物品奖励
                        mail.AddAttachment(p.ItemCount, p.ItemCode, false, 1);
                        break;

                    case 10:    //金条
                        mail.AddAttachment(EnumCurrencyType.GoldBar, p.ItemCount);
                        break;
                    }
                }
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    var messageCode = MessageCode.NbUpdateFail;
                    do
                    {
                        if (!PenaltykickManagerMgr.Update(item, transactionManager.TransactionObject))
                        {
                            break;
                        }
                        if (!mail.Save(transactionManager.TransactionObject))
                        {
                            break;
                        }
                        messageCode = MessageCode.Success;
                    } while (false);
                    if (messageCode != MessageCode.Success)
                    {
                        transactionManager.Rollback();
                    }
                    transactionManager.Commit();
                }
            }
            PenaltykickSeasonMgr.Update(seasonInfo);
            return(MessageCode.Success);
        }