コード例 #1
0
        public void OnUserDoSomething(int roleID, RankType rankType, int value)
        {
            DBManager dbMgr = DBManager.getInstance();

            if (null != dbMgr)
            {
                DBRoleInfo roleInfo = dbMgr.GetDBRoleInfo(ref roleID);
                if (null != roleInfo)
                {
                    double currSecond = Global.GetOffsetSecond(DateTime.Now);
                    roleInfo.RankValue.AddUserRankValue(rankType, value);
                    lock (this.RankDataDictLock)
                    {
                        foreach (KeyValuePair <string, RankData> item in this.RankDataDict)
                        {
                            RankDataKey rankDataKey = RankDataKey.GetKeyFromStr(item.Key);
                            if (null != rankDataKey)
                            {
                                if (rankType == rankDataKey.rankType)
                                {
                                    double startTime = Global.GetOffsetSecond(DateTime.Parse(rankDataKey.StartDate));
                                    double endTime   = Global.GetOffsetSecond(DateTime.Parse(rankDataKey.EndDate));
                                    if (currSecond >= startTime && currSecond <= endTime)
                                    {
                                        bool bExist = false;
                                        foreach (InputKingPaiHangData rankData in item.Value.RankDataList)
                                        {
                                            if ((RankType.Charge == rankType && rankData.UserID == roleInfo.UserID) || (RankType.Consume == rankType && rankData.UserID == roleInfo.RoleID.ToString()))
                                            {
                                                rankData.PaiHangTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                                                rankData.PaiHangValue += value;
                                                bExist = true;
                                                break;
                                            }
                                        }
                                        if (!bExist)
                                        {
                                            int userRankValue           = roleInfo.RankValue.GetRankValue(rankDataKey);
                                            InputKingPaiHangData phData = new InputKingPaiHangData
                                            {
                                                UserID       = ((RankType.Charge == rankType) ? roleInfo.UserID : roleInfo.RoleID.ToString()),
                                                PaiHang      = 0,
                                                PaiHangTime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                                                PaiHangValue = userRankValue
                                            };
                                            item.Value.RankDataList.Add(phData);
                                        }
                                        this.BuildRank(item.Value);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        public int AddUserRankValue(RankType ActType, int addValue)
        {
            double currSecond = Global.GetOffsetSecond(DateTime.Now);

            lock (UserRankValueCache.UserRankValueDictLock)
            {
                foreach (KeyValuePair <string, UserRankValue> item in this.DictUserRankValue)
                {
                    RankDataKey key = RankDataKey.GetKeyFromStr(item.Key.ToString());
                    if (null != key)
                    {
                        double startTime = Global.GetOffsetSecond(DateTime.Parse(key.StartDate));
                        double endTime   = Global.GetOffsetSecond(DateTime.Parse(key.EndDate));
                        if (ActType == key.rankType && currSecond >= startTime && currSecond <= endTime)
                        {
                            item.Value.RankValue += addValue;
                        }
                    }
                }
            }
            lock (this.UserChargeMoneyCountDicLock)
            {
                foreach (KeyValuePair <string, Dictionary <int, int> > item2 in this.ChargeMoneyCountDic)
                {
                    RankDataKey key = RankDataKey.GetKeyFromStr(item2.Key.ToString());
                    if (null != key)
                    {
                        double startTime = Global.GetOffsetSecond(DateTime.Parse(key.StartDate));
                        double endTime   = Global.GetOffsetSecond(DateTime.Parse(key.EndDate));
                        if (ActType == key.rankType && currSecond >= startTime && currSecond <= endTime)
                        {
                            if (item2.Value.ContainsKey(addValue))
                            {
                                Dictionary <int, int> value;
                                (value = item2.Value)[addValue] = value[addValue] + 1;
                            }
                            else
                            {
                                item2.Value[addValue] = 1;
                            }
                        }
                    }
                }
            }
            return(0);
        }